Hacker News new | ask | show | jobs
by kpmah 3843 days ago
It lets you do some nice things.

You can always get instant feedback (types, errors) because your code is always a valid AST. No ambiguous braces etc.

Also things like markdown comments and inline evaluation.

My attempt: http://sediment.io

3 comments

That's a valid point, but if the compilation/IDE pipeline is arranged sensibly, you'll get those errors and insert a couple of ")" and get to the real meat of the issue a few seconds later...?

On the other hand... with an AST-only editor I now have to mentally tune in even more to the way the editor will behave while typing code and any deviation from the expected behavior becomes absolutely crippling[1]. For me, personally, this can become more overhead than it's worth to correct a few misplaced ")" or "]" or ";" or whatever when I've finished typing the gist of my idea. (I honestly don't know what would be faster overall, and I suspect it depends on hideously complex factors like "how much time do you intend to spend on learning IDE-X vs. learning to 'edit files', etc. I guess we could start with studies on "does it work?" as in medicine, even if we have no clue as to how it supposedly works.)

I'm saying that given the enormous success (all things considered, etc.) of text-based editing the claimants have the burden of proof.

(Actually, I'll happily admit that I was at one point on the hype-train regarding AST-editing, but I'm more skeptical these days. The thing is that it's easy to produce the 80% solution at to make it look awesome, but the problem is that getting those last 10% is a killer. Just look at Chris Granger's project for an example of just how difficult it is to get to 90%.)

[1] The machine is a machine and can do ASTs perfectly all day long, but if I'm a bit sleepy or drunk it suddenly becomes impossible to edit and type in code because I can't do a perfect job at prediction...? That would be strange indeed!

Awesome.

Naive question; is "defn" really necessary?, isn't "let" and "lambda" enough to express a program?.

One thing I've noticed is depending on how your code is being compiled/transpiled, having smaller defn's over them being nested in a let can lead to better performance since inlining becomes an easier problem.

This is particularly true in clojure, since it's being compiled to java byte-code, and the jvm has a few default settings for how deep it'll look into the call tree for inlining. See https://www.youtube.com/watch?v=0tUrbf6Uzu8 for a talk that mentions this.

You're right, it's not necessary, it's just a preference :)

Although it does 'flatten' the bindings. Defn a, Defn b… is the same as let a = … in let b = … in …

Is it possible to make structure editors work for whitespace sensitive languages like Haskell? Limiting AST editors to just lisp is a bit weird.
The reason AST editors look a lot like lisp is because lisp pretty much is just an AST. There's no technical reason the AST can't be a more complicated structure than a list, and you can present the AST any way you want - you don't have to show parenthesis. You can use mathematical symbols, whitespace, images, fonts...

The problem is the further away you go from lists of symbols, the more complicated the AST is to edit and to present to the user, and the more complicated the interface is for the user. It's not an insurmountable problem though.