SLThree
SLThree (Script Language 3) — a multi-paradigm interpreted C-like programming language with strict dynamic typing, developed for the .NET platform. Mixes imperative and functional approaches, and OOP is implemented by a single composite type of the language itself — context.
Features
- Powerful interpreter
- The ability to use all types and their contents from .NET
- [Experimentally] compilation in IL (which is subsequently picked up by the JIT of .NET)
- Interpolated strings
- Generic methods
- Contextes
- Tuples
Why not DLR
Being a dynamic language on the .NET, SLThree does not use DLR, but its own architectural solution. Based on this article, DLR when working with COM types (for interlanguage interaction of the same IronPython and C#, the COM API is used) can cause memory leaks when transferring dynamics.
Perfomance compare
Performance measurements were performed using the Collatz conjecture in the range from 0 to 1000000.
Test machine | |
---|---|
CPU | Ryzen 7 4700U 8-Core CPU 4.2 GHz |
RAM | DDR4 Dual-Channel 16 GB 3200 CL22 |
OS | Windows 10 21H2 |
Results | |
---|---|
Dynamic typing | |
JavaScript | 10984 ms |
TypeScript | 10960 ms |
Python 3.12 | 8724 ms |
SLThree | 7824 ms |
Static typing | |
SLThree + JIT | 240 ms |
PascalABC.NET 3.9 | 226 ms |
C# | 212 ms |
С++ | 208 ms |
Rust | 185 ms |
- calc = explicit (index) => {
- step = 0;
- while (index > 1)
- if (index % 2 == 0) {
- index = index / 2;
- step = step + 1;
- }
- else {
- index = (3 * index + 1) / 2;
- step = step + 2;
- }
- return step;
- };
- using linq;
- 0..1_000_000 |> linq.max(calc);
- calc = (i64 index): i64 => {
- i64 step = 0;
- while (index > 1)
- if (index % 2 == 0) {
- index = index / 2;
- step = step + 1;
- }
- else {
- index = (3 * index + 1) / 2;
- step = step + 2;
- }
- return step;
- };
- using jit;
- using dlinq;
- calc_opt = jit.opt(calc, self);
- <i64>0..1_000_000 |> dlinq.max<i64, i64>(calc_opt.CreateDelegate(@@System.Func<i64, i64>));
Between SLThree versions
Since optimizations were introduced in most language updates, performance varied from version to version.
Results | |
---|---|
SLThree 0.1.0 Lovely 64 bits | 48000 ms |
SLThree 0.2.0 Unwrap the wrap | 14000 ms |
SLThree 0.3.0 Third time is lucky | 7900 ms |
SLThree 0.6.0 Functionalization Update | 7824 ms |
SLThree 0.7.0 Typing Update | 240 ms |