News for hackers. Stuff that matters.
Re:Defense of Lisp Macros by PaulHoule on Thursday July 25, 2024 @09:37AM (#41068538)
I'm going to argue that Lisp already won.

That is, other programming languages have adopted many of the features of Lisp that made Lisp special such as garbage collection (Rustifarians are learning the hard way that garbage collection is the most important feature for building programs out of reusable modules), facile data structures (like the scalar, list, dict trinity), higher order functions, dynamic typing, REPL, etc.

People struggled to specify programming languages up until 1990 or so, some standards were successful such as FORTRAN but COBOL was a hot mess that people filed lawsuits over it, PL/I a failure, etc. C was a clear example of "worse is better" with some kind of topological defect in the design such that there's a circularity in the K&R book that makes it confusing if you read it all the way through. Ada was a heroic attempt to write a great language spec but people didn't want it.

I see the Common Lisp spec as the first modern language spec written by adults which inspired the Java spec and the Python spec and pretty much all languages developed afterwards. Pedants will consistently deny that the spec is influenced by the implementation but that's absolutely silly: modern specifications are successful because somebody thinks through questions like "How do we make a Lisp that's going to perform well on the upcoming generation of 32 bit processors?"

In 1980 you had a choice of Lisp, BASIC, PASCAL, FORTRAN, FORTH, etc. C wound up taking PL/I's place. The gap between (say) Python and Lisp is much smaller than the gap between C and Lisp. I wouldn't feel that I could do the macro-heavy stuff in

https://www.amazon.com/Lisp-Advanced-Techniques-Common/dp/01...

in Python but I could write most of the examples in

https://www.amazon.com/Paradigms-Artificial-Intelligence-Pro...

pretty easily.

Re:Defense of Lisp Macros by munch117 on Thursday July 25, 2024 @11:01AM (#41069498)
Lisp is the original dynamic language; for decades more or less the only one. Dynamic languages have been incredibly successful.

The code-as-data, self-similar aspect of Lisp, which is at the core of Lisp's macro features, hasn't reached the same popularity.

I would say that Lisp has both won and lost.

Re:Defense of Lisp Macros by PaulHoule on Thursday July 25, 2024 @11:35AM (#41069897)
As much as it sucked, BASIC had an important place as a dynamic language as early as 1963 at Dartmouth. GOTO wasn't all that different from a JMP in assembly.

BASIC was mature as a teaching language that you could run on a microcomputer by the early-1970s (see https://en.wikipedia.org/wiki/RSTS/E) and it came to dominate the market because there were implementations like Tiny BASIC and Microsoft BASIC that would run in machines with 4K of RAM.

There was endless handwringing at the time that we were exposing beginners to a language that would teach them terrible habits but the alternatives weren't great: it was a struggle to fit a PASCAL (or FORTRAN or COBOL or ...) compiler into a 64k address space (often using virtual machine techniques like UCSD Pascal which led to terrible performance) FORTH was a reasonable alternative but never got appeal beyond enthusiasts.

There was a lot of hope among pedagogues that we'd switch to LOGO which was more LISP-like in many ways and you could buy LOGO interpreters for everything from the TI-99/4A and TRS-80 Color Computer to the Apple ][. There was also µLISP which was available on some architectures but again wasn't that popular. For serious coding, assembly language was popular.

In the larger computer space there were a lot of languages like APL and SNOBOL early on that were dynamic too.

Re:Defense of Lisp Macros by mst on Thursday July 25, 2024 @06:32PM (#41074120)
I cut my teeth on BBC BASIC with the occasional inline arm2 assembly block on an Acorn Archimedes A310.

It had its limitations, but it damn well worked and you could have total control of the machine if you needed it.

(also the Acorn Archimedes manual was about 40% "how to use the gui" and 60% a complete introduction and reference for BBC BASIC, which definitely helped; I had to buy a book to get an explanation of the ASM side of things but, I mean, fair enough)

Then again the second time I fell in love with a programming language was perl5 so I am perhaps an outlier here.

Re:Defense of Lisp Macros by whartung on Thursday July 25, 2024 @12:19PM (#41070439)
Similarly, Lisp has lost.

It's clear to me that S-expr are not popular.

Other languages and environments have captured much of what Lisp has offered forever, but not S-expr, and, less so, not macros.

Any argument one has against Lisp is answered by modern implementations. But, specifically, by Clojure. Modern, fast, "works with everything", "lots of libraries", the JVM "lifts all boats", including Clojure.

But despite all that, it's still S-expr based, and its still a niche "geek" language. A popular one, for its space, but niche. It's not mainstream.

Folks have been pivoting away from S-expr all the way back to Dylan.

I'm a Lisp guy, I like Lisp, and by Lisp I mean Common Lisp. But I like CLOS more than macros, specifically mulithmethod dispatch. I'd rather have CLOS in a language than macros.

I don't hate S-expr, but I think their value diminishes rather quickly if you don't have macros. Most languages have structured static data now, which is another plus of S-expr.

I don't use many macros in my Lisp code. Mostly convenience methods (like (with-<some-scope> scope <body>)), things like that). Real obvious boiler plate stuff. Everyone else would just wrap a lambda, but that's not so much the Common Lisp way.

In my Not Lisp work, I don't really miss macros.

Anyway, S-expr hinder adoption. It's had all the time in the world to "break through", and it hasn't. "Wisdom of the crowds" says nay.

Re:Defense of Lisp Macros by PaulHoule on Thursday July 25, 2024 @12:28PM (#41070535)
What did win is the scalar/list/dict trinity which I first saw clearly articulated in Perl but is core to dynamic langauges like Python and Javascript and in the stdlib and used heavily in almost every static language except for the one that puts the C in Cthulu.
Re:Defense of Lisp Macros by dudinax on Thursday July 25, 2024 @04:40PM (#41073139)
And a lot of lisps have clunky dicts.
Re:Defense of Lisp Macros by kazinator on Thursday July 25, 2024 @05:28PM (#41073612)
This is kind of backwards. Languages which imitate everything from the Lisp family except S-exprs and macros are, because of that, other languages. Those that have S-exprs and macros are identified as in the Lisp family.

The appearance of new languages like this has not stopped.

Re:Defense of Lisp Macros by cageface on Thursday July 25, 2024 @08:39PM (#41074931)
This is kind of a no true Scotsman argument. The point is that most of the key ideas of lisp have been enthusiastically adopted by many very popular languages but lisp itself remains a small niche.
Re:Defense of Lisp Macros by kazinator on Thursday July 25, 2024 @08:56PM (#41075002)
A language that enthusiastically adopts all key ideas is identified as a Lisp.

There aren't "many" popular languages; only a fairly small number. The vast majority of languages are destined for unpopularity, regardless of what they copy from where.

Re:Defense of Lisp Macros by lispm on Friday July 26, 2024 @02:21AM (#41076224)
You'll need to say what this "lisp" and the "lisp features" are.

When we go back to the original idea of LISP, we have the following things:

idea -> what follows from those

1) programming with Symbolic Expressions -> support the implementation/implementation of languages

2) "programming with Symbolic Expressions" applied to itself -> Lisp in itself, code as data, macros, self-hosting compiler, Lisp interpreter

3) linked lists and symbols as data structures for Symbolic Expressions

4) a programming system to build algorithms and programs based on the ideas of above -> symbols repository, late binding, recursive functions, symbols with properties, garbage collection, Lisp interpreter using s-expressions, Lisp compiler, reader, printer, read-eval-print-loop, a resident development environment, managed memory, saving/loading heap dumps, dynamic data structures,...

LISP means "List Processor" (not "List Processing"). Which indicates that this is at its core, not a library or an add on.

There aren't that many other languages which are based on these ideas.

We can define three levels of "feature adoption":

* enables a feature (the language provides mechanisms to provide a feature)

* supports a feature (the language actually includes those features, but use is optional)

* requires a feature (the language requires the use of that feature, its not optional for the developer)

If we use a programming system, which requires the four core ideas above (and many of the features that follow from those) and is based on them, it is still very (!) different to what most people use.

Example:

Smalltalk development was started more than a decade after LISP. It adopted a huge amount of features from Lisp: managed memory, resident development environment, garbage collection, late binding, interactive use, runtime evaluation, dumping&loading heaps, etc. etc. For a decade Xerox PARC developed a Smalltalk system and a Lisp system side-by side: Smalltalk 80 systems and Interlisp-D systems were the results.

Still: Smalltalk 80 did not use the first three core ideas from above and replaced them with another core idea: objects+classes communicating via message passing.

Thus mass feature adoption alone does not make Smalltalk fundamentally to be a LISP. Nor does feature adoption make a language popular.

So we can ask use, will those core ideas of Lisp make it very popular? Seems like it did not. Still many of the useful features which were following from it could be replicated/adopted/morphed into other languages.

The original article was probably taking a view that a language&programming system which enables domain specific embedded languages would be "better" than the diverse stack of tools and languages in the automotive domain. Lisp is such a tool for embedded languages (embedded into a hosting language, not in the sense of languages for embedded systems), but that does not make it the best for that domain, which has a lot more requirements than language embedding (like reliability, robustness, etc. ...). In Germany A-SPICE gives a lot of hints what a development process needs to do, to deliver reliable software for the automotive domain. I don't think Lisp would fit well into such a development process.

Re:Defense of Lisp Macros by Straw on Friday July 26, 2024 @12:40AM (#41075803)
You can implement CLOS with macros, but not the other way round!
Re:Defense of Lisp Macros by cylinder714 on Friday July 26, 2024 @01:30AM (#41076014)
As an aside, Ron Rivest and Donald Eastlake last updated "SPKI S-Expressions" just a couple of months ago: https://datatracker.ietf.org/doc/draft-rivest-sexp/
Re:Defense of Lisp Macros by bunderbunder on Friday July 26, 2024 @11:58AM (#41079677)
I think you're absolutely right about macros being the main thing that makes s-expressions valuable, but allow me to inject my own opinion to drive it all the way home:

It's not that the homoiconicity of S-expressions makes it easier to write macros. Plenty of infix expression languages have macros that let you manipulate ASTs. We're programmers; mapping from lexical syntax to an AST is not hard for us.

What makes s-expressions so great in macro-heavy code is that the simplicity and regularity of the syntax lets you create DSLs without having to fuss with defining your own syntax extensions or figuring out how to integrate it into the "parent" language in a way that isn't completely terrible.

Racket demonstrates this rather nicely. They've got a fantastic system for creating macros that let you define your own syntax. It really does work well. But I'd generally rather not use it if I don't have to, because if I do then the job instantly gets 10x bigger because now I have to write a parser plus all the extensions to make sure it won't break syntax highlighting, ensure parse errors are indicated nicely in the editor, etc. And also all that work will be tightly coupled to DrRacket; people who prefer a different editor will not get a good editing experience if they use my macro.

I can avoid all of that headache if I just let it be s-expressions from top to bottom.

Re:Defense of Lisp Macros by AnimalMuppet on Thursday July 25, 2024 @03:37PM (#41072514)
> C was a clear example of "worse is better" with some kind of topological defect in the design such that there's a circularity in the K&R book that makes it confusing if you read it all the way through.

Whaaaaat???

I read the K&R book (rev 1) all the way through. The only thing I found confusing (without a compiler to experiment wiht) was argc and argv. Other than that, I found it very clear.

What, specifically, are you referring to?

Re:Defense of Lisp Macros by jjtheblunt on Thursday July 25, 2024 @04:30PM (#41073037)
oh how i wish i had kept my rev1 K&R rather than donate it to my hometown library 20+ years ago.
Re:Defense of Lisp Macros by jjtheblunt on Thursday July 25, 2024 @04:29PM (#41073030)
I really like that argument.

I've often thought Sun and Solaris also won, since so much of Linux is open source reimaginings of what Solaris had in the mid-late 90s, essentially a few year head start on Linux (which i used in the early 90s and still do, but along with Solaris back then, and NeXTstep).

Re:Defense of Lisp Macros by mst on Thursday July 25, 2024 @06:42PM (#41074233)
20 years back I remember chatting to a sysadmin over beer and the conversation included "Linux mostly does either whatever Solaris does or whatever BSD does, you just have to check which it is before trying to write anything."

(this was not a complaint, we were both veterans of the "How Many UNICES?!?!?!" era)

Re:Defense of Lisp Macros by _dain_ on Thursday July 25, 2024 @05:11PM (#41073442)
>C was a clear example of "worse is better" with some kind of topological defect in the design such that there's a circularity in the K&R book that makes it confusing if you read it all the way through.

Aww you can't just leave us hanging like this. What's the paradox?

Re:Defense of Lisp Macros by mighmi on Thursday July 25, 2024 @09:33PM (#41075131)
> there's a circularity in the K&R book that makes it confusing if you read it all the way through

What do you mean?