4 ms·
This is one of the hills to climb when learning a lisp. Seasoned lispers don't edit text, or traverse text; they edit and traverse lisp forms (AST nodes). In my
by Jeaye 3y ago
This is one of the hills to climb when learning a lisp. Seasoned lispers don't edit text, or traverse text; they edit and traverse lisp forms (AST nodes). In my experience, vim/neovim work very well for this, due to their notion of "text objects". With a couple of plugins, text objects end up aligned directly with the lisp AST, but even better is that the AST is visual and tangible, since it's encoded in the text.
It makes sense to benefit from this sort of thinking in other languages, but this is just another reminder, to me, of the beauty of lisps.
A fun language idea would be to take the exact semantics of an existing language, like C++, and encode them within a lisp, losslessly. I suspect it would end up quite verbose. However, add in a macro system and then you can start building a DSL around the original language, keeping all the same underlying semantics.
- rakoo 3y agoIsn't that a bit what hy (https://hylang.org/ https://hylang.org/) tries to do ? AIUI it is a lisp interacting directly with the AST of Python, allowing seamless interop: Python modules can be used from hy and vice versa, everything is transparent.
- Jeaye 3y agoI'm not sure if it's doing exactly that, but it looks like it could be! Very neat. It'd be nice to see it for other langs, if Hy proves viability in the approach.
- kolme 3y agoOther commenter mentioned Hy, but what about Clojure? It is a lisp on top of Java, and all of its variants (Clojurescript -> Javascript, etc). Then there's Fennel (Lua) and others I can't remember right now.
- Jeaye 3y agoClojure sits on top of the JVM and allows for Java interop, but the language itself does not losslessly encode all of the semantics of Java. Same goes for ClojureScript and the other dialects. The difference here is that the lisp's AST would need to map 1:1 with its underlying language.
- m12k 3y agoI find this idea interesting, because it's my impression visual programming is generally considered less powerful than textual programming, but it sounds like the described setup where you visually edit an AST could be a sort of middle ground.
- ykonstant 3y agoI agree completely; this is why I think a lisp would be a much better scripting language for a text editor than vimscript or lua. Although I use vim at an advanced level, I have never written a plugin for this reason. Emacs offers a much better scripting environment with elisp.