Files
cell/cell.md
2025-06-11 16:35:46 -05:00

2.7 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.

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, const, and let, all work like let, but are called var

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

Make ? and all other characters usable for names

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.

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 }

rename instanceof to 'is'

remove undefined; all is 'null' now

remove with

Remove Object. New records have a prototype of nothing.


This will all actually come about gradually. Add a few things at a time, fix up code that did not adhere.