News for hackers. Stuff that matters.
Re:Ask HN: Production Lisp in 2020? by alehander42 on Tuesday May 19, 2020 @08:30AM (#23234095)
these days many newer languages have macros: lisp is not alone
Re:Ask HN: Production Lisp in 2020? by Syzygies on Tuesday May 19, 2020 @11:40AM (#23236051)
We haven't figured out macros yet.

There's a perceptual litmus test here. Some people see life on earth and see God. Others see the faintest exploration of the design space, an impoverished code base that made it impossibly far. A miracle, perhaps, but not what we'd see in a billion runs of the simulation.

Same with Lisp macros. Their few variants look bolted on. We haven't begun to explore the design space, yet the best macro systems in other languages are copies of what lisp has figured out so far.

There's an 80:20 rule for language emergence. Ecosystem questions aside, a Turing-complete language needs to start by getting one thing right. APL leveraged multidimensional array handling into a general purpose language. Scripting languages gain much of their leverage from nested hash tables.

Concise versions of monadic parsing are exhilarating in their power and expressiveness. If a language was designed so parsing and manipulating itself was its sweet spot, generalizing this parsing to typed trees would be easy, and we'd invent many new programming paradigms. A general purpose language would follow.

Lisp, an implementation of the lambda calculus, is not this language. Lisp is a machine language precursor to this idea, with various macro systems bolted on.

Haskell, an implementation of typed category theory, is not this language either. At the expression level, Haskell is stuck at a few hard-wired pattern matching primitives. Haskell does not make the assumption that everyone has learned to compose arbitrary parsing operators.

Re:Ask HN: Production Lisp in 2020? by nikofeyn on Tuesday May 19, 2020 @11:34PM (#23243041)
> We haven't figured out macros yet.

the racket lang team has investigated this heavily.

https://www.youtube.com/watch?v=ABWLveMNdzg

https://www.cs.utah.edu/plt/publications/popl16-f.pdf

https://www.cs.utah.edu/plt/scope-sets/

> Haskell, an implementation of typed category theory

http://math.andrej.com/2016/08/06/hask-is-not-a-category/

Re:Ask HN: Production Lisp in 2020? by neutronicus on Tuesday May 19, 2020 @11:51AM (#23236211)
> yet the best macro systems in other languages are copies of what lisp has figured out so far.

These are going to be controversial assertions in a Lisp thread, but I believe

1. C++ Templates + Concepts is a good Macro facility

2. Most of what makes it good is not borrowed from Common Lisp

On the other hand, I agree strongly with this assertion:

> Scripting languages gain much of their leverage from nested hash tables.

Re:Ask HN: Production Lisp in 2020? by Jtsummers on Tuesday May 19, 2020 @03:49PM (#23239321)
I've been pondering this comment, and I'm not sure I agree that C++ Templates + Concepts are really equivalent to Lisp macros. They're about enabling generic programming with type constraints (when you add concepts, in particular). This seems more akin to Common Lisp's defgeneric and defmethod, where you can specialize your implementation based on the type. Like, assuming some class hierarchy of foo (base) -> bar -> baz:

  (defgeneric do-something (object))
  (defmethod do-something ((object foo))
     (something every foo can do))
  ;; bar is the same as foo
  (defmethod do-something ((object baz))
     (something only bazzes should do))
Templates and concepts are certainly a powerful tool, and I personally like them (as I've come back to C++ after a long break). But macros let you do something else entirely. You can create entirely new syntactic structures, or modify existing functions (see Norvig's PAIP, chapter 9, where macros are used to memoize recursive functions), or any number of other things.
Re:Ask HN: Production Lisp in 2020? by neutronicus on Tuesday May 19, 2020 @04:31PM (#23239808)
> I'm not sure I agree that C++ Templates + Concepts are really equivalent to Lisp macros.

I think I said as much in my comment.

> This seems more akin to Common Lisp's defgeneric and defmethod

Except that Templates are statically dispatched and type-checked.

But also one can perform meaningful compile-time computation with them - I have used this in anger to implement stencils and iteration logic for partial differential equation solvers in 1-3 dimensions so I can say from experience that it is not a mere curiosity. And I don't think that CLOS really has any analog for the techniques used to implement std::tuple.

> But macros let you do something else entirely. You can create entirely new syntactic structures, or modify existing functions (see Norvig's PAIP, chapter 9, where macros are used to memoize recursive functions), or any number of other things.

I think the thrust of my comment is that Lisp programmers identify this type-blind AST-mapping functionality as the core of "a Macro System," while users of other languages (with more syntax to begin with) see this as somewhat secondary to the goal of type-checked compile-time computation.

Re:Ask HN: Production Lisp in 2020? by oalae5niMiel7qu on Thursday May 21, 2020 @05:10AM (#23256336)
If C++ had a good macro system, the Qt library wouldn't need the "moc" preprocessor to implement its "slots" abstraction. Templates aren't powerful enough to fill that role, even when you add Concepts to them.
Re:Ask HN: Production Lisp in 2020? by neutronicus on Thursday May 21, 2020 @08:40AM (#23257673)
My understanding is that moc is no longer necessary, but sticks around for legacy compatibility, but I may be wrong.
Re:Ask HN: Production Lisp in 2020? by tolsen718 on Tuesday May 19, 2020 @09:31AM (#23234665)
I don't think another language's macros can match lisp macros unless the other language is also homoiconic.
Re:Ask HN: Production Lisp in 2020? by gnufx on Tuesday May 19, 2020 @04:51PM (#23240028)
Latter-day Dylan is infix with a Scheme-y macro system: https://opendylan.org/books/dpg/macros.html

Cue arguments, I guess, about whether Scheme is a Lisp, whatever their standards say.

Re:Ask HN: Production Lisp in 2020? by neutronicus on Tuesday May 19, 2020 @11:20AM (#23235804)
Clojure is weakly heteroiconic and seems to have rough parity
Re:Ask HN: Production Lisp in 2020? by fiddlerwoaroof on Tuesday May 19, 2020 @12:02PM (#23236351)
Clojure is “homoiconic”: Clojure source code is represented in terms of the data structures Clojure applications manipulate. There’s nothing preventing Common Lisp from having a similar surface syntax either: a couple read macros on [ and {, and a library of normal macros would be sufficient and could probably be written over a weekend.
Re:Ask HN: Production Lisp in 2020? by p_l on Thursday May 21, 2020 @03:59PM (#23264225)
In fact, since Common Lisp "source code" is NOT defined in terms of text but data structures (that happen to have standard serialization/deserialization) and that's the level that macros work on, you could theoretically even make semi-algolish syntax and still keep CL's macro system.

It would just look weird as fuck.

Re:Ask HN: Production Lisp in 2020? by fiddlerwoaroof on Thursday May 21, 2020 @10:13PM (#23268042)
Re:Ask HN: Production Lisp in 2020? by p_l on Sunday May 24, 2020 @05:55AM (#23290448)
That's one example, not as crazy as what's possible. Though I have to say I dislike the indent based blocks :/
Re:Ask HN: Production Lisp in 2020? by alehander42 on Wednesday May 20, 2020 @11:52AM (#23248331)
i am not sure: you can have "quoting" without this property
Re:Ask HN: Production Lisp in 2020? by dreamcompiler on Tuesday May 19, 2020 @08:36AM (#23234145)
C has macros. They are nothing like lisp macros. Please cite a non-lisp language with macros a powerful as lisp's.
Re:Ask HN: Production Lisp in 2020? by pmoriarty on Tuesday May 19, 2020 @11:31AM (#23235945)
The major advantage of Lisp macros over macros in other languages aren't their power but the fact that using Lisp's macro system is virtually the same as using the rest of Lisp.

Lisp macros look like Lisp and in manipulating code via macros you can leverage the rest of Lisp and Lisp's ecosystem.

So writing Lisp macros is entirely natural for someone who already knows Lisp. You don't have to learn or use what is effectively a separate language, as you do with every other language that's not homoiconic.

As Alan Perlis once said, "Beware the Turing tarpit, where everything is possible and nothing is easy."

Re:Ask HN: Production Lisp in 2020? by mumblemumble on Tuesday May 19, 2020 @09:24AM (#23234592)
C macros and lisp macros (In particular, I'm thinking of hygienic macros à la Scheme) are two wildly different extremes. In between them lies a huge continuum of interesting things. There are Scala's macros. There are Haskell's language extensions. There are code generators like the ones used to implement much of gRPC, and there are compiler plugins like the ones used to implement aspect-oriented programming in C# and Java.

Most of them arguably qualify as being somewhere between an 80% solution and a 90% solution for the practical problems that lisp might solve with macros.

They're frequently not anywhere near as convenient to use or understand. But that's arguably a good thing in the long run, because it encourages communities to pool resources and work on a coordinated solution that can be shared by the community. My take on the curse of lisp, for what it's worth, is economies of scale. Lisp makes it too easy (and fun) to just keep your head down and work on your own thing, which hinders pooling of resources.

Re:Ask HN: Production Lisp in 2020? by krebs_liebhaber on Tuesday May 19, 2020 @08:39AM (#23234176)
Re:Ask HN: Production Lisp in 2020? by loudlambda on Tuesday May 19, 2020 @09:35AM (#23234708)
Scala, Nim, Clojure, Haxe
Re:Ask HN: Production Lisp in 2020? by dreamcompiler on Tuesday May 19, 2020 @01:11PM (#23237315)
Clojure is a Lisp so it doesn't count.
Re:Ask HN: Production Lisp in 2020? by plinkplonk on Tuesday May 19, 2020 @09:06AM (#23234419)
Julia
Re:Ask HN: Production Lisp in 2020? by dreamcompiler on Tuesday May 19, 2020 @01:12PM (#23237331)
Julia is lisp in drag so it doesn't really count, but I'll give you the point.
Re:Ask HN: Production Lisp in 2020? by dTal on Wednesday May 20, 2020 @08:23AM (#23246037)
In what sense is Julia a lisp in drag? I'm just starting in on it it doesn't seem any more lispy than any other dynamic language. In particular I've yet to see a car/cdr.
Re:Ask HN: Production Lisp in 2020? by orbifold on Tuesday May 19, 2020 @10:05AM (#23234974)
Haskell, OCaml
Re:Ask HN: Production Lisp in 2020? by JeremyBanks on Tuesday May 19, 2020 @09:07AM (#23234433)
Rust?