Daslang

News

Overview

Daslang (former 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.

Daslang is:

Daslang offers a wide range of features like:

Daslang 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 Daslang, 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 Daslang 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?

Daslang'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

Daslang'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.

Daslang 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, Daslang requires support for C++17.

Performance

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

Daslang 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 Daslang is comparable to C++ in Debug mode, as demonstrated by the Particles sample.

Tested on AMD Ryzen Threadripper 3990X 64-Core Processor at Tue Jun 18 14:51:21 2024
CLANG 17.0.6

Interpreted

Test DAS INTERPRETERLUALUAJIT -joffLUAUMONO --interpreterQUICKJSQUIRRELSQUIRREL3
dictionary 1.00 (0.0167)3.97 (0.0660)1.00 (0.0166)1.78 (0.0297)80.52 (1.3387)6.07 (0.1010)5.23 (0.0870)6.74 (0.1120)
exp loop 1.00 (0.0114)4.47 (0.0510)3.31 (0.0377)1.78 (0.0203)34.47 (0.3930)7.63 (0.0870)7.63 (0.0870)7.45 (0.0850)
fibonacci loop 1.00 (0.0375)2.40 (0.0900)1.20 (0.0451)2.05 (0.0768)3.50 (0.1312)3.31 (0.1240)4.19 (0.1570)2.99 (0.1120)
fibonacci recursive 1.00 (0.0549)1.86 (0.1020)1.09 (0.0601)1.65 (0.0908)2.03 (0.1113)3.06 (0.1680)5.48 (0.3010)5.50 (0.3020)
float2string 1.04 (0.0778)8.00 (0.6010)2.29 (0.1717)1.00 (0.0751)74.10 (5.5678)48.26 (3.6260)N/AN/A
mandelbrot 1.00 (0.0031)52.85 (0.1640)19.23 (0.0597)17.77 (0.0551)8.39 (0.0260)N/AN/AN/A
n-bodies 1.00 (0.2139)5.45 (1.1670)2.63 (0.5630)3.28 (0.7025)5.42 (1.1593)11.34 (2.4270)13.42 (2.8700)13.13 (2.8090)
native loop 1.00 (0.0372)N/A23.72 (0.8821)N/A39.22 (1.4586)N/A18.69 (0.6950)N/A
particles kinematics 1.00 (0.0118)102.25 (1.2090)25.72 (0.3041)32.64 (0.3859)54.50 (0.6445)120.18 (1.4210)55.99 (0.6620)121.45 (1.4360)
primes loop 1.00 (0.0408)2.35 (0.0960)1.67 (0.0683)2.29 (0.0936)3.80 (0.1552)3.16 (0.1290)8.52 (0.3480)8.25 (0.3370)
queen 1.00 (0.0013)1.60 (0.0020)1.00 (0.0012)1.38 (0.0017)N/AN/AN/AN/A
sha256 1.00 (0.1233)N/A2.05 (0.2524)5.88 (0.7252)N/AN/AN/AN/A
sort 1.00 (0.0320)2.85 (0.0910)2.19 (0.0700)1.63 (0.0520)8.70 (0.2782)N/AN/AN/A
spectral norm 1.00 (0.2044)2.87 (0.5860)1.41 (0.2882)1.16 (0.2375)2.15 (0.4391)4.31 (0.8820)N/AN/A
string2float 1.00 (0.0274)7.44 (0.2040)4.92 (0.1350)4.59 (0.1260)200.18 (5.4922)16.62 (0.4560)N/AN/A
tree 1.33 (1.7525)2.17 (2.8580)1.00 (1.3200)1.33 (1.7606)1.45 (1.9074)12.79 (16.8780)N/AN/A

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

In terms of performance, Daslang 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, Daslang can even outperform C++.

Daslang Just-in-Time compilation is based on LLVM backend, and often outperforms C++, due to Daslang 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
CLANG 17.0.6, AOT CLANG 17.0.6, JIT LLVM 16.0.6

AOT or JIT

Test .NETC++DAS AOTDAS JITLUAJITLUAU --codegenMONO
dictionary 7.69 (0.0781)4.23 (0.0429)1.00 (0.0101)1.03 (0.0105)1.20 (0.0122)2.25 (0.0229)7.61 (0.0772)
exp loop 1.49 (0.0055)1.00 (0.0037)1.38 (0.0051)1.01 (0.0037)4.84 (0.0179)2.27 (0.0084)2.85 (0.0105)
fibonacci loop 1.26 (0.0020)1.00 (0.0016)1.00 (0.0016)1.20 (0.0019)3.01 (0.0048)22.06 (0.0350)1.58 (0.0025)
fibonacci recursive 1.67 (0.0065)1.00 (0.0039)1.15 (0.0045)1.17 (0.0046)3.26 (0.0127)15.32 (0.0598)2.05 (0.0080)
float2string 5.01 (0.3279)4.51 (0.2954)1.00 (0.0655)1.03 (0.0674)2.38 (0.1559)1.06 (0.0691)6.96 (0.4555)
mandelbrot 4.43 (0.0020)1.00 (0.0005)1.39 (0.0006)1.02 (0.0005)16.60 (0.0075)83.70 (0.0378)8.85 (0.0040)
n-bodies 1.87 (0.0386)1.31 (0.0270)1.31 (0.0270)1.00 (0.0207)3.95 (0.0816)11.13 (0.2299)3.77 (0.0780)
native loop 13.18 (0.1602)N/A1.01 (0.0122)1.01 (0.0122)1.00 (0.0122)N/A10.99 (0.1336)
particles kinematics 2.20 (0.0065)1.51 (0.0045)1.00 (0.0030)1.03 (0.0030)69.15 (0.2051)67.02 (0.1988)30.71 (0.0911)
primes loop 2.82 (0.0379)2.86 (0.0385)1.00 (0.0135)1.00 (0.0135)1.01 (0.0136)2.59 (0.0349)2.81 (0.0378)
queen 48.79 (0.0055)1.02 (0.0001)1.27 (0.0001)1.00 (0.0001)3.91 (0.0004)7.43 (0.0008)N/A
sha256 1.54 (0.0075)N/A1.05 (0.0051)1.00 (0.0049)7.01 (0.0342)114.95 (0.5606)N/A
sort 2.32 (0.0125)1.04 (0.0056)1.00 (0.0054)1.67 (0.0090)13.43 (0.0723)9.06 (0.0488)1.95 (0.0105)
spectral norm 1.00 (0.0120)1.03 (0.0123)1.03 (0.0124)1.03 (0.0124)1.21 (0.0146)4.73 (0.0568)2.21 (0.0265)
string2float 4.74 (0.1126)4.25 (0.1012)1.00 (0.0239)1.00 (0.0238)4.93 (0.1172)4.85 (0.1154)7.64 (0.1817)
tree 1.42 (0.2473)1.01 (0.1755)1.00 (0.1738)1.02 (0.1778)5.76 (1.0010)7.91 (1.3748)1.48 (0.2566)

All samples for all languages in comparison are available in GitHub

Work in Progress

Documentation

Daslang 0.4

Online Daslang 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

Daslang's GitHub repository is here

Authors blog

Boris Batkin blog on Daslang (in English)

Other useful links

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