This is my first programming language, in the style of high-level assembly. I think it is pleasant to have each line begin with some atomic instruction about what the computer is doing. 😄
Lang-Lang is implemented in JavaScript, which of course means all of the advantages of working inside of the browser.
Here are some notable features of the language thus far:
-
Hard
movsemantics even with primitive types.mov a bmeans the nameais no longer accessible on the global scope. -
No braces or indentation. A
loop, for example, closes out with apool. Anifwith afi. This makes the execution model very simple and fun. Aloopdoes not know a priori when it will find its matchingpool. -
Special
%nsyntax for referring to loop indices. -
Initial direct addressing layers deep. You can
cp true x.y.zwithout first needing to initializexas an object then initializeyonxas an object. -
The Map as the universal data structure. JavaScript flexibly interprets number keys into strings, and we do the same thing here. Assuming no CPU bottleneck for the app, it is nice to have one universal structure. We, indexing by 1, represent
[10, 20, 30]as{1: 10, 2: 20, 3: 30}. The JavaScript map is unordered, and there is currently no way in Lang-Lang to iterate over all the keys of some object. -
Address substitutions. You can
cp 1 snk./%1/.x. Since%1is between the/signs, it gets interpreted in scope. So this code copies1to thexfield of whatever snake item we are currently looping over. -
General assembly character. There is something that just feels good about each line beginning with its operation. Everyone knows what
b = ameans, but it's still intriguing tomov a b
Here are some notable features that are missing right now:
-
Scope other than the global scope. In particular, scoped functions to pass input and receive output.
-
Strings. Right now there are implicit strings as the keys of the JavaScript objects, but the only primitive types are JavaScript's
booleanandnumber. -
Type constraints that keep the high-level assembly flavor of the language. One idea that could be cool is to have a template system like
tt snk.*i*.x :: number, andtt snk.*i*.y :: number, where the*i*is a wildcard catch-all. With adevelopment_modeturned on, we can intercept any writes to thexandyfields of a snake segment and verify that they are both type number. -
Expressions. These are super convenient, but I might just not implement them. No expressions means that source lines are more isomorphic to actual computer actions, not using "under the hood" invisible instructions to manipulate the expression. No expressions gives a very crisp high-level assembly feel to the language.