5 ms·
I’ve had a change of heart over the years regarding macros. Prefix syntax, as in Common Lisp, makes it really easy to write macros without understanding how pro
by rayiner 2y ago
I’ve had a change of heart over the years regarding macros. Prefix syntax, as in Common Lisp, makes it really easy to write macros without understanding how programming language syntax and grammars really work. As more of a “computer” person than a “computer science” person, that was super appealing.
But that’s probably optimizing for the wrong case. Macros are used much more often than they are written, and the person writing the macro should probably understand syntax and grammar. Moreover, as soon as you add guardrails like hygiene (like Scheme does), the inherent conceptual simplicity of Common Lisp style macros is greatly reduced.
Too bad Dylan never took off. I think it would have been a better language than Java for enterprise software. Ironically, it was a create of the time insofar as it focused on something (trying to match C for performance) that ultimately didn’t end up mattering so much. We now write everything in one of the worst and least optimizable languages this side of TCL, and that doesn’t hold back deployment.
- pjmlp 2y agoActually it was my experience with Tcl back at our 2000's startup, continuously porting modules from Tcl down into C, that formed my opinion that languages without either JIT or AOT on their reference implementation, as mostly suitable for scripting and teaching purposes.
- rayiner 2y agoHaha—sorry, I didn’t mean to shit on TCL. It’s got no pretension of pretending to be something it’s not.
- lproven 2y agoEr. You don't specify what the opinion you formed is. Should that have been: "... languages without either JIT or AOT on their reference implementation, are mostly [only?] suitable for scripting and teaching purposes." ... ?
- DonHopkins 2y agoNot necessarily in the reference implementation, but quite early: Adam Sah, UCB: An Efficient Implementation of the Tcl Language (1994, UCB Masters Degree Thesis for Professor John Ousterhout): https://www2.eecs.berkeley.edu/Pubs/TechRpts/1994/CSD-94-812.pdf https://www2.eecs.berkeley.edu/Pubs/TechRpts/1994/CSD-94-812... After Ousterhout and his team went to Sun, but before the Java Juggernaut made its debut, Sun was positioning TCL to be the "Official Scripting Language of the World Wide Web". Brian T. Lewis, Sun Microsystems Labs: An On-the-fly Bytecode Compiler for Tcl (1996, Usenix TCL/Tk Workshop): https://www.usenix.org/legacy/publications/library/proceedings/tcl96/full_papers/lewis/lewis.html https://www.usenix.org/legacy/publications/library/proceedin... I wonder what would have happened if John Oosterhout's TCL team had applied Dave Ungar's Self team's JIT tech to TCL, before the Self team left Sun and made HotSpot (who Sun then hired back to apply to Java). Anyone know if / how those two teams at Sun overlapped / interacted at Sun Labs? Then "The TCL War" happened, which didn't help TCL's world domination plans either: https://vanderburg.org/old_pages/Tcl/war/ https://vanderburg.org/old_pages/Tcl/war/ https://news.ycombinator.com/item?id=12025218 https://news.ycombinator.com/item?id=12025218 Slightly Skeptical View on John K. Ousterhout and Tcl: https://softpanorama.org/People/Ousterhout/index.shtml https://softpanorama.org/People/Ousterhout/index.shtml >There was some concerns about TK future. See for example the following message from [Python-Dev] >FYI ajuba solutions (formerly scriptics) acquired by interwoven On Tue, Oct 24, 2000 at 07:07:12PM +0200, Fredrik Lundh wrote: >I'm waiting for the Tcl/Tk developers to grow up -- they still >fear that any attempt to make it easier to use Tk from other >languages would be to "give up the crown jewels" :-( >In the long run this has probably harmed Tk seriously. If Tk was just a widget set divorced from Tcl, then it might have been chosen as the underlying widget set for GNOME or KDE, and then have benefited from the development work done for those projects, such as the GNOME canvas enhancements, which now can't be absorbed back into Tk without a lot of effort to merge the two sets of code. The genius of TCL/Tk: https://news.ycombinator.com/item?id=22709478 https://news.ycombinator.com/item?id=22709478 DonHopkins on March 28, 2020 | parent | context | favorite | on: Is there any code in Firefox (as of 2020) that com... The genius of TCL/Tk, and the reason I believe Tk was so incredibly successful despite the flaws and shortcomings of TCL, is that toolkits like Motif, based on the X Toolkit Intrinsics, that aren't written AROUND an existing extension language, end up getting fucked by Greenspun's Tenth Rule: https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule >"Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp." -Philip Greenspun's Tenth Rule The X Toolkit ends up needing to do all of these dynamic-scripting-language-like things, like resolving names and paths, binding events to handlers, calculating expressions, and instantiating objects based on resource data. So if it doesn't already start out with a standardized scripting language to use for that, it has to duplicate all that dynamic almost-but-not-quite-entirely-unlike-half-of-Common-Lisp stuff itself. Case in point: Motif's infamous UIL (because X resource files weren't half-assed enough). https://www.donhopkins.com/home/catalog/unix-haters/hpox/uil-sux.html https://www.donhopkins.com/home/catalog/unix-haters/hpox/uil... And then when you do get around to plugging that toolkit into some other scripting language (the way WINTERP plugged Motif/Xt into XLisp, or GTK/GObject plugs into Python for that matter), now you have two or more fat bloated complex buggy poorly documented incompatible impedance-mismatched half-assed competing layers of middleware and object models tripping over each other's feet and spraying each other with seltzer bottles like the Three Stooges. https://www.youtube.com/watch?v=VO9RP4QEZKU https://www.youtube.com/watch?v=VO9RP4QEZKU https://news.ycombinator.com/item?id=22610342 https://news.ycombinator.com/item?id=22610342 >Speaking of the plague, does it support UIL? ;) >Neils Mayer described WINTERP (XLisp + Motif) as: You might think of such functionality as "client-side NeWS without the postscript imaging model". http://nielsmayer.com/winterp/ http://nielsmayer.com/winterp/ >Don Hopkins wrote to a comp.human-factors discussion about "Info on UIL (User Interface Language)" on January 22, 1993: https://groups.google.com/d/msg/comp.human-factors/R3wfh90HMss/WR1-qmjnNJIJ https://groups.google.com/d/msg/comp.human-factors/R3wfh90HM... >Here are some classic messages about UIL. Avoid it like the plague. [...]
- Zambyte 2y agoIt is interesting to me that prefix notation gets brought up so much in the context of Lisp. Most operations in most languages use prefix notation (function calls, procedure calls, method calls, and most macro systems). The only thing that makes Lisp unique in this context is that it also makes arithmetic operations prefix. This is just the natural side effect of treating "primitive operators" as first class functions. It's something that other languages that treat these operators as non-primitive constructs awkwardly work around, like some syntax magic in Haskell or operator overloading in other languages. What makes Lisp macros so intuitive is not the prefix notation, it's the homoiconicity of the language. Writing a macro is just a list operation, where the familiar map / filter / reduce applies.
- gorjusborg 2y agoI love prefix-notation for arithmetic, not just because it prevents the need for disambiguating precedence. Subjective, I know, but I think (+ 1 2 3 4) is way nicer than (1 + 2 + 3 + 4).
- Zambyte 2y agoWhen dealing with pure functions, there is also no ambiguity for f(g(1), h(i(2), 3), j(4)). In both cases, prefix notation removes ambiguity.
- johnnyjeans 2y agoFor me, it's concatenative languages. Grammar so simple that BNF is of dubious usage. 4 3 2 1 + + +
- whartung 2y agoMy problem with prefix, is simply that my mind does not think in prefix. If I have to write 1 + 2 * 5 - 3, I'm not going to "start" with *. I will type: (+ 1 2<-<-(* ^E 5) <-<-<-<-<-<-<-(- ^E 3)) It indicative of how I'm thinking about it (regardless of how the navigation is done). I just have a lot of those starts and stops when converting infix to prefix in my tiny Piglet brain. That said, as a general rule, yea, I like (+ 1 2 3 4) and its ilk. It takes a bit of exploration to read. For example, I need to transit the entire list of 1 2 3 4 to understand all that is being added, which can be more difficult with longer expressions. But that can be mitigated with formatting: (+ (this that) (func zzz) (if (< v q) 1 3)) (Function conditions are also fun to intermix into things!) I think just as a rule, I find formatting more important in general with s-expr systems than algolesque systems.
- jjtheblunt 2y ago> We now write everything in one of the worst and least optimizable languages this side of TCL, and that doesn’t hold back deployment. Javascript? If so, why do you say it's a least optimizable language? Do you mean for ahead-of-time single point in time static compilation, rather than code evolving within a JIT afforded real runtime statistics? I don't have numbers but as an old optimizing compiler person I'm asking because it's plausible you know datasets i have not seen.
- benrutter 2y agoI assumed they were referring to Python which is after javascript arguably the most used language and also known to be one of the slowest. https://niklas-heer.github.io/speed-comparison/ https://niklas-heer.github.io/speed-comparison/ Honestly though, you could probably take your pick. Javascript is suprisingly fast for such a dynamic intepretted language, but PHP, Python and Ruby are all simultaneously some of the most used languages and the slowest.
- hayley-patton 2y agoImplementations interpret, languages don't; PyPy compiles and is about half the speed of V8. But one should put micro trust in a micro benchmark in general.
- jjtheblunt 2y agoYou just reminded me that ive not seen jython or ironpython for years…now curious how they fare!
- aidenn0 2y agoIt's not the prefix-system per-se, but it is the fact that code and data are sufficiently similar that you don't have to context-switch when writing macros is very nice. Your argument seems to be that Macros ought to be harder to write in exchange for being easier to use? What non-lisp macros are easier to use than lisp macros, and how?
- jlarocco 2y agoI think his argument is actually that the extreme simplicity of defining a macro in CL hides the fact that writing correct macro code isn't very simple. Using gensyms to create bindings in macros is an example - it's not obvious, but often critical for getting macros to behave nicely. Things like accidently capturing variables, multiple evaluation, etc. make "real world" macros difficult to write. Not insurmountable, of course, but more difficult than just basic list processing. Ideally that has no impact on how easy it is to use a macro, except to the extent a bug would make the macro hard to use.
- koito17 2y ago> as soon as you add guardrails like hygiene (like Scheme does), the inherent conceptual simplicity of Common Lisp style macros is greatly reduced Clojure offers a nice middle-ground to this. In Clojure, symbols are namespaced, and syntax quote "fully qualifies" symbols. A "fully qualified" symbol is a symbol with its namespace explicitly written out. For instance, foo is unqualified whereas clj.user/foo is fully qualified. The language disallows binding fully qualified symbols. So the most common bugs arising in unhygienic macros are eliminated while maintaining the same level of "simplicity" as macros in Common Lisp. There are also other features to help ensure hygiene, such as syntax that automatically produces gensyms for you. e.g. instead of (let [foo-sym (gensym)] `(let [~foo-sym some-value] (do something with ~foo-sym)))) one can simply write `(let [foo# some-value] (do something with foo#))