Learning Lisp just seems to promote better ways of tackling programming problems that is transferable to other languages where it's not as encouraged naturally even if superior.
Learning Lisp just seems to promote better ways of tackling programming problems that is transferable to other languages where it's not as encouraged naturally even if superior.
I hadn't written a line of lisp (although counted many brackets when trying to read along) but just studying it helped me think about programming problems a bit differently.
For example it is my opinion that this function is in no ways inferior to a recursive equivalent:
(defun range (end &key (start 0) (step 1))
(loop for i from start to end by step
collect i))But keep in mind that some things, although recursively defined, are better computed in other ways, the most obvious example is a Fibonacci sequence, which if I really needed, I would precompute and stick in an array for constant time access or something like that(maybe memoize a recursive function).
(defun search (tree val)
(cond
((null tree) nil)
((= (car tree) val) tree)
((< (car tree) val) (search (cadr tree) val))
((> (car tree) val) (search (cddr tree) val))
)
)
I write this sort of code all the time for more complicated structures; iterative solutions would involve keeping track of a bunch of local variables, which only makes the code more difficult to deal with.http://www.amazon.com/Little-Schemer-Daniel-P-Friedman/dp/02...
That's how I write Lisp too. It seems to me the nicest way to minimize overall complexity.
However, whether or not your example shows something that is not inferior is likely a matter of opinion, not fact.
-- Eric S. Raymond
There's a reason Java won't go away and that's that it runs everywhere releatively easily and interfaces with stuff acceptably well.
Python is now doing a good job of this too.
Lisp has a looong way to go on this front and I do speak from some limited experience.
It's very pleasant if all you're doing is staying inside lisp and interacting only with your own code but as soon as it's asked to play nice with others it gets a lot less fun.
And staying inwardly focused, never looking out and never talking to anyone else ultimately means get very little real productive work done.
:(
Clojure runs on the JVM and has great Java interop, so you get the fun of lisp, and the convenience of all the Java libs.
I still personally find JVM languages slow memory hogs during development but that's another issue :P
It's definitely a good offering