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 Mon Sep 30 15:32:40 2024
CLANG 17.0.6

Interpreted

dictionary

DAS INTERPRETER
0.0189  (1.13)
LUA
0.0660  (3.96)
LUAJIT -joff
LUAU
0.0307  (1.84)
QUICKJS
0.1020  (6.13)
QUIRREL
0.0880  (5.28)
SQUIRREL3
0.1110  (6.67)

exp loop

DAS INTERPRETER
LUA
0.0520  (4.18)
LUAJIT -joff
0.0382  (3.08)
LUAU
0.0204  (1.64)
QUICKJS
0.0870  (7.00)
QUIRREL
0.0860  (6.92)
SQUIRREL3
0.0850  (6.84)

fibonacci loop

DAS INTERPRETER
LUA
0.0900  (2.53)
LUAJIT -joff
0.0454  (1.28)
LUAU
0.0775  (2.18)
QUICKJS
0.1260  (3.54)
QUIRREL
0.1390  (3.91)
SQUIRREL3
0.1110  (3.12)

fibonacci recursive

DAS INTERPRETER
LUA
0.1020  (1.91)
LUAJIT -joff
0.0588  (1.10)
LUAU
0.0892  (1.67)
QUICKJS
0.1670  (3.12)
QUIRREL
0.2580  (4.82)
SQUIRREL3
0.2750  (5.14)

float2string

DAS INTERPRETER
LUA
0.6210  (8.19)
LUAJIT -joff
0.1723  (2.27)
LUAU
QUICKJS
3.6120  (47.63)
QUIRREL
0.1080  (1.42)
SQUIRREL3
0.1070  (1.41)

mandelbrot

DAS INTERPRETER
LUA
0.1640  (53.93)
LUAJIT -joff
0.0597  (19.64)
LUAU
0.0555  (18.24)

n-bodies

DAS INTERPRETER
LUA
1.2500  (5.96)
LUAJIT -joff
0.5590  (2.66)
LUAU
0.6912  (3.29)
QUICKJS
2.4450  (11.65)
QUIRREL
0.2400  (1.14)
SQUIRREL3
0.2870  (1.37)

native loop

DAS INTERPRETER
LUAJIT -joff
0.8819  (23.68)

particles kinematics

DAS INTERPRETER
LUA
1.2270  (103.66)
LUAJIT -joff
0.3007  (25.41)
LUAU
0.3925  (33.16)
QUICKJS
1.4440  (121.99)
QUIRREL
0.6090  (51.45)
SQUIRREL3
1.4890  (125.79)

primes loop

DAS INTERPRETER
LUA
0.0960  (2.34)
LUAJIT -joff
0.0690  (1.68)
LUAU
0.0942  (2.29)
QUICKJS
0.1310  (3.19)
QUIRREL
0.3340  (8.13)
SQUIRREL3
0.3360  (8.17)

queen

DAS INTERPRETER
0.0013  (1.01)
LUA
0.0020  (1.60)
LUAJIT -joff
LUAU
0.0018  (1.40)
QUIRREL
0.0040  (3.19)
SQUIRREL3
0.0040  (3.19)

sha256

DAS INTERPRETER
LUAJIT -joff
0.2541  (2.10)
LUAU
0.7353  (6.06)

sort

DAS INTERPRETER
0.0320  (1.33)
LUA
0.0920  (3.83)
LUAJIT -joff
0.0701  (2.92)
LUAU
0.0531  (2.21)
QUIRREL
SQUIRREL3
0.0280  (1.17)

spectral norm

DAS INTERPRETER
LUA
0.5930  (2.90)
LUAJIT -joff
0.2894  (1.42)
LUAU
0.2391  (1.17)
QUICKJS
0.8880  (4.35)
QUIRREL
1.4390  (7.05)
SQUIRREL3
1.4800  (7.25)

string2float

DAS INTERPRETER
LUA
0.2040  (7.00)
LUAJIT -joff
0.1362  (4.67)
LUAU
0.1271  (4.36)
QUICKJS
0.4590  (15.75)
QUIRREL
0.3060  (10.50)
SQUIRREL3
0.4290  (14.72)

tree

DAS INTERPRETER
1.7543  (1.17)
LUA
2.9080  (1.94)
LUAJIT -joff
LUAU
1.7688  (1.18)

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 Mon Sep 30 15:32:40 2024
CLANG 17.0.6

AOT or JIT

dictionary

.NET
0.0795  (7.87)
C++
0.0439  (4.34)
DAS AOT
DAS JIT
0.0105  (1.03)
LUAJIT
0.0121  (1.20)
LUAU --codegen
0.0233  (2.31)
MONO
0.0766  (7.58)

exp loop

.NET
0.0060  (1.63)
C++
DAS AOT
0.0062  (1.68)
DAS JIT
LUAJIT
0.0179  (4.85)
LUAU --codegen
0.0085  (2.30)
MONO
0.0100  (2.72)

fibonacci loop

.NET
0.0030  (1.89)
C++
DAS AOT
DAS JIT
0.0019  (1.21)
LUAJIT
0.0048  (3.02)
LUAU --codegen
0.0328  (20.72)
MONO
0.0030  (1.89)

fibonacci recursive

.NET
0.0063  (1.56)
C++
0.0043  (1.07)
DAS AOT
DAS JIT
0.0045  (1.11)
LUAJIT
0.0129  (3.17)
LUAU --codegen
0.0602  (14.83)
MONO
0.0085  (2.10)

float2string

.NET
0.2835  (4.22)
C++
0.3021  (4.49)
DAS AOT
DAS JIT
LUAJIT
0.1564  (2.33)
LUAU --codegen
0.0695  (1.03)
MONO
0.4566  (6.79)

mandelbrot

.NET
0.0020  (4.45)
C++
DAS AOT
0.0006  (1.40)
DAS JIT
0.0005  (1.02)
LUAJIT
0.0076  (16.92)
LUAU --codegen
0.0379  (84.48)
MONO
0.0040  (8.90)

n-bodies

.NET
0.0390  (1.89)
C++
0.0270  (1.31)
DAS AOT
0.0274  (1.33)
DAS JIT
LUAJIT
0.0820  (3.97)
LUAU --codegen
0.2302  (11.13)
MONO
0.0805  (3.89)

native loop

.NET
0.1615  (13.20)
DAS AOT
DAS JIT
LUAJIT

particles kinematics

.NET
0.0069  (2.32)
C++
0.0035  (1.17)
DAS AOT
DAS JIT
LUAJIT
0.1997  (67.00)
LUAU --codegen
0.2144  (71.96)
MONO
0.0915  (30.71)

primes loop

.NET
0.0380  (2.82)
C++
0.0386  (2.87)
DAS AOT
DAS JIT
LUAJIT
0.0137  (1.01)
LUAU --codegen
0.0350  (2.60)
MONO
0.0380  (2.82)

queen

.NET
0.0050  (43.86)
C++
0.0001  (1.03)
DAS AOT
0.0001  (1.25)
DAS JIT
LUAJIT
0.0004  (3.87)
LUAU --codegen
0.0009  (7.69)

sha256

.NET
0.0080  (1.64)
DAS AOT
0.0052  (1.06)
DAS JIT
LUAJIT
0.0339  (6.94)
LUAU --codegen
0.5664  (115.84)

sort

.NET
0.0130  (2.37)
C++
0.0057  (1.04)
DAS AOT
DAS JIT
0.0096  (1.74)
LUAJIT
0.0730  (13.28)
LUAU --codegen
0.0478  (8.69)
MONO
0.0100  (1.82)

spectral norm

.NET
C++
0.0123  (1.03)
DAS AOT
0.0123  (1.03)
DAS JIT
0.0124  (1.03)
LUAJIT
0.0147  (1.22)
LUAU --codegen
0.0574  (4.78)
MONO
0.0260  (2.17)

string2float

.NET
0.1065  (4.41)
C++
0.1015  (4.20)
DAS AOT
DAS JIT
LUAJIT
0.1173  (4.86)
LUAU --codegen
0.1158  (4.80)
MONO
0.1853  (7.68)

tree

.NET
0.2465  (1.41)
C++
DAS AOT
0.1777  (1.02)
DAS JIT
0.1776  (1.02)
LUAJIT
0.9647  (5.52)
LUAU --codegen
1.3965  (7.99)
MONO
0.2590  (1.48)

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)