Suppose you were looking at lisps and got around to the part where you realize homiconicity makes it possible (and/or sensible) to have language facilities like syntax macros. What would such a facility look like in practice? What would it be used for and how? What could go wrong defining it or using it? That's the sort of thing that's covered in On Lisp and it makes it an interesting read for any sort of programmer, rather than just a lisp one. The book is short, without being incomprehensibly dense, you get easily get a feel for it from just browsing the PDF for a bit. And the concepts being presented are a lot easier to digest than, say, 'what if your language was really good at category theory'.
There are of course still tons of examples in the book that are very useful for clojure as well.
The only criticism I have is that PG does not write code in "Common Lisp style". It's often more of Scheme with Common Lisp.
I think this is due to the fact that I learned to program in C. Nowadays I work mainly with python/ruby/javascript, but I got the feeling that I could improve myself as a programmer by learning Lisp.
Exercises includes sorting, search in binary trees etc etc
http://mitpress.mit.edu/sicp/ is almost the same but with more math/physic background (uses numerical oriented exercises very early). You'll have to write recursive subset, n-queens, matrix-composition functions.
Apart from Racket, Clojure is also a nice Lisp to get started with. It runs on the JVM.
I'd advice against learning Common Lisp as your first Lisp these days, even though Common Lisp is what On Lisp is about.
Similar, if someone asked about a modern scripting language, I'd send them away from Perl in favour of Python or Ruby.
If they goal was explicitly Perl (or Common Lisp) that would be a different thing, though.
(In case you ask: Common Lisp is a useful target, if you want to port programs from even older Lisps, like emacs' elisp.)
That being said, what is idiomatic in CL is not necessarily idiomatic clojure. For example, pg tends to like anaphoric macros, (http://en.wikipedia.org/wiki/Anaphoric_macro), while Clojure tends to eschew them.
The reasons one might do so in Clojure are likely to bear similarity to those provided by Graham - speed and memory - despite the vastly greater resources of today's computers versus those of 1991.
I think there are people on the internet who have implmented most of the example in clojure.
It's a pretty enjoyable book if you don't mind its preachiness. :-)
http://www.amazon.com/ANSI-Common-LISP-Paul-Graham/dp/013370...
Also make sure you check the errata for On Lisp, there are a few examples that you will really need the errata for.
Or if you are now to programming in general:
Then I looked at the date. It seems as though all 'classical' sources on lisp or functional paradigm are either two decades old, or just-out-yesteryear. What happened in between?
In practice, everyone just uses emacs to indent, no problem.
http://bl.ocks.org/mbostock/4063582
I'm not really a lisp coder at all (a bit of clojure experience), but the relentless self-similarity of lisp languages is both a strength and a weakness, IMHO. But it's regular syntax would make it a good candidate for a treemap. Just sayin'.
4clojure.com is a good resource to see how experienced clojure programmers can turn what would 50 lines of imperative code into a handful of keywords. The self-similarity is a non-issue. Saying it is a negative is like saying Mozart used "too many notes" in his music.
In other words, you don't have a clue. Right, thanks for clearing that up.
Because Lisp communities tend to eschew an imperative programming style, sequential operations tend to be composed of nested functions (and therefore indented) in lieu of passing values by mutable variables to blocks of sequential instructions.
Though arguments about programming styles are always going to remain unconvincing because the benefits of one over the other or vice versa are revealed when programmers are actually writing programs, it is objectively the case, that Lisp's indentation idiom can be used to express the sequence of execution for programs written using a functional style in a consistent way.
The lets might look like so (warning- silly example):
(defn n-squared-over-two-plus-three-as-str [n]
(let [squared (* n n)
halved (/ squared 2.0)
added (+ halved 3)]
(str added)))
> (n-squared-over-two-plus-three-as-str 1)
"3.5"
Sure, I could've just done this as a deeply-nested structure: > ((fn [n] (str (+ 3 (#(/ % 2.0) (* n n))))) 1)
"3.5"
... but it's harder to read, debug, and reason about. You wouldn't do that in a non-functional language either! I suppose the tolerance for deep nesting is different for different programmers.[1] https://github.com/dpritchett/cloball/blob/62300d31666ab1261...
No, I think the first book to explain that was Godel, Escher, Bach.
how is arc progressing?
I think arc still has some good points related to code brevity that noone else has fully duplicated yet.
Mathematical programming - linear programming, finite domain constraint programming, constraint logic programming, logic programming, relational programming
Static functional programming - ml, haskell
A good modern introduction to programming is Concepts, Techniques, and Models of Computer Programming, by Peter Van Roy and Saif Haridi. It's far superior to the commonly mentioned lisp book Structure and Interpretation of Computer Programs.
Huh? I am not sure if you are trolling or if you copied and pasted that without further investigation, but comparing operation research algorithms (such as linear and finite domain constraint programming) with a programming language is at the very least... disingenuous.
> "Lisp is a dangerous language"
That's a very strong and weird statement, would you mind to explain? because to me is completely the opposite.
Operations research type algorithms can be thought of as forward chaining compared to prolog's backward chaining. Prolog implementations usually integrate them in because they are more efficient in many cases.
Lisp's dangerousness was why ML was invented by Robin Milner.
Jokes aside, the Van Roy book is something to add to my "to read" list. Try posting it again in a comment that doesn't get downvoted to hell, maybe others will notice it too.
> constraint logic programming, logic programming
The book you comment on actually implments a logic programming system.
Both common lisp and clojure have implmentations of high performance logic systems.
> Static functional programming
Both Clojure and Common Lisp have type systems that can do most things ml and haskell can do. Its arguable that some of this (in the CL) are even more powerful then what haskell has.
Im not sure on what the other types of programming are but the do not at sound like things that a library can not do. Can you give a example of something that you can not do in clojure or commen lisp that is possible without in these other languages that you have not actually provieded.
> Concepts, Techniques, and Models of Computer Programming
It is a very good book. However 99.99% of programming today are not done with these modern concepts. It are actually langauges like clojure that push some of the technics like constraint logic programming more into the mainstream. Check out core.logic.
I don't know about that, Haskell has quite a few very non-trivial extensions in it's type system that I have yet to see replicated outside of research languages. ( Rank-N Types, GADTs, Kind polymorphism, etc).
Except they let you do MORE, which is often bad. For example, in Haskell STM you have a static guarantee that you don't have mutation or IO inside of a transaction. How are you going to guarantee that with Clojure STM?
Most of the time the majority of code (written by good programmers) is in constraints or relations, so why encase that in a functional language with parenthesis everywhere (I've programmed a fair bit in lisp and don't mind parenthesis at all, but it get's annoying after you're used to the elegance of prolog syntax).
You want a language that is flexible to expand into new fields.
Also you have still not provided with these magical programming languages you are talking about. Is there any language you yourself would use?
As far as I know many concepts like contraind logical programming is not really ready for prime time, in most cases.