Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ArkScript-lang/Ark
ArkScript is a small, fast, functional and scripting language for C++ projects
https://github.com/ArkScript-lang/Ark
ark arkscript compiler cpp language lisp programming-language scripting scripting-language virtual-machine vm
Last synced: 3 months ago
JSON representation
ArkScript is a small, fast, functional and scripting language for C++ projects
- Host: GitHub
- URL: https://github.com/ArkScript-lang/Ark
- Owner: ArkScript-lang
- License: mpl-2.0
- Created: 2019-06-03T09:52:14.000Z (about 5 years ago)
- Default Branch: dev
- Last Pushed: 2024-04-11T20:19:49.000Z (3 months ago)
- Last Synced: 2024-04-12T00:51:27.459Z (3 months ago)
- Topics: ark, arkscript, compiler, cpp, language, lisp, programming-language, scripting, scripting-language, virtual-machine, vm
- Language: C++
- Homepage: https://arkscript-lang.dev/
- Size: 5 MB
- Stars: 547
- Watchers: 11
- Forks: 42
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- Code of conduct: CODE_OF_CONDUCT.md
Lists
- awesome-game-engine-dev - ArkScript - Small, fast, functional and scripting language. (Libraries / C++)
- awesome-stars - ArkScript-lang/Ark - ArkScript is a small, fast, functional and scripting language for C++ projects (C++)
- awesome-stars - ArkScript-lang/Ark - ArkScript is a small, fast, functional and scripting language for C++ projects (C++)
- awesome-stars - ArkScript-lang/Ark - ArkScript is a small, fast, functional and scripting language for C++ projects (C++)
- awesome-programming-languages - ArkScript - ArkScript is a small, fast, functional and scripting language for C++ projects ; the syntax is inspired by Lisp. It's a scripting language aiming for high portability and easily embedding in C++ projects, with a few nice features such as tail call optimization and macros. (Uncategorized / Uncategorized)
README
# ArkScript ![Latest version](https://img.shields.io/github/v/release/arkscript-lang/ark?style=for-the-badge)
![Code size](https://img.shields.io/github/languages/code-size/arkscript-lang/ark?style=for-the-badge&logo=github)
![Downloads](https://img.shields.io/github/downloads/arkscript-lang/ark/total?color=%2324cc24&style=for-the-badge&logo=github)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/ArkScript-lang/Ark/ci.yml?logo=cmake&style=for-the-badge&branch=4.0)
* [Documentation](https://arkscript-lang.dev/documentation.html)
* [Discussions](https://github.com/orgs/ArkScript-lang/discussions): to receive help with the language, discuss new features and ideas
* [Modules](https://github.com/ArkScript-lang/modules)**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](https://github.com/ark-lang/ark)
## 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 functionalitiesAlso it has:
* **macros**: if/else, values, and functions
* tail call optimization
* 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](https://hub.docker.com/r/arkscript/stable), built after each release
* [nightly](https://hub.docker.com/r/arkscript/nightly), built after each commit## Examples
### Fibonacci suite
```clojure
(let fibo (fun (n)
(if (< n 2)
n
(+ (fibo (- n 1)) (fibo (- n 2))))))(print (fibo 28)) # display 317811
```## More or less game
```clojure
(import "random.arkm")
(import "Math.ark")(let number (mod (math:abs (random)) 10000))
(let game (fun () {
(let impl (fun (tries) {
(let guess (toNumber (input "Input a numeric value: ")))(if (< guess number)
{
(print "It's more than " guess)
(impl (+ tries 1))}
(if (= guess number)
{
(print "You found it!")
tries }
{
(print "It's less than " guess)
(impl (+ tries 1))}))}))(let tries (impl 0))
(print "You won in " tries " tries.")}))(game)
```More examples are available inside `examples/`.
## Installation
You can either use docker:
```bash
docker pull arkscript/stable:latest# or use the most updated repo
docker pull arkscript/nightly:latest
```or [build the project with CMake](#building) and install it with CMake:
```bash
cmake --install build
```## Contributing
* First, [fork](https://github.com/ArkScript-lang/Ark/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 requestMake sure you follow the [contribution guidelines](CONTRIBUTING.md) before submitting your pull request!
Don't know what to work on? No worries, we have a [list of things to do](https://github.com/ArkScript-lang/Ark/issues) :wink:
### Related projects
We have other projects tightly related to ArkScript, which aren't necessarily C++ oriented:
* the [standard library](https://github.com/ArkScript-lang/std), written in ArkScript itself
* the [standard library modules](https://github.com/ArkScript-lang/modules), extending the capacities of the language, written in C++
* [ArkDoc](https://github.com/ArkScript-lang/ArkDoc), a documentation generator *à la doxygen* for ArkScript, written in Python 3
* our [website](https://github.com/ArkScript-lang/arkscript-lang.github.io) written in HTML, CSS and JavaScript### Our beloved contributors
[Full list here](https://github.com/ArkScript-lang/Ark/graphs/contributors).
### Coding guidelines for contributing
See [C++ Coding guidelines](https://github.com/ArkScript-lang/Ark/blob/dev/CONTRIBUTING.md#c-coding-guidelines) if you want to contribute to ArkScript compiler / runtime.
Also, see [ArkScript Coding guidelines](https://github.com/ArkScript-lang/Ark/blob/dev/docs/guidelines_coding.md) 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](images/diagram.svg)
## Building
### Dependencies
* C++20
* CMake >= 3.15
* 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](https://docs.brew.sh/): `brew install gcc && brew link gcc`
* Pass compiler path to `cmake` in the build step: `-DCMAKE_CXX_COMPILER=/usr/local/bin/g++-9 -DCMAKE_C_COMPILER=/usr/local/bin/gcc-9`:warning: When passing a specific C++ compiler to CMake, add the corresponding C compiler as ArkScript relies on C code as well ; otherwise you'll cryptic get compilation/linking errors (using `CMAKE_CXX_COMPILER` and `CMAKE_C_COMPILER`).
All the external libraries we use are already included in [thirdparties](https://github.com/ArkScript-lang/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_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
* `-DARK_SANITIZERS` to enable ASAN and UBSAN
* `-DARK_TESTS` to build the unit tests (separate target named `unittests`)```bash
# 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`:
```bash
DESCRIPTION
ArkScript programming languageSYNOPSIS
arkscript -h
arkscript -v
arkscript --dev-info
arkscript -e
arkscript -c [-d]
arkscript [-d] [-L ]
arkscript -f [--dry-run]
arkscript --ast [-d] [-L ]
arkscript -bcr -on
arkscript -bcr -a [-s ]
arkscript -bcr -st [-s ]
arkscript -bcr -vt [-s ]
arkscript -bcr [-cs] [-p ] [-s ]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)-L, --lib Set the location of the ArkScript standard library. Paths can be
delimited by ';'-f, --format Format the given source file in place
--dry-run Do not modify the file, only print out the changes--ast Compile the given program and output its AST as JSON to stdout
-d, --debug... Increase debug level (default: 0)
-L, --lib Set the location of the ArkScript standard library. Paths can be
delimited by ';'-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
-cs, --code Display only the code segments
-p, --page Set the bytecode reader code segment to display
-s, --slice Select a slice of instructions in the bytecodeVERSION
4.0.0-86587c14LICENSE
Mozilla Public License 2.0
```### In your own project
Please refer to the [embedding ArkScript](https://arkscript-lang.dev/impl/d7/dea/tutorial_embedding.html) tutorial.
## 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](images/ArkSnake.png)
Controls are the arrows (left, right, up and down), the game closes itself when you successfully collect the 3 apples.
## The donors
Huge thanks to those people for their donations to support the project:
* [TheCountVEVO](https://github.com/TheCountVEVO)
* [llexto](https://github.com/llexto)
* COUR Eloïse
* [AKPINAR Dylan](https://github.com/DylanAkp)
* [Ryan C. Gordon](https://icculus.org) through his [2022 Microgrant](https://twitter.com/icculus/status/1534552918317318144)## Credits
This project was inspired by [gameprogramingpatterns](http://gameprogrammingpatterns.com/bytecode.html) and [ofan lisp.cpp](https://gist.github.com/ofan/721464)
## Copyright and Licence information
Copyright (c) 2019-2024 Alexandre Plateau. All rights reserved.
This ArkScript distribution contains no GNU GPL code, which means it can be used in proprietary projects.