Skip to content

Philosophy

justinmann edited this page Dec 24, 2017 · 5 revisions

SJ Tenets

  • Minimize Language Constructs
  • Minimize Heap Allocation
  • Enforce Data Thread Locality
  • Cross Platform

Minimize Language Constructs

SJ is very frugal with its syntax. With a single modified version of a function, SJ implements classes & functions.

syntax(
  isFun() { true }
) { this }

question : syntax()
question.isFun()

Minimize Heap Allocations

Stack allocations are an order of magnitude faster than heap allocation, but it can be really hard to figure out which to use in a given program. SJ analyzes the code to determine how to maximize stack allocations without breaking the logic. SJ uses several tricks to minimize the need to heap allocation, like allocating return values in the calling function.

Enforce Data Thread Locality

It is nearly impossible to design an object that can be safely used from multiple threads. Even if you manage to accomplish this, it will come at the cost of locks. In SJ, an object can only live in one thread. If it is sent to another thread then it is copied. The only way to communicate between threads is through messages similar to web workers or the actor pattern.

Cross Platform

SJ currently transpiles to C99 standard code. This code can be compiled to native code using MSVC, GCC, or CLANG. It can also be compiled to WebAssembly or asm.js using emscripten. SJ can be run on Windows, Linux, OS X, or in a browser using WebAssembly.

Clone this wiki locally