sábado, 9 de novembro de 2019

Lisp macros and why Smalltalk doesn't need them

Lisp is homoiconic and this allows for its powerfull macros. But there's two other languages that don't need macros (talking about the 'Big Old Languages', and not the manifold spawns): Smalltalk and Forth.

Here's a very insightful take on why Smalltalk doesn't need macros, by Richard Kenneth Eng:

"...macros make Lisp powerful because they allow you to write programs that themselves write programs. But that’s what macros are, not what enables them–Lisp’s macros aren’t the cause of its power, they’re a symptom of it. What makes Lisp powerful isn’t its macros, it’s the fact that Lisp runs in the same context it’s written in. It’s s-expressions all the way down. This leads to an interesting possibility: could there be other ways to achieve similar power? Are macros the only possible way to make programs that write programs, or might there be others?

Smalltalk goes one further than Lisp: it’s not that Smalltalk’s source code has no syntax so much as Smalltalk has no source code. “Source code,” after all, just means “program that isn’t running,” and there is no such thing as a Smalltalk program that isn’t running! Because there is absolutely nothing in Smalltalk except “data that runs”–which is what an object is, after all–then there is no distinction in Smalltalk between data and programs. Data (objects) can write programs (objects) which write data (objects) which write programs (objects) which… "



The Red by Regayip  Koçak on 500px.com

Nenhum comentário:

Postar um comentário