GithubHelp home page GithubHelp logo

redchew-fork / ark Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arkscript-lang/ark

0.0 0.0 0.0 6.08 MB

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

Home Page: https://arkscript-lang.dev/

License: Mozilla Public License 2.0

CMake 2.15% C++ 96.81% Shell 0.56% Dockerfile 0.25% Python 0.22%

ark's Introduction

ArkScript Latest version

Code size Downloads GitHub Workflow Status

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 core fit under 8000 lines of code ; also small in terms of keywords (only 10)
  • a scripting language: very easy to embed it in your projects. Registering your own functions in the language is made easy
  • portable: a unique bytecode which can be run everywhere the virtual machine is
  • a functional language: every parameter is passed by value, everything is immutable unless specified
  • powerful: provides closures and explicit capture
  • promoting functionalities before performances: expressiveness often brings more productivity, though performances aren't left behind
  • a Lisp inspired language, with fewer parentheses: [...] is expanded to (list ...) and {} to (begin ...)
  • extensible: supports C++ module to use it in the language, adding functionalities

Also it has:

  • macros: if/else, values, and functions
  • a REPL with autocompletion and coloration
  • a growing standard library, composed of ArkScript code (under lib/std/) and C++ (under lib/ext/)
  • a lot of unit tests (but never enough), which are ran before every release to ensure everything works as expected
  • docker images:
    • stable, built after each release
    • nightly, built after each commit

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

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

(let number (mod (abs (random)) 10000))

(mut value 0)
(mut tries 0)
(mut continue true)

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

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

    (set tries (+ 1 tries))
})

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

More examples are available inside examples/.

Installation

You can either use docker:

docker pull arkscript/stable:latest

# or use the most updated repo
docker pull arkscript/nightly:latest

or build the project with CMake and install it with CMake:

cmake --install build

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

Make sure you follow the contribution guidelines before submitting your pull request!

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

Related projects

We have other projects tightly related to ArkScript, which aren't necessarily C++ oriented:

Our beloved contributors

Full list here.

Coding guidelines for contributing

See C++ Coding guidelines if you want to contribute to ArkScript compiler / runtime.

Also, see ArkScript Coding guidelines for other files, written in ArkScript.

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

Code structure

ArkScript code structure

Building

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

All the external libraries we use are already included in thirdparties.

Through CMake

Different CMake switches are available to customize the build:

  • -DARK_BUILD_EXE to generate an executable, defaults to Off, building a shared library only
  • -DARK_ENABLE_SYSTEM to enable sys:exec (execute shell commands without restrictions), defaults to On
  • -DARK_PROFILER to enable the coz profiler, defaults to Off
  • -DARK_PROFILER_COUNT to count every creation/copy/move of the internal value type, defaults to Off
  • -DARK_PROFILER_MIPS to enable the MIPS counting, defaults to Off
  • -DARK_NO_STDLIB to avoid the installation of the ArkScript standard library
  • -DARK_BUILD_MODULES to trigger the modules build
# first, clone it
git clone --depth=50 --branch=dev https://github.com/ArkScript-lang/Ark.git
cd Ark
git submodule update --init --recursive
# building Ark
cmake . -Bbuild -DCMAKE_BUILD_TYPE=Release -DARK_BUILD_EXE=On
cmake --build build --config Release
# installing Ark (might need administrative privileges)
cmake --install build --config Release

Desired output of arkscript --help:

DESCRIPTION
        ArkScript programming language

SYNOPSIS
        arkscript -h
        arkscript -v
        arkscript --dev-info
        arkscript -e <expression>
        arkscript -c <file> [-d]
        arkscript -bcr <file> -on
        arkscript -bcr <file> [-(a|st|vt)] [-s <start> <end>]
        arkscript -bcr <file> [-cs] [-p <page>]
        arkscript <file> [-d] [-L <lib_dir>]

OPTIONS
        -h, --help                  Display this message
        -v, --version               Display ArkScript version and exit
        --dev-info                  Display development information and exit
        -e, --eval                  Evaluate ArkScript expression
        -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
        -on, --only-names           Display only the bytecode segments names and sizes
        -a, --all                   Display all the bytecode segments (default)
        -st, --symbols              Display only the symbols table
        -vt, --values               Display only the values table
        -s, --slice                 Select a slice of instructions in the bytecode
        -cs, --code                 Display only the code segments
        -p, --page                  Set the bytecode reader code segment to display
        -L, --lib                   Set the location of the ArkScript standard library

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 their donations to support the project:

Credits

This project was inspired by gameprogramingpatterns and ofan lisp.cpp

Copyright and Licence information

Copyright (c) 2019-2021 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

biothewolff avatar codacy-badger avatar dontbelieveme avatar eliot-akira avatar fowled avatar gryfenfer97 avatar jsanestrzik avatar loki-astari avatar mattn avatar maxnatamo avatar owenl131 avatar pierrepharel avatar piyussshh avatar qix- avatar rakista112 avatar raloverast avatar rinz13r avatar rstefanic avatar sdachess avatar shehab7osny avatar superfola avatar unactived avatar wafelack avatar yardenshoham 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.