don't make me ANGRY!
〈Lisp vs Perl Syntax, the Cult Problem〉
Lisp vs Perl Syntax, the Cult Problem
the syntax war of computer languages, is mostly fueled by hot air. there is rarely any voice at all, from a syntax expert. Note: a syntax expert is not someone who have designed a language, nor someone (you) who “O, i've programed in 10 languages”. A syntax expert is someone who have studied ...
one plus one
Shared publicly•View activity
View 8 previous comments
- I will come back on this once again, because, I think we don't disagree: I would rather say we don't understand each other. I even wonder if I do not miss something somewhere.
So I will rephrase why I see Lisp syntax an essential part of the language that you don't find in other programming languages.
Lisp is one of the few languages where you don't need to write a parser nor to write specific data structures to parse its own programs.
You can write the following:
(defun foo (x y)
(+ x y))
(foo 3 4)
;;; -> 7
;;; Replace the '+ by a '*
(nth 4 (function-lambda-expression (function foo)))
;;; -> *
(foo 3 4)
;;; -> 12
I claim you can't do this (and all that it implies: defining code at runtime) with the vast majority of programming languages. If you start with a language with a C-like syntax, it would require data structures to handle the various kind of constructs: expressions, loops, etc.. Here is an example of what MS did with Roslyn for VB and C#:
and you'll see that it is far from simple.
So yes the syntax of Lisp is uncommon (some would say awkward) but changing it will likely break this feature of Lisp. Not all programs (nor all programmers) do use it.Jun 25, 2013
- yes. What you wrote i read many times in past decade. Thanks for the comment. I understand that aspect well. Here's something that might be interesting
one can do what you described in Mathematica or XML.
Again, in M, it has syntax just like lisp, purely nested structure (but yet it's 100% regular). However, it has a transformation layer, transparent to user.
user can code in the pure nested form like lisp, or in traditional form. The transformation is purely mechanical, systematic, and automatic/transparent to user.
M is a lang similar or a family of lisp.
Now, the above is not about pattern matching. But M has pattern matching. This is where it is relevant to lisp macros. With pattern matching as in M, it's a term re-writing system, so as has mentioned, it's a order magnitude more powerful than lisp macros. (imagine, every line of lisp is a macro. That's basically what M is.)
in summery, there are 2 ideas here.
(1) a purely nested and regular syntax, such as lisp, xml, Mathematica, can do syntax transformation on the fly. This point you mentioned in your last post.
(2) a systematic pattern matching system, along with the idea of regular syntax above, beats any sort of macro system in Lisp. This is also demonstrated in XML and its various transformation technologies.
Now, the above 2 points isn't exactly the point of this thread, about lisp syntax and cult nature. The funny thing is (no disrespect to you), when it comes to syntax, lispers only see their advantages, just like perl will insist their advantages, and ignore any other info.
the point i pointed out in the article is that, lispers insists how their synatx is certain data is program, or macros, yet refuse, completely ignore, XML and the much superior Mathematica, based on similar principle. And, when one points out that lisp syntax is less regular than M or XML, they say it's not important.Jun 25, 2013
- Well, we should set up some kind of wiki page with examples of how things are done in different languages. I have only used M for doing a bit of maths, not programming. So I should probably investigate it. How would you construct a function on-the fly in M and then execute it?
XML is hardly a programming language : it has no set of instructions per se. Ok, it is completely reflexive : you can represent an XML tree in XML (luckily, and albeit it has deficiencies like the handling of entities and stuff).
Rewriting is only about processing, it has nothing to do with the fact that some code can modify itself.
The equivalent in Lisp of pattern matching found in functional languages is probably destructuring-bind.
And again, I don't see how Lisp syntax is less regular than ... well anything. For me it is only very elementary.Jun 25, 2013
- i wrote a essay here
that might be interesting.
it gives detail about M syntax, how it does transformation, in the context of lisp and xml.
lisp syntax not 100% regular, namely, not every expression is of the form (f …). Example:
(a . b)
`( , ,@ etc)
in my view, if it is 100% regular, lisp would have been much more powerful, perhaps also naturally developed the M-expression layer M has, and automatic code formatting.
i detailed them here, hope you find it interesting
http://xahlee.info/UnixResource_dir/writ/lisp_problems.htmlJun 25, 2013
- Thanks for the resources. I'll try to make myself more fluent with M syntax.
About Lisp macro-characters: they do not belong to Lisp syntax. This is precisely their purpose: convert some input into Lisp syntax. Lisp don't need them. [This is where there might be some misunderstanding between us]
'a is (quote a)
`(a ,b) is (list (quote a) b)
And the . for lists is definitely needed because of the definition of lists (that is car, cdr, cons). Every list (a b c) is actually (a b c . nil) .
The Lisp syntax is as basic as open and close parenthesis, spaces and the dot for lists.Jun 25, 2013
- Xah Lee+1i see. I haven't studied or used much of lisp reader. Thanks. I know about list and cons well though.Jun 25, 2013