Skip to content
AntonYudintsev edited this page Jul 6, 2019 · 23 revisions
Clone this wiki locally

daScript is high-performance strong statically typed scripting language, with

  • no garbage collection,
  • "pure" stateless (it's state survives only one script run)
  • "native" machine types (no NaN-tagging or anything. int is int, float4 is native float4)
  • explicit (nested) structs.
  • cheap "inter-op" with native code

In a real world scenarios, it's interpretation is 10+ times faster than lua-jit without JIT (and can be even faster than luajit with JIT). It also allows Ahead-of-Time compilation, which is not only possible on all platforms (unlike JIT), but also always faster/not-slower (JIT is known to sometimes slow down scripts). It's already implemented AoT (c++ transpiler) produces more or less similar with c++11 performance.

Table with performance comparisons

It's philsophy is build around modified Zen of Python.

  • Performance counts.
  • But not at the cost of safety.
  • Unless is explicitly unsafe to be performant.
  • Readability counts.
  • Explicit is better than implicit.
  • Simple is better than complex.
  • Complex is better than complicated.
  • Flat is better than nested.

Typical Fibonacci sample:

 def fibR(n)
     if (n < 2)
         return n
         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

More complicated particles kinematics:

struct NObject
     position, velocity : float3

def updateParticles(var objects:array<NObject>)
    for obj in objects
        obj.position += obj.velocity

def initParticles(var objects:array<NObject>)
    resize(objects, 50000)
    for obj, i in objects, range(0,length(objects))

def test()
    var objects:array<NObject>
    print("created {length(objects)} particles")

It's (not)full list of features includes:

  • strong typing
  • Ruby-like blocks
  • tables
  • arrays
  • string-builder
  • native (c++ friendly) interop
  • generics
  • semantic indenting
  • ECS-friendly interop
  • etc, etc

options keyword
on vector constructors and how to initialize them