daScript

News

As of May 1st, 2023, version 0.4 of daScript has been released. The development team is currently working on the next major release, which will include a fully featured JIT compiler. This JIT compiler is currently available as a preview.

daScript now happily runs in the web browser. Check it out.

We now have an official blog

November 18th, 2021: version 0.3 released.

September 5th, 2020: version 0.2 released.

24 August 2020: A lot of documentation has been added.
tio.run sandbox added.

28 October 2019: Benchmarks has been updated. All lang compilers were built in LLVM8.0, architecture AVX.

15 August 2019: daScript site has been released, check it out.

Overview

daScript is a high-level programming language that features strong static typing. It is designed to provide high performance and serves as an embeddable 'scripting' language for C++ applications that require fast and reliable performance, such as games or back end/servers. Additionally, it functions effectively as a standalone programming language.

daScript is:

daScript offers a wide range of features like:

daScript takes inspiration from languages like Python, Ruby, Kotlin, and Haxe when it comes to its explicitness and readability. However, it is also designed to be extremely fast, making it an ideal choice for performance-critical applications.

A Visual Studio Code extension is available for daScript, providing comprehensive support for the language. This extension offers features such as code diagnostics, code completion, code navigation, hints, and more. Additionally, it provides a rich debugging environment, allowing developers to easily debug their daScript code. It also includes a profiler for measuring and optimizing code performance. You can find this extension on the Visual Studio Code Marketplace at the following link: https://marketplace.visualstudio.com/items?itemName=profelis.dascript-plugin.

What Does it look like?

daScript's syntax is reminiscent of (Typed) Python, while its static strong typed nature is similar to ML or Zig. Its POD types are closely aligned with hardware/machine types. Additionally, the language makes use of type inference, as can be seen in the following Fibonacci code snippet.

def fibR(n)
    if (n < 2)
        return n
    else
        return fibR(n - 1) + fibR(n - 2)

def fibI(n)
    var last = 0
    var cur = 1
    for i in range(0, n-1)
        let tmp = cur
        cur += last
        last = tmp
    return cur
Also, for those who for some reason prefer curly brackets over Python-style indenting, it is also possible to write:

def fibR(n) {
    if (n < 2) {
        return n;
    } else {
        return fibR(n - 1) + fibR(n - 2);
    }
}
def fibI(n) {
    var last = 0;
    var cur = 1;
    for i in range(0, n-1); {
        let tmp = cur;
        cur += last;
        last = tmp;
    }
    return cur;
}
(Note that within curly brackets semicolons (;) are required to separate statements).

Development state

daScript's current version is 0.4, and it's already being used in production projects at Gaijin Entertainment. Until the release of version 1.0, there will be no patches or fixes for older versions. Instead, all updates and fixes will be made available exclusively in the master branch.

daScript has been successfully compiled and run on a wide range of platforms, including Windows (x86 & x64), Linux (x64), macOS, Xbox One, Xbox One Series X, PlayStation 4, PlayStation 5, Nintendo Switch, iOS, Android, and WebAssembly.

Has been tested with the following compilers with C++17 support:

MS Visual C++ 17, 19, and 22 (x86 & x64)
Linux GCC
LLVM 7 and above

To compile, daScript requires support for C++17.

Performance

As an interpreted language, daScript typically outperforms everything, including the blazing fast LuaJIT.

daScript particularly excels in interop with C++ functions, providing an easy and seamless experience when it comes to integrating new functions and types.

The overhead of data-oriented processing in interpretation mode in daScript is comparable to C++ in Debug mode, as demonstrated by the Particles sample.

Tested on AMD Ryzen Threadripper 3990X 64-Core Processor at Fri Mar 15 23:33:28 2024

Interpreted

Test DAS INTERPRETERLUALUAJIT -joffLUAUMONO --interpreterQUICKJSQUIRRELSQUIRREL3
dictionary 1.00 (0.0162)4.02 (0.0650)1.02 (0.0165)1.78 (0.0288)83.16 (1.3455)6.12 (0.0990)5.44 (0.0880)6.55 (0.1060)
exp loop 1.00 (0.0112)4.64 (0.0520)3.29 (0.0369)1.73 (0.0194)33.85 (0.3792)7.59 (0.0850)7.77 (0.0870)7.59 (0.0850)
fibonacci loop 1.00 (0.0303)2.84 (0.0860)1.47 (0.0444)2.43 (0.0735)4.27 (0.1292)4.00 (0.1210)4.96 (0.1500)3.64 (0.1100)
fibonacci recursive 1.00 (0.0567)1.76 (0.1000)1.01 (0.0573)1.55 (0.0877)1.93 (0.1094)2.89 (0.1640)5.15 (0.2920)5.24 (0.2970)
mandelbrot 1.00 (0.0028)55.30 (0.1570)20.49 (0.0582)19.32 (0.0548)8.91 (0.0253)N/AN/AN/A
n-bodies 1.00 (0.2367)4.60 (1.0890)2.31 (0.5462)2.86 (0.6780)4.81 (1.1393)10.03 (2.3750)11.87 (2.8090)11.67 (2.7620)
native loop 1.00 (0.0365)N/A23.71 (0.8665)N/A48.92 (1.7880)N/A19.10 (0.6980)N/A
particles kinematics 1.00 (0.0110)109.33 (1.2020)26.61 (0.2926)34.36 (0.3778)55.82 (0.6137)126.07 (1.3860)58.40 (0.6420)130.25 (1.4320)
primes loop 1.00 (0.0400)2.32 (0.0930)1.67 (0.0668)2.31 (0.0926)3.86 (0.1545)3.17 (0.1270)8.52 (0.3410)8.32 (0.3330)
queen 1.03 (0.0013)1.64 (0.0020)1.00 (0.0012)1.40 (0.0017)N/AN/AN/AN/A
sha256 1.00 (0.1153)N/A2.17 (0.2497)6.17 (0.7119)N/AN/AN/AN/A
sort 1.00 (0.0315)2.83 (0.0890)2.19 (0.0689)1.64 (0.0516)9.02 (0.2838)N/AN/AN/A
spectral norm 1.00 (0.1995)2.88 (0.5740)1.42 (0.2823)1.18 (0.2346)2.14 (0.4264)4.36 (0.8690)N/AN/A
tree 1.28 (1.8590)1.93 (2.7920)1.00 (1.4485)1.22 (1.7634)1.30 (1.8836)11.20 (16.2290)N/AN/A

As a compiled Ahead-of-Time language, daScript is significantly faster than both LuaJIT and Chrome JS, both of which have extremely fast Just-in-Time compilers.

In terms of performance, daScript is nearly on par with naive C++ (compiled with clang-cl llvm 8.0.1 with all optimizations), typically differing by no more than 10%. In some cases, daScript can even outperform C++.

daScript Just-in-Time compilation is based on LLVM backend, and often outperforms C++, due to daScript providing more information to LLVM than AOT.

It is worth noting that unlike Just-in-Time compilation, Ahead-of-Time compilation can be used on any platform, including those with signed binary executables like iOS or consoles.

Tested on AMD Ryzen Threadripper 3990X 64-Core Processor at Fri Mar 15 23:33:28 2024

AOT or JIT

Test .NETC++DAS AOTDAS JITLUAJITLUAU --codegenMONO
dictionary 7.76 (0.0776)4.10 (0.0410)1.00 (0.0100)1.03 (0.0103)1.20 (0.0120)2.26 (0.0226)7.40 (0.0740)
exp loop 1.52 (0.0056)1.00 (0.0036)1.33 (0.0049)1.00 (0.0036)4.80 (0.0175)2.21 (0.0081)2.75 (0.0100)
fibonacci loop 1.93 (0.0030)1.01 (0.0016)1.00 (0.0016)1.21 (0.0019)3.02 (0.0047)22.30 (0.0346)1.93 (0.0030)
fibonacci recursive 1.71 (0.0066)1.00 (0.0038)1.17 (0.0045)1.16 (0.0045)3.28 (0.0126)15.34 (0.0590)2.08 (0.0080)
mandelbrot 4.37 (0.0020)1.27 (0.0006)1.34 (0.0006)1.00 (0.0005)16.13 (0.0074)81.45 (0.0373)8.73 (0.0040)
n-bodies 1.88 (0.0380)1.33 (0.0267)1.30 (0.0262)1.00 (0.0202)3.96 (0.0799)11.62 (0.2342)3.90 (0.0786)
native loop 13.11 (0.1572)N/A1.01 (0.0121)1.00 (0.0120)1.00 (0.0120)N/A10.86 (0.1302)
particles kinematics 2.41 (0.0070)1.17 (0.0034)1.00 (0.0029)1.01 (0.0029)64.44 (0.1868)67.50 (0.1957)30.91 (0.0896)
primes loop 2.85 (0.0376)2.86 (0.0378)1.00 (0.0132)1.00 (0.0132)1.01 (0.0133)2.58 (0.0341)2.80 (0.0370)
queen 37.06 (0.0040)1.05 (0.0001)1.27 (0.0001)1.00 (0.0001)4.02 (0.0004)7.59 (0.0008)N/A
sha256 1.37 (0.0070)N/A1.08 (0.0055)1.00 (0.0051)6.48 (0.0332)107.30 (0.5500)N/A
sort 2.29 (0.0120)1.02 (0.0053)1.00 (0.0052)1.68 (0.0088)13.67 (0.0716)8.85 (0.0464)1.91 (0.0100)
spectral norm 1.00 (0.0120)1.01 (0.0121)1.01 (0.0121)1.00 (0.0121)1.19 (0.0142)4.67 (0.0560)2.17 (0.0260)
tree 1.41 (0.2438)1.00 (0.1726)1.00 (0.1730)1.01 (0.1735)5.15 (0.8896)7.84 (1.3525)1.46 (0.2528)

All samples for all languages in comparison are available in GitHub

Work in Progress

Documentation

daScript 0.4

Online daScript 0.4 reference manual and Standard Libraries manual

Offline Reference Manual (PDF)
Offline Standard Libraries Manual (PDF)

Sandbox

Try it in your browser implemented with Emscripten, runs in your browser.
Try it online implemented with tio.run fork.

Download

GitHub Repository

daScript's GitHub repository is here

Authors blog

Boris Batkin blog on daScript (in English)

Other useful links

Language server plugin for VSCode with auto-completion, help, etc - itself written in daScript.
dasBox - simple framework allowing create games in daScript.
Article on history of daScript.
Spiiin's blog on daScript (in Russian)