3 ms·
Isn't his point rather that Lisp goes beyond the normal definition of 'programming language'? "Lisp is almost an interpreter builder rather than just an interp
by stevecooperorg 15y ago
Isn't his point rather that Lisp goes beyond the normal definition of 'programming language'?
"Lisp is almost an interpreter builder rather than just an interpreter/compiler"
So most languages have a fixed grammar, and programs are always written in that grammar. Java functions, whatever problems they have, are at least always declared using a fixed grammar -- something like
function ::= returnType Identifier parameterList;
So even if you don't know what a function does, at least you (and tools) can easily see functions in the source code. The same applies to loops, classes, conditionals, etc. (Same for python, BASIC, whatever.) What Lisp does goes beyond that; I can define a new conditional language construct, or looping grammar, or object system...
"This means that one can make it be just about anything they want. Thus, its culture is almost a lack of culture."
The fear is that you'll end up having to join a project using "Dave's Object System" or "Nora's Conditionals Library". And that's where Lisp has the Aw(esome|ful) power to write in wildly divergent styles -- in fact, written in whole new grammars.
I suppose there's an idea that code can be written in a 'natural' way for the language. So you have this idea in python programming of something being 'pythonic' -- not just corresponding to the the python grammar, but also in a particular, respected programming idiom. So the question is, when you have the power to write your own grammar, can you then still write in a good, predicatable style that makes the code a good form of communication for other programmers? Is there a 'lispish' way to write code? (I suppose the same question applies to things like internal Ruby DSLs.)
Honest questions; although I've given Lisp a good shot, I've never written anything longer than a few hundred lines...
- raganwald 15y agoWell, it’s true that Lisp has meta-syntactic programming and Java doesn’t, however since Java doesn’t have homoiconicity, you end up with people building things where a lot of the meta-programming is baked into XML files. So, you could argue that a large, complex Java program can’t be understood just by reading it a line at a time, you have to figure out how it is all wired together via the XML files. I think what I’m trying to say is that large and complex systems are, well, large and complex whether in Lisp or java. But Lisp has standard libraries just like Java, e.g. CLOS. So it’s true Dave could write his own objects, and Nora her own conditionals, but I wonder whether that is more folklore than practical reality on commercial projects.
- pavelludiq 15y agoIs there a 'lispish' way to write code? Yes. If you read enough Clojure, Scheme and Common Lisp code you'll see that they have their own different styles. On a few occasions I read Common Lisp code written by schemers, it was somewhat ugly and inelegant, although the same code would have been elegant if written in scheme. Here's an example from an Erik Naggum article( http://www.xach.com/naggum/articles/3195982690560792@naggum.net.html http://www.xach.com/naggum/articles/3195982690560792@naggum.... ). First the Scheme in common lisp: (defun make-account (balance) (labels ((withdraw (amount) (if (>= balance amount) (progn (setf balance (- balance amount)) balance) (format t "Insufficient funds"))) (deposit (amount) (setf balance (+ balance amount)) balance) (dispatch (m) (cond ((equal m 'withdraw) withdraw) ((equal m 'deposit) deposit) (t (format t "Unknown request -- MAKE-ACCOUNT"))))) dispatch)) Perfectly reasonable way to do it in Scheme, not in Common Lisp. Heres how you do it in idiomatic Common Lisp: (defclass account () ((balance :initarg :deposit :initform 0 :accessor balance))) (defmethod withdraw ((account account) amount) (decf (balance account) amount)) (defmethod deposit ((account account) amount) (incf (balance account) amount)) (defmethod withdraw :before ((account account) amount) (unless (<= amount (balance account)) (error "~A has insufficient funds to withdraw ~A." account amount))) I'll let the code speak for itself :) Lisp allows you to turn code like the first example into code like the second. edit: formatting