Coder Social home page Coder Social logo

adityasunny1189 / ark Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arkscript-lang/ark

0.0 1.0 0.0 3.64 MB

ArkScript is a small, fast, functional and scripting language for C++ projects

Home Page: https://arkscript-lang.github.io/

License: Mozilla Public License 2.0

CMake 1.52% C++ 97.93% Shell 0.15% Dockerfile 0.41%

ark's Introduction

ArkScript Latest version

Codacy Badge Build Status Code size Downloads

Nota bene: the project is referred as "Ark" and as "ArkScript". The official public name is "ArkScript" since "Ark" is already being used by another language

Key features

ArkScript is

  • small: the compiler, and the virtual machines fit under 5000 lines, but also small in term of keywords (it has only 10)!
  • a scripting language: it's very easy to embed it in your application. The builtin construction is quite easy to understand, so adding your own functions to the virtual machine is effortless
  • portable: it produces a bytecode which is run by its virtual machine, like Java but without the OutOfMemoryException
  • a functional language: every parameter is passed by value, everything is immutable unless you use mut to define a mutable variable
  • powerful: it can handle object oriented programming in a very elegant way with its closures and explicit captures (see examples/church-encoding)
  • promoting functionalities before performances: expressiveness often brings more productivity, but performances aren't bad at all
  • easy to compile: it takes less than 200ms to compile and check a complex code with a lot of branches and sub-branches of 200 lines.
  • a Lisp-like, but with less parentheses: [...] is expanded to (list ...) and {} to (begin ...). More shorthands will come in the future.
  • extensible: it is very easy to create a C++ module to use in the language

Also it has:

  • a REPL with autocompletion and coloration
  • a growing standard library, composed of ArkScript (under lib/std/) and C++ (under lib/ext/)
  • a lot of unit tests, which are ran before every release to ensure everything work as intended
  • docker images:

Examples

Fibonacci suite

(let fibo (fun (n)
    (if (< n 2)
        n
        (+ (fibo (- n 1)) (fibo (- n 2))))))

(print (fibo 28))  # display 317811

More or less game

# more or less game
(print "More or less game!")

(import "random.arkm")
(import "Math/Arithmetic.ark")

(let number (mod (abs (random)) 10000))
(print number)
(mut value 0)
(mut tries 0)

(mut continue true)

(while continue {
    (set value (toNumber (input "Input a numeric value: ")))

    (if (< value number)
        # then
        (print "More!")
        # else
        (if (= value number)
            # then
            { (print "Bingo!") (set continue false) }
            # else
            (print "Less!")))

    (set tries (+ 1 tries))})

(print "You won in" tries "tries")

More examples are available in the folder examples/.

Contributing

  • First, fork the repository
  • Then, clone your fork: git clone [email protected]:username/Ark.git
  • Create a branch for your feature: git checkout -b feat-my-awesome-idea
  • When you're done, push it to your fork and submit a pull request!

Don't know what to work on? No worries, we have a list of things to do ๐Ÿ˜‰

Our beloved contributors

Who worked on

Contributing to the ArkScript standard library

See Coding guidelines if you want to write ArkScript for the library (see folder lib/std/).

For performance reasons, some functions might be written in C++, in include/Ark/Builtins/Builtins.hpp and src/Builtins/.

Code structure

ArkScript code structure

Dependencies

  • C++17
  • CMake >= 3.12
  • Visual Studio >= 11 (on Windows)
  • On macOS versions prior to 10.15, libc++ lacks filesystem in the standard library.
    • Install a newer compiler using Homebrew: brew install gcc && brew link gcc
    • Pass compiler path to cmake in the build step: -DCMAKE_CXX_COMPILER=/usr/local/bin/g++-9

Libs already included:

Building

# first, clone it
~$ git clone --depth=50 --branch=dev https://github.com/ArkScript-lang/Ark.git
~/Ark$ cd Ark
~/Ark$ git submodule update --init --recursive
# building Ark
~/Ark$ cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release -DARK_BUILD_EXE=On
~/Ark$ cmake --build build
# installing Ark (might need administrative privileges)
~/Ark$ cmake --install build --config Release
# running
~/Ark$ Ark --help
DESCRIPTION
        ArkScript programming language

SYNOPSIS
        Ark -h
        Ark --version
        Ark --dev-info
        Ark -r
        Ark <file> [-c] [[-d]|-bcr] [-L <lib_dir>] [-f(fac|no-fac)] [-f(aitap|no-aitap)]

OPTIONS
        -h, --help                  Display this message
        --version                   Display ArkScript version and exit
        --dev-info                  Display development information and exit
        -r, --repl                  Run the ArkScript REPL
        -c, --compile               Compile the given program to bytecode, but do not run
        -d, --debug...              Increase debug level (default: 0)
        -bcr, --bytecode-reader     Launch the bytecode reader
        -L, --lib                   Set the location of the ArkScript standard library
        -f(fac|no-fac)              Toggle function arity checks (default: ON)
        -f(aitap|no-aitap)          Authorize invalid token after `(' (default: OFF). When ON, only display a warning      

LICENSE
        Mozilla Public License 2.0

Performances

See https://github.com/ArkScript-lang/benchmarks

Games

You can find a snake created in ArkScript in the folder examples/games/snake (run it from there, otherwise it won't find the font and the sprites ; you won't need to install the SFML).

ArkSnake

Controls are the arrows (left, right, up and down), the game closes itself when you successfully collect the 3 apples.

The donators

Huge thanks to those people for they donation to support the project:

Credits

This project was inspired by gameprogramingpatterns and ofan lisp.cpp

Copyright and Licence information

Copyright (c) 2019-2020 Alexandre Plateau. All rights reserved.

This ArkScript distribution contains no GNU GPL code, which means it can be used in proprietary projects.

ark's People

Contributors

superfola avatar pierrepharel avatar rstefanic avatar unactived avatar rinz13r avatar yardenshoham avatar eliot-akira avatar adityasunny1189 avatar dontbelieveme avatar codacy-badger avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.