News for hackers. Stuff that matters.
Re:I Still ‘Lisp’ (and You Should Too) by packetlost on Sunday February 19, 2023 @10:15PM (#34864559)
Lisp as a great tool for learning FP paradigms for application in other languages. IMO, in practice, the metaprogramming that Lisp encourages isn't very good good for the understandability of a codebase, which is IMO one of if not the most important factors for building an applications in a company.
Re:I Still ‘Lisp’ (and You Should Too) by kazinator on Monday February 20, 2023 @12:01AM (#34865079)
The objective test for whether Lisp metaprogramming contributes to or detracts from the readability of a codebase is to take a sample of the code base and expand the macros, to see whether that is more or less readable.
Re:I Still ‘Lisp’ (and You Should Too) by distcs on Monday February 20, 2023 @08:36AM (#34867913)
+1 These complaints about Lisp metaprogramming hurting code readability is a meme that never seems to die on HN. I doubt people who propagate this meme even use Lisp in the first place. Maybe they have only seen the type of macros you can find in C or Ruby or another non-homoiconic language and think what they have observed in those languages is true for Lisp as well.
Re:I Still ‘Lisp’ (and You Should Too) by todd8 on Monday February 20, 2023 @09:37AM (#34868463)
Macros provide abstractions that often make programs easier to understand. I myself have dozens of the usepackage macro in my Emacs configuration, they hide and standardize the boilerplate that I could use instead. Nevertheless, I have serious reservations about macros in programming.

Taking a code base and expanding the macros to see whether that is more or less readable is a bit like expanding a C++ class hierarchy into assembly language and concluding that this program’s object oriented design is great because it is more readable than the resulting assembly language.

The real question is whether or not there are better alternatives than macros or metaprogramming in the first place. Functions, especially as found in modern languages[1], have proven to be very useful abstraction mechanisms and can often mitigate the lack of fancy macros.

I don’t want macros banned from Lisp, but I don’t miss them in other programming languages. Over exuberant use of fancy macros in Knuth’s brilliant TeX, in my opinion, contributes to the glacial pace of LaTeX development.

[1] By this I mean functions with circumscribed access to non local variables, provisions for choices of ownership of parameters, static scoping, first class functions, closures, and recursion.

Re:I Still ‘Lisp’ (and You Should Too) by packetlost on Monday February 20, 2023 @10:36AM (#34869070)
Agreed. Metaprogramming does have it's place in languages like Lisp where it removes boilerplate or hides details that other programmers likely don't need/want to think about. However it's easy to go too far, which is really what I'm talking about. I think as long as you have first-class and variadic functions you can probably live without macros for like 98% of cases without compromising on readability (as is the case with Python). Alternatively, if you have an easy way to, at develop/compile time, identify exactly what a macro/metaprogram is doing I think it's ok, but that is subject to tooling.
Re:I Still ‘Lisp’ (and You Should Too) by kazinator on Monday February 20, 2023 @12:43PM (#34870544)
Python acquires new macros in its parser. For instance, it now has pattern-matching macros which weren't there before. A few years ago it got a f'...' reader macro which wasn't there before.
Re:I Still ‘Lisp’ (and You Should Too) by packetlost on Monday February 20, 2023 @02:17PM (#34871643)
Sure, but Python doesn't let users write their own macros
Re:I Still ‘Lisp’ (and You Should Too) by kazinator on Monday February 20, 2023 @02:24PM (#34871750)
So if you're on an older Python, you can't backport the new syntax; you're forced to upgrade if you have some code which depends on it. In Lisp, if some code we would like to use depends on some newer macros offered by the Lisp dialect we are using, but we cannot move to a newer installation yet, we may be able to backport just the macros into our program.

You're stuck with the ill-designed crap that Python puts out. For instance, I don't agree with pattern matching that assigns to existing variables; from where I'm sitting, it looks like an incompetent clusterfuck. If someone did that in one Lisp program, the entire language would be blamed for allowing that sort of "curse".

Re:I Still ‘Lisp’ (and You Should Too) by kazinator on Monday February 20, 2023 @12:32PM (#34870424)
* * *