News
- July 7th, 2024: Version 0.5 is comming very soon. It will include a lot of new features and improvements. Stay tuned! Expect JIT, serialization, performance improvements, new syntax features, and more.
- July 1st, 2024: daScript renamed to Daslang!
- May 1st, 2023: Version 0.4 of Daslang 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.
- 1st Jan 2023: Daslang now happily runs in the web browser. Check it out.
- 14 Dec 2022: 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: Daslang site has been released, check it out.
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:
- Extremely fast programming language that can rival compiled or JIT languages even in interpreter mode. It consistently outperforms dynamically interpreted scripting languages such as Lua. When used in AOT mode, Daslang is often faster than naively written C++ due to its SSE-friendly POD-types, and it even surpasses some of the best JIT VMs like V8 or LuaJIT. As a result, there's no need to rewrite your Daslang code in C++ to optimize your application.
- Safe and versatile programming language that provides all the benefits of static typing. Many errors that would break an application in runtime in languages like Lua or JavaScript won't even compile in Daslang. Additionally, due to its support for generics, type inference, and macros, Daslang is easy and fluid to use. Safety is a fundamental pillar of Daslang's design, making it safer in many cases than languages like C++ or Java.
- Real embedded programming language that requires no external dependencies other than a C++17 compiler. Its interop capabilities are both super easy to use and safe, as is expected from any embedded scripting language that's meant to call native code.
Daslang offers a wide range of features like:
- amazing performance
- strong static typing
- instant hot reload
- Ruby-like blocks
- semantic indenting
- lexical scoping
- high performance interpretation
- Ahead-of-Time compilation (optimization for release build)
- generators
- generics and type inference
- macros
- optional types (i.e. pointers)
- native HW friendly POD types
- C++ friendly and fast interop
- semi-manual memory management
-
fast and easy-to-reset execution context, allowing automatic burst
free memory management for stored procedures
no memory leaks with no GC/reference counting cost. - extendable type and function system
- cheap multi-threading support - explicit separation of execution context and code context.
- Open Source BSD licence
-
powerful embedding API
- e.g. functions can be defined by scripts or in C++
- e.g. objects can fully exist in the Context or be bound to native code
- and more
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 2024CLANG 17.0.6
Interpreted
Test | DAS INTERPRETER | LUA | LUAJIT -joff | LUAU | MONO --interpreter | QUICKJS | QUIRREL | SQUIRREL3 |
---|---|---|---|---|---|---|---|---|
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/A | N/A |
mandelbrot | 1.00 (0.0031) | 52.85 (0.1640) | 19.23 (0.0597) | 17.77 (0.0551) | 8.39 (0.0260) | N/A | N/A | N/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/A | 23.72 (0.8821) | N/A | 39.22 (1.4586) | N/A | 18.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/A | N/A | N/A | N/A |
sha256 | 1.00 (0.1233) | N/A | 2.05 (0.2524) | 5.88 (0.7252) | N/A | N/A | N/A | N/A |
sort | 1.00 (0.0320) | 2.85 (0.0910) | 2.19 (0.0700) | 1.63 (0.0520) | 8.70 (0.2782) | N/A | N/A | N/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/A | N/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/A | N/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/A | N/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 2024CLANG 17.0.6, AOT CLANG 17.0.6, JIT LLVM 16.0.6
AOT or JIT
Test | .NET | C++ | DAS AOT | DAS JIT | LUAJIT | LUAU --codegen | MONO |
---|---|---|---|---|---|---|---|
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/A | 1.01 (0.0122) | 1.01 (0.0122) | 1.00 (0.0122) | N/A | 10.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/A | 1.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
- Just-in-time and LLVM AoT backend
- AOT optimizations
- Tutorials
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)