ArkScript-lang / Ark

Licence: mpl-2.0
ArkScript is a small, fast, functional and scripting language for C++ projects

Programming Languages

cpp
1120 projects
language
365 projects
lisp
113 projects
scripting
82 projects

Projects that are alternatives of or similar to Ark

Customasm
💻 An assembler for custom, user-defined instruction sets! https://hlorenzi.github.io/customasm/web/
Stars: ✭ 211 (-32.37%)
Mutual labels:  compiler, virtual-machine, vm
Quickjs
QuickJS是一个小型并且可嵌入的Javascript引擎,它支持ES2020规范,包括模块,异步生成器和代理器。
Stars: ✭ 2,199 (+604.81%)
Mutual labels:  compiler, virtual-machine, vm
Quickjs
The official repo is at bellard/quickjs.
Stars: ✭ 1,429 (+358.01%)
Mutual labels:  compiler, virtual-machine, vm
Smlvm
Smallrepo Virtual Machine
Stars: ✭ 265 (-15.06%)
Mutual labels:  compiler, virtual-machine, vm
c8c
The chip8 compiler, assembler, and virtual machine
Stars: ✭ 110 (-64.74%)
Mutual labels:  vm, virtual-machine
specter
a (tiny) VM project built with Go
Stars: ✭ 57 (-81.73%)
Mutual labels:  vm, virtual-machine
SBTCVM-Gen2-9
SBTCVM is a virtual machine implementation of a balanced ternary (base 3) computer. Features several compiled languages for ternary software development.
Stars: ✭ 32 (-89.74%)
Mutual labels:  vm, virtual-machine
kcs
Scripting in C with JIT(x64)/VM.
Stars: ✭ 25 (-91.99%)
Mutual labels:  vm, virtual-machine
Never
Never: statically typed, embeddable functional programming language.
Stars: ✭ 248 (-20.51%)
Mutual labels:  compiler, virtual-machine
RSqueak
A Squeak/Smalltalk VM written in RPython.
Stars: ✭ 78 (-75%)
Mutual labels:  vm, virtual-machine
vm-automation
VirtualBox automation using Python
Stars: ✭ 1 (-99.68%)
Mutual labels:  vm, virtual-machine
Tagha
Minimal, low-level, fast, and self-contained register-based bytecode virtual machine/runtime environment.
Stars: ✭ 101 (-67.63%)
Mutual labels:  vm, virtual-machine
clox
A virtual machine and a tree-walk interpreter for the Lox programming language in C89 🌀
Stars: ✭ 38 (-87.82%)
Mutual labels:  vm, virtual-machine
butterfly
Butterfly connects Virtual Machines and control their traffic flow
Stars: ✭ 48 (-84.62%)
Mutual labels:  vm, virtual-machine
Mtail
extract internal monitoring data from application logs for collection in a timeseries database
Stars: ✭ 3,028 (+870.51%)
Mutual labels:  compiler, vm
Animach
Scheme语言实现和运行时环境 / A Scheme runtime & implementation
Stars: ✭ 45 (-85.58%)
Mutual labels:  vm, virtual-machine
open-semantic-desktop-search
Virtual Machine for Desktop Search with Open Semantic Search
Stars: ✭ 22 (-92.95%)
Mutual labels:  vm, virtual-machine
js5005
js5005 is a virtual CPU with every logic gate simulated. A pretty interface, a built in assembler, display, and 256 bytes of RAM to boot. It's the better i4004.
Stars: ✭ 14 (-95.51%)
Mutual labels:  vm, virtual-machine
RISVM
A low overhead, embeddable bytecode virtual machine in C++
Stars: ✭ 21 (-93.27%)
Mutual labels:  vm, virtual-machine
Swift Lispkit
Interpreter framework for Lisp-based extension and scripting languages on macOS and iOS. LispKit is based on the R7RS standard for Scheme. Its compiler generates bytecode for a virtual machine. LispKit is fully implemented in Swift 5.
Stars: ✭ 228 (-26.92%)
Mutual labels:  compiler, virtual-machine

ArkScript Latest version

Codacy Badge Code size Downloads CMake

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 8000 lines, but also small in terms 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 fewer 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/.

Installation

Through the latest release

Linux only

Important: this method will add the folder where ArkScript will be downloaded to your path. The executable being named ark you can have conflicts with another existing program named ark as well, a KDE archiving tool.

mkdir -p "${HOME}/.ark"
cd "${HOME}/.ark"
install_dir=`pwd`

current=`curl -s https://github.com/ArkScript-lang/Ark/releases/latest | egrep -o "tag/(?[^\"]+)" | cut -c 5- -`
url="https://github.com/ArkScript-lang/Ark/releases/download/$current/linux64.zip"
wget --quiet $url

if [ -f linux64.zip ]; then
    unzip -o linux64.zip
    rm linux64.zip
fi

# export arkscript path to your PATH variable to call it from everywhere
# export also ARKSCRIPT_PATH for arkscript to find its standard library
cat >> $HOME/.bashrc<< EOF
export PATH="$PATH:${install_dir}/"
export ARKSCRIPT_PATH="${install_dir}"
EOF

Finally, don't forget to source $HOME/.bashrc to refresh your path.

Through docker

$ docker pull arkscript/stable:latest

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

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

Some libs 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_SCOPE_DICHOTOMY to activate the dichotomic mode of the scope, defaults to Off
# 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 . -Bbuild -DCMAKE_BUILD_TYPE=Release -DARK_BUILD_EXE=On
~/Ark$ cmake --build build --config Release
# installing Ark (might need administrative privileges)
~/Ark$ cmake --install build --config Release
# running
~/Ark$ ark --help
DESCRIPTION
        ArkScript programming language

SYNOPSIS
        ark -h
        ark -v
        ark --dev-info
        ark -e <expression>
        ark -c <file> [-d]
        ark -bcr <file>
        ark <file> [-d] [-L <lib_dir>] [-f(fac|no-fac)] [-f(ruv|no-ruv)]

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
        -L, --lib                   Set the location of the ArkScript standard library   
        -f(fac|no-fac)              Toggle function arity checks (default: ON)
        -f(ruv|no-ruv)              Remove unused variables (default: ON)

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].