ru en

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
  1. calc = explicit (index) => {
  2.     step = 0;
  3.     while (index > 1)
  4.         if (index % 2 == 0) {
  5.             index = index / 2;
  6.             step = step + 1;
  7.         }
  8.         else {
  9.             index = (3 * index + 1) / 2;
  10.             step = step + 2;
  11.         }
  12.     return step;
  13. };
  14. using linq;
  15. 0..1_000_000 |> linq.max(calc);
The SLThree 0.6.0 code
  1. calc = (i64 index): i64 => {
  2.     i64 step = 0;
  3.     while (index > 1)
  4.         if (index % 2 == 0) {
  5.             index = index / 2;
  6.             step = step + 1;
  7.         }
  8.         else {
  9.             index = (3 * index + 1) / 2;
  10.             step = step + 2;
  11.         }
  12.     return step;
  13. };
  14. using jit;
  15. using dlinq;
  16. calc_opt = jit.opt(calc, self);
  17. <i64>0..1_000_000 |> dlinq.max<i64, i64>(calc_opt.CreateDelegate(@@System.Func<i64, i64>));
The SLThree 0.7.0 code

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

References