TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Defense of Lisp macros: The automotive field as a case in point

227 pointsby molteanu10 months ago

18 comments

VyseofArcadia10 months ago
I was a bit baffled the first time I was introduced to Simulink Coder. I get the value proposition: simulate your model so that you have confidence it&#x27;s doing the right thing, and then essentially just run that model as code instead of implementing it yourself and possibly introducing mistakes. What I didn&#x27;t understand, as a software guy, not an engineering guy, was why on earth you&#x27;d want a <i>graphical</i> programming language to do that. Surely it would be easier to just write your model in a traditional text-based language. Hell, the same company even makes their own language (MATLAB) that would be perfect for the task.<p>I did a little digging, and it turns out I had it backwards. It&#x27;s not that Simulink invented a new graphical programming language to do this stuff. Control systems engineers have been studying and documenting systems using Simulink-style block diagrams since at least the 1960s. Simulink just took something that used to be a paper and chalkboard modeling tool and made it executable on a computer.
评论 #41068805 未加载
评论 #41068200 未加载
评论 #41075726 未加载
评论 #41068884 未加载
评论 #41075471 未加载
评论 #41071105 未加载
评论 #41072844 未加载
评论 #41072943 未加载
pfdietz10 months ago
Without Lisp-like macros, you need preprocessors or code generators. Something like Yacc&#x2F;Bison is easily done with suitable macros.<p>In Common Lisp, macros also enable a kind of Aspect Oriented Programming. That&#x27;s because one can dynamically modify macro expansion using the macroexpand hook. It&#x27;s a way to modify a code base without changing the source files, which has all sorts of uses.<p><a href="http:&#x2F;&#x2F;clhs.lisp.se&#x2F;Body&#x2F;v_mexp_h.htm#STmacroexpand-hookST" rel="nofollow">http:&#x2F;&#x2F;clhs.lisp.se&#x2F;Body&#x2F;v_mexp_h.htm#STmacroexpand-hookST</a><p>One can implement things natively in Common Lisp, like code coverage tools, that require separate tooling in other languages.
评论 #41079520 未加载
评论 #41072020 未加载
评论 #41071892 未加载
评论 #41073553 未加载
评论 #41072969 未加载
roenxi10 months ago
In my experience (Clojure) macro-heavy libraries tend to be powerful but brittle. A lisp programmer can do things in a library that non-lisp programmers can&#x27;t realistically attempt (Typed Clojure, for example). But the trade offs are very real though hard to put a finger on.<p>There are several Clojure libraries that are cool and completely reliant on macros to be implemented. Eventually, good Clojure programmers seem to stop using them because the trade-offs are worse error messages or uncomfortable edge-case behaviours. The base language is just so good that it doesn&#x27;t really matter, but I&#x27;ve had several experiences where the theoretically-great library had to be abandoned because of how it interacts with debugging tools and techniques.<p>It isn&#x27;t the macros fault, they just hint that a programmer is about to do something that, when it fails, fails in a way that is designed in to the system and can&#x27;t be easily worked around. Macros are basically for creating new syntax constructs - great but when the syntax has bugs, the programmer has a problem. And the community tooling probably won&#x27;t understand it.
评论 #41068990 未加载
评论 #41068810 未加载
评论 #41074028 未加载
评论 #41068411 未加载
评论 #41079327 未加载
jancsika10 months ago
&gt; A confirmation of Greenspun&#x27;s Tenth Rule, if you will.<p>I&#x27;ve always found this rule suspect.<p>If it were true you&#x27;d have had lispers loudly reimplementing well-known, slowly-and-buggy mid-size C programs in common lisp, at roughly the rateand loudness the Rust people reimplement old C programs in Rust.<p>Did that actually happen?<p>If not, this has to be the greatest expression of envy in all of programming language lore.
评论 #41076124 未加载
评论 #41083978 未加载
qohen10 months ago
BTW, for anyone interested in learning more about Lisp macros, Paul Graham&#x27;s book about advanced Lisp programming, <i>On Lisp</i>, covers the topic pretty extensively and it&#x27;s freely downloadable from his website:<p>Book description: <a href="https:&#x2F;&#x2F;paulgraham.com&#x2F;onlisp.html" rel="nofollow">https:&#x2F;&#x2F;paulgraham.com&#x2F;onlisp.html</a><p>Download page: <a href="https:&#x2F;&#x2F;paulgraham.com&#x2F;onlisptext.html" rel="nofollow">https:&#x2F;&#x2F;paulgraham.com&#x2F;onlisptext.html</a>
评论 #41076960 未加载
评论 #41075414 未加载
FrustratedMonky10 months ago
So how would we go about switching the entire software industry to use LISP more? I&#x27;ve been struggling with this idea for awhile. It seems that the best languages don&#x27;t get adopted.<p>The only consistent explanation I&#x27;ve seen that it is about &#x27;easy&#x27;. The other languages have tools to make them easy, easy IDE&#x27;s, the languages &#x27;solve&#x27; one &#x27;thing&#x27; and using them for that &#x27;one thing&#x27; is easier to than building your own in LISP.<p>You can do anything with LISP, sure, but there is a learning curve, lot of &#x27;ways of thinking&#x27; to adopt the brain to in order to solve problems.<p>Personally, I do wish we could somehow re-vamp the CS Education system to focus on LISP and other ML languages, and train more for the thinking process, not just how to connect up some Java Libraries.
评论 #41068538 未加载
评论 #41068028 未加载
评论 #41069017 未加载
评论 #41067914 未加载
评论 #41069311 未加载
评论 #41068124 未加载
评论 #41078726 未加载
codr710 months ago
On that subject, I once made a serious effort at explaining why Lisp macros are so useful:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;codr7&#x2F;whirlisp">https:&#x2F;&#x2F;github.com&#x2F;codr7&#x2F;whirlisp</a>
agumonkey10 months ago
Wow this starts strong:<p>&gt; Replacing Lisp&#x27;s beautiful parentheses with dozens of special tools and languages, none powerful enough to conquer the whole software landscape, leads to fragmentation and extra effort from everyone, vendors and developers alike. The automotive field is a case in point.<p>This has been a struggle of mine since day one. Coming from the java world with more formats, tools, IDEs everytime people create a problem was absurd. Lisp was all absorbing.. much reuse on all metalevels.. yet sometimes I believe a bit of &quot;organ&quot;ism is useful.
bunderbunder10 months ago
The book Beautiful Racket is the best defense of macros out there, on &quot;show, don&#x27;t tell&quot; grounds. Also, it&#x27;s just so well-written and describes such an interesting set of tools that I&#x27;d argue it&#x27;s worth a skim even if you don&#x27;t intend to learn the language.<p><a href="https:&#x2F;&#x2F;beautifulracket.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;beautifulracket.com&#x2F;</a>
continuational10 months ago
Macros allow you to bring highly tailored DSLs into your code base. You can practice language oriented programming.<p>It&#x27;s seductive, but there&#x27;s a steep cost. You bring in a bunch of new notation, which you have to learn and teach and remember. You have to consider all the interactions that happen when you mix notations. You have to implement all the tooling.<p>Usually what happens is you don&#x27;t quite remember what things mean after a while, and you have to study it again. You didn&#x27;t consider all the interactions, so it isn&#x27;t that well behaved. And you never got around to implement quality tooling - and there&#x27;s no obvious place to plug that tooling in, either. And then it turns out that the notation wasn&#x27;t quite right for implementing the changing requirements of the business.
RealityVoid10 months ago
IMO, someone should kill XCP and A2L. They are in effect, a semihosted debugger. I would rather have semihosted gdb and use .elf. The tooling around A2L is horrendous.
评论 #41076414 未加载
deterministic10 months ago
I am not a fan of Lisp. However I sure wish all command line tools would use the same Lisp dialect for scripting. Instead of each Linux tool inventing their own awful, badly documented, makes-you-want-to-vomit bad joke of a scripting language.
codr710 months ago
Macros are more abstract, one meta level up, hence errors are more difficult to relate to code and reason about. They are also more powerful, so errors can have dramatic consequences.<p>Any kind of code generation setup will have the same characteristics.<p>Sloppy macros clashing with local names can lead to pretty long debug sessions, but it&#x27;s the first thing you learn to avoid.<p>And you&#x27;re basically inventing your own ad hoc programming language to some extent, the effort spent on error handling tend to not live up to those requirements.<p>All of that being said, I wouldn&#x27;t trade them for anything, and I haven&#x27;t seen any convincing alternatives to Lisp for the full experience.
评论 #41076532 未加载
评论 #41073582 未加载
djaouen10 months ago
I am not reading 10,000+ words on why macros are good. I know macros are good because smart people tell me they are. There is also plentiful evidence of macros being useful to programmers. Who are you trying to convince here?
评论 #41076219 未加载
whalesalad10 months ago
For such a long and detailed post, not a single lisp expression or macro is visible in this post.
cryptonector10 months ago
&gt; Replacing Lisp&#x27;s beautiful parentheses with dozens of special tools and languages, none powerful enough to conquer the whole software landscape, leads to fragmentation and extra effort from everyone, vendors and developers alike. The automotive field is a case in point.<p>This completely ignores Haskell.
评论 #41077509 未加载
评论 #41079517 未加载
BaculumMeumEst10 months ago
Macros are one of the widely touted superpowers of lisp. And yet in Clojure, which is the most widely used dialect in modern use, it is idiomatic to avoid macros as much as possible. None of the claimed advantages really hold up under scrutiny.
评论 #41074440 未加载
评论 #41072947 未加载
评论 #41072540 未加载
评论 #41072653 未加载
pfdietz10 months ago
&gt; &quot;I don&#x27;t think this is truly realized, but all this information written down in word sheets, requirements, knowledge passed on in meetings, little tricks and short hacks solved in video calls, information passed in emails and instant messaging is information that is part of the project, that is put down in some kind of a language, a non-formal one like English or tables or boxes or scribbles or laughs and jokes. The more a project has of these, the harder it is to talk about and verify the actual state of the project as it is obviously impossible to evaluate a non-formal language like you would a formal programming language and thus it becomes that much harder to explore and play with, test and explore the project.&quot;<p>I&#x27;ve thought all this sloppy side information would be a good target for the currently in vogue AI techniques.
评论 #41067942 未加载