breck7 / scrollsdk

The code for Particles and Parsers, which Scroll is built on.
https://sdk.scroll.pub
384 stars 17 forks source link

Motivations/use-cases #140

Closed sh4r1k7 closed 5 months ago

sh4r1k7 commented 2 years ago

Hello, I'm quite piqued by treelang but I'm a bit puzzled about it's motivation for existence given that you're familiar with Rebol - which is not only syntactically almost the same (having almost no syntax to speak of) but is also expressly geared toward defining many small languages and embedding them inside each other.

The 2D nature of treelang is really the only difference but I just can't see the big benefit of it.

I'm no fanboy of, or even expert at, Rebol, I'm genuinely just curious and would like to see what you see, so if you have any good examples you could share where you were glad to use treelang over Rebol I'd love to learn from your experience. If it wasn't for Rebol I wouldn't even be asking.

But as an exercise in minimalism it's very impressive! You also might get a kick out of noon that I found years ago which put even CSON to shame in terms of minimal and human-friendly.

breck7 commented 2 years ago

You also might get a kick out of noon

Don't think I've seen noon—thanks! It's clever to use a double space to delimit key/value in order to allow a single space in keys.

The 2D nature of treelang is really the only difference but I just can't see the big benefit of it.

Beneficial if you have a DSL that you want to edit as a spreadsheet (example: https://www.youtube.com/watch?v=0l2QWH-iV3k). I think there's a tiny chance those benefits might generalize.

about it's motivation for existence... as an exercise in minimalism it's very impressive!

It wouldn't be far off to say the motivation was a dogged pursuit of minimalism! I was very surprised that simply using words and the off-side rule you had all the syntax needed for any data structure. Might there be something deep and useful there? I was bullish on the possibility.

Rebol...also expressly geared toward defining many small languages

I should try building more dialects in Rebol. My impression is that you get everything & the kitchen sink(ie, 45 value types). With TN in comparison, you'd only include the node types you need in your language (so it might have INTs but no floats or strings, for example). You compose your grammars using as many or as few node and cell types as you need.

glad to use treelang over Rebol I'd love to learn from your experience

I thought TN's simplicity made it a great long term bet, but I'm probably 100x less bullish on TreeLangs nowadays. I was wrong about my bet that TN's simplicity might be needed to unlock program synthesis. Scaling deep learning (GPT-3 et al) can do program synthesis quite well using our existing languages. My secret plan was: "crack program synthesis with TN => get programmers to flock to it and build out the ecosystem".

I also had an unconscious bias that humans would always want to be able to understand everything, and so the pursuit of a universal syntax would always be in vogue, but now realize that I probably was making an anthropocentric mistake and the future may be dominated by AI's.

Sorry, that's a long way of saying that I was betting that the simplicity of TN + future network effects would make it a much more productive ecosystem than other languages (such as Rebol), but now I think I was wrong because of deep learning an its implications.

I still am iterating on various small things with TN, and enjoy it & have no regrets, but it's definitely still in an early state and my expectations for it to be greatly useful are not as high as they were.

sh4r1k7 commented 2 years ago

my expectations for it to be greatly useful are not as high as they were.

Damn that's a bummer!

I enjoyed reading your response though - truth be told I was sort of expecting to hear some of that but was hoping I wouldn't as I also have similar thoughts and visions which most likely will be squashed by the impending AI-pocalypse.

humans would always want to be able to understand everything

I'm one of those (hence the interest in treelang and Rebol etc) but we're definitely an endangered species.

With TN in comparison, you'd only include the node types you need in your language

I can definitely see the appeal in that, it's something I love and hate about Rebol. Reminds me of Tcl on the other end of the spectrum - which is elegant and simple to the point of being a pain!

Beneficial if you have a DSL that you want to edit as a spreadsheet

That's pretty cool, did users end up groking it and getting productive with it? Beating Excel at it's own game with a proper-ish language would be very interesting.

One thing I was curious about with the syntax is why you opted for someNode and someCell rather than the more structured node some and cell some approach?

breck7 commented 2 years ago

I wouldn't as I also have similar thoughts and visions which most likely will be squashed by the impending AI-pocalypse.

Any links to share? Always enjoy exploring new things.

That's pretty cool, did users end up groking it and getting productive with it?

Good question! Looking at publications that one is actively used, but need to follow up and inquire about productivity.

Beating Excel at it's own game with a proper-ish language would be very interesting.

The optimistic part of me thinks there may be an interesting thing here (a better spreadsheet language using a 2D grammar), but the realistic part of me thinks if there were someone would have done it by now. I wish I could see more moves ahead!

One thing I was curious about with the syntax is why you opted for someNode and someCell rather than the more structured node some and cell some approach?

The switch to this Hungarian notation for cell and node identifiers is actually one of my favorite changes to the Grammar language. It used to be node some and cell some as you mentioned. My vague recollection is I was making lots of dumb mistakes (putting cell ID's where I wanted node ID's; hitting naming conflicts when combining grammars; not being able to do "rename this" in a type safe way without lots of tooling; etc). I've found Hungarian style here made the code much more bulletproof and readable. Especially when I come back to some Grammar code a year later, it helps me get my bearings to know what types the IDs are referring to. When writing, I like the hand holding around the key glue parts of a grammar "every word in a 'cells' property should end in 'Cell', and every word in 'inScope' should end in 'Node'".

I love this question though, because now I'm thinking about why have I loved Hungarian notation there but don't use it everywhere? Scanning the list of advantages on the Wikipedia page I think maybe the rule of them that resonates with me is is when identifiers are defined far away from where they are used, Hungarian style might be advantageous.

Of course, is my ontology of nodes & cells the right abstraction? It's worked for me but maybe there's a better pattern out there.

sh4r1k7 commented 2 years ago

Any links to share? Always enjoy exploring new things.

Currently it all just lives in my head as half baked ideas - something like perl6 grammars + zig comptime + k.

but the realistic part of me thinks if there were someone would have done it by now.

Have you come across stratified-js? One of their main demos (site is down now) was a similar concept of running JS code in spreadsheet cells - the trick to making it actually awesome was their use of advanced async capabilities (custom JS compiler), much more awesome than the braindead promises in vanilla JS.

So yea, "someone would've done it" is a tricky heuristic :).

when identifiers are defined far away from where they are used, Hungarian style might be advantageous.

Yea that makes a lot of sense actually since without any syntax to guide you, treelang is just a bunch of identifiers - where some are more equal than others. And visually telling them apart saves an extra compile cycle (and the sting of errors).

is my ontology of nodes & cells the right abstraction?

I think it's the natural progression from no syntax, to structured prefix, to structured prefix with args (essentially the first incarnation of lists?) - I think without args/cells it'd be a 1.5D language with questionable use/useablity hehe.

I think going to the next level might be heading in the direction of Rebol (like [ ] cells/nodes forming true lists maybe?) - which is the thought that sparked this discussion :).

breck7 commented 2 years ago

something like perl6 grammars

Just took another look at these. Really cool!

I am pretty sure I had never seen stratifiedJS before. Seems like they blazed the trail for sane async programming in JS (was such a nightmare before awat/async).

breck7 commented 5 months ago

Going to close this.

Final Tree Notation report is here: https://breckyunits.com/treeNotation.html

I spent most of my thoughts on a totally new kind of language now, however, Tree Notation + Grammar (might rename that) will live on for a long time as they support Scroll (https://scroll.pub/) which I really like and will keep going.