Files
cell/cell.md
2025-06-14 17:03:49 -05:00

4.3 KiB

JAVASCRIPT VISION

CELLSCRIPT

Javascript to its core. Objects. What does the language need? It can be quite small, I think. The key is, ANYTHING that we want to be fast and JIT'd, must be present. So, record lookups. These are actually quicker in a jit'd language that have them as a feature. Most things should be libraries. Blobs need to be in the runtime.

The purpose of this is to be a great language for passing messages. So it should be fast at creating records first and foremost, and finding items on them. So it needs first class, jitt'd records.

Finally, it needs to use less memory. Deleting a bunch of this stuff should make that simpler.

What is present? Objects, prototypes, numbers, arrays, strings, true, false, null.

Things to do:

merge typeof and instanceof. Misty has array? stone? number? etc; it needs to be generic. 5 is number returns true.

No new operator. It's the same idea though: simply instead of 'var guy = new sprite({x,y})' you would say 'var guy = sprite({x,y})', and sprite would simply be a function written to return a sprite object.

One number type. Dec64. Numeric stack can be added in later: a bigint library, for example, built inside cell.

Simplify the property attributes stuff. It is simple: objects have text keys and whatever values. Objects can also have objects as values. These work like symbols. You can share them, if desired. No well known symbols exist to eliminate that much misdirection. Obejcts basically work like private keys. If you serialize an object, objects that are keys are not serialized; only textual keys are. You can do something about it with a json() method that is invoked, if you desire. You cannot retrieve

var works like let; use var instead of let

no const

Function closures and _ => all work the same and close over the 'this' variable

Totally delete modules, coroutines, generators, proxy .. this deletes a lot of the big switch statement

Add the 'go' statement for tail calls

Add the 'do' statement

Implementation detail: separate out arrays and objects. They are not the same. Objects no longer need to track if they're fast arrays or not. They're not. Arrays are. Always.

Add the functional proxy idea. Log will be implemented through that.

Remove ===; it's just == now, and !=.

Remove 'continue'; now, break handles both. For a do statement, label it, and break to that label; so

var x = 0 do loop { x++ if (x < 5) break loop // goes back to loop break // exits loop }

rename instanceof to 'is'

remove undefined; all are 'null' now

remove 'delete'; to remove a field, assign it to null

remove with

Remove Object. New records have a prototype of nothing. There are no more 'type prototypes' at all.

Arrays are their own type

Remove property descriptors. Properties are always settable, unless the object as a whole is stone. Stone is an object property instead of a shape property.

Syntax stuff .. would like to invoke functions without (). This can effectively simulate a "getter". Make ? and all other characters usable for names. No reserve words, which are endlessly irritating.


This will all actually come about gradually. Add a few things at a time, fix up code that did not adhere. For a lot of this, no new functions will even need to be written; it's a matter of not calling certain functions that are no longer relevant, or calling different functions when required.

Benchmarks to implement

general speed

binarytrees coro-prime-sieve edigits fannkuch-redux fasta http-server json serialize/deserialize knucleotide lru mandelbrot merkletrees nbody nsieve pidigits regex-redux secp256k1 spectral-norm

function calling and recursion stress - test goto

naive recursive fibonacci [fib(35) or fib(40)] tak ackermann

numeric

sieve of eratosthenes [10^7 bits] spectral norm [5500 x 5500 matrix] n-body sim [50 000 - 100 000 steps] mandelbrot [1600x1200 image, max iter = 50]

memory & gc torture

binary trees [depth 18 (~500 000 nodes)] richards task scheduler fannkuch redux [n=11 or 12]

dynamic object & property access

deltablue constraint solver splay tree [256k nodes] json, wota, nota decode->encode [use 2MB example]

string / regex kernels

regex-DNA fasta word-frequency

concurrency/message passing

ping-pong [two actors exhange a small record N times, 1M messages end to end] chameneos [mating color swap game w/ randezvous]

For all, track memory and time.