4 ms·
I wonder in which (if not all) ways this applies to Clojure.
by sgt 16y ago
I wonder in which (if not all) ways this applies to Clojure.
- ihodes 16y agoIt's interesting; lots of the complaints I got to are in fact addressed by Clojure. Syntax: code is still data, but there is additional syntax (like {} for maps, [] for vectors) that makes reading coding a bit easier; I don't particularly thing Lisps are hard to read anyway, but it is nice. Function names are less obscure; we have first and rest instead of car and cdr, for instance. I also hope we're a nice community to be around! I've certainly enjoyed my stay so far.
- KC8ZKF 16y agoFIRST and REST are from Common Lisp. http://www.lispworks.com/documentation/HyperSpec/Body/f_firstc.htm http://www.lispworks.com/documentation/HyperSpec/Body/f_firs... http://www.lispworks.com/documentation/HyperSpec/Body/f_rest.htm http://www.lispworks.com/documentation/HyperSpec/Body/f_rest...
- nickik 16y agoyes but in CL you have "rules" when to use first/rest and when to use car/cdr. A noob does not want to learn them.
- nickik 16y agocorrect would be to say clojure has first/next.
- sedachv 16y agoThere aren't any for loops! I GIVE UP
- nickik 16y agothere is for in clojure
- cgrand-net 16y agolike clojurebot says: "for is not a loop" doseq is.
- rbanffy 16y ago...then you'll see, that it is not the loop that loops. It's only your program
- beefman 16y agoClojure pretty much breaks all these old Lisp flame wars. Summing integers 1-10 is, incidentally, (sum (range 1 10)).
- stuhacking 16y agoThis is also possible in common lisp, however, there seems to be a lot more use of looping in CL than other dialects... Perhaps for performance reasons. Suppose, for example* , that `range' conses up a list of START to END numbers, then sums that list. That's a bunch of memory allocation then a reduction. It may be elegant, but looping over the numbers and accumulating the result would be faster and use less memory. I'm no expert, but it seems that a lot of production common lisp code will have gone through a few cycles of optimisation and arrived at a point of resembling imperative procedures. As a result common lisp teaches iteration (skipping over the need to rediscover the production tricks) while scheme teaches recursion. * That's not to say that this form couldn't be implemented in terms of looping.
- lukev 16y agoBut it's a vital point that 'range' doesn't allocate the whole list - it generates the head of a lazy seq. So the Clojure form CAN be compiled to be nearly as fast as the CL one. Why do optimization by hand when you can write something conceptually cleaner and let the compiler do it for you?
- sedachv 16y agoIf you look at CLtL appendices A and B, you'll see that Common Lisp was originally going to come with Rich Waters' SERIES (http://series.sourceforge.net/ http://series.sourceforge.net/), which is like lazy iterators/stream processing. At the time there were plans for doing all kinds of neat optimizations, including what's now known as map fusion in Haskell-land.