onilabs / stratifiedjs

Oni StratifiedJS (previously Apollo)
http://onilabs.com/stratifiedjs
Other
231 stars 22 forks source link

sjs status? #20

Open danbri opened 1 year ago

danbri commented 1 year ago

Hello :)

Just checking in on SJS and noticed activity on the website but couldn't find any demo code for stratified JS itself, and some of the old web content appears to be gone - https://web.archive.org/web/20210224042355/http://onilabs.com/stratifiedjs

I was wondering if it now runs on top of native JS (await/async etc.) without needing a custom JS interpreter (ok I'm a decade out of date!), or has some compiled-to-wasm thing of its own.

Are there any simple modern examples, ideally something I can run in ObservableHQ.com?

afri commented 1 year ago

Greetings!

Indeed, SJS hasn't gone into hibernation; is still very much under active development and in active use in proprietary applications built on top of https://github.com/onilabs/conductance. However, regrettably there aren't any current simple examples, and it's uncertain if there will be any in the near future :/

The main issue is that SJS has a rather unique programming model that is different from conventional languages and doesn't align all that nicely with 'normal' JS. SJS by design being an extension of normal JS leads to some syntax compromises which makes the concepts underlying the language harder to explain than it should be. It also introduces various redundancies/discrepancies which are complex to reconcile (e.g. JS's iterable protocol and SJS's "stream" model).

In hindsight, it would have been a better strategy to adopt a unique syntax for SJS rather than extending JS. If I ever find the time, I might develop a cleaner language that incorporates everything we've learned from SJS, but there is no concrete timeline yet.

As for your specific question about how SJS runs, it isn't interpreted, but compiled on the fly to native JS, which then executes with the help of a small runtime library. async/await isn't used at all under the hood (SJS's controlflow features just don't align well with async/await), but SJS makes use of some other 'advanced' JS features like generators.