4 ms·
> A concrete example: Lisp macros. Who didn't see this coming? For someone who's constantly extolling the importance of other languages and flexible thinking,
by hota_mazi 5y ago
> A concrete example: Lisp macros.
Who didn't see this coming?
For someone who's constantly extolling the importance of other languages and flexible thinking, Paul doesn't seem to ever be able to get his mind out of Lisp.
> [Lisp macros] by their nature would be hard to implement properly in a language without turning it into a dialect of Lisp.
There are numerous counter examples to this claim, the most obvious one being Rust.
How do you call someone who only knows one language and refuses to learn new ones? Oh right, a blub programmer.
- deleted 5y ago[deleted]
- chrismorgan 5y agoI wouldn’t care to claim that Rust has Lisp macros. Lisp macros you define just like any Lisp function, and allow you to create new syntax constructs indistinguishable from any built-in constructs, which can execute whatever code they like as part of the process. In Lisp, macros are evaluated at run-time and can do anything, including access program state (if you play your cards right). They consume something that’s very roughly an AST, and emit something that’s very roughly an AST, and the language makes doing that quite easy, largely because it’s all structural in nature. In Rust, you’ve got macro_rules! which provides convenient syntax for simple structural macros, and then after that you have procedural macros which have the full power, but have to be written in a completely different place and get evaluated at compile-time only (so no dynamic macros), in a completely different context to the code that calls them (so no program state). They’re a lot harder to work with, consuming a stream of token trees (e.g. `if`, `3`, `.`, `{ … }`, `(…)`) and emitting a stream of token trees, a representation that’s clumsy and prone to error (especially since it’s not structural) though this can be mitigated a lot with crates like syn and quote which can make the process at least somewhat more structural, but it’s still way more clumsy than Lisp, where you can’t really distinguish between structural and procedural because they’re basically the same thing. Also Rust macros look different from built-in language constructs, all being like `foo!(…)`, `foo![…]` or `foo! { … }`. I can’t comment about any other languages; they may have things much closer to Lisp macros. (I write this as a Rust expert who writes structural macros regularly but procedural macros only once every year or two at least partly because of how painful they are to write, and a Lisp outsider who’s familiar with all the concepts and written a little here and there over the years but never anything serious.)
- pornel 5y agoI think there is similarity. Lisp can take its own AST, and modify it with its own fully-capable code. In this sense Rust's proc-macros can too. The difference is that Lisp has bare-bones syntax, so the AST manipulation doesn't get tedious. But Rust's proc macros using the quote crate look kinda Lisp-y. And just like LOOP in Common Lisp, you can totally make Rust macros that are a new language inside a language, and are too clever for their own good ;)
- wvenable 5y agoIt's pretty disappointed that there's an article called Weird Languages and all we get is Lisp again. I also think it's a bit arrogant to imply that if you don't like Lisp than you're just not smart. I'm sure many of us have been exposed to Lisp and still prefer to programming language that less powerful but more humane.
- MrManatee 5y agoIndeed. The author's appreciation of Lisp is well known. If he really is convinced by this abstract argument, it would have been nice to know what other weird languages besides Lisp it has inspired him to learn. APL, Prolog, Smalltalk, R, Haskell - perhaps? I don't mean to be too dismissive. I think this short piece was thought-provoking enough to be worth reading, and it was not a bad argument in favor of Lisp. Maybe I really should learn Lisp. But if the heuristic was generalized from just one example, it might overfit to just one particular kind of weirdness.