31 ms·
This occurred to me after I finished writing that post.
by tdfx 15y ago
This occurred to me after I finished writing that post.
- skylan_q 15y agoYea... I'm still confused as to the whole point of pure/near-pure functional programming if we're not getting better code density/more productivity against other languages which I (and some others) find easier to work with. I guess all I'm saying is "convince me!" :) I'm all ears.
- rayiner 15y agoI mean the answer is that the Python example is nearly purely functional to begin with. It uses list comprehensions heavily and I couldn't find any mutating assignments in a quick glance of the code. Which is not surprising, since it was written by Peter Norvig, who wrote a very popular Lisp book. I think what Clojure can offer on top of that is macros, the advantages of which are really only evident on bigger or harder problems.
- jkkramer 15y agoIn short: FP makes programs easier to reason about and understand by using trustworthy abstractions. Here are some resources to check out, which explain better than I could: Why Functional Programming Matters: http://www.cs.utexas.edu/~shmat/courses/cs345/whyfp.pdf http://www.cs.utexas.edu/~shmat/courses/cs345/whyfp.pdf Out of the Tar Pit: http://web.mac.com/ben_moseley/frp/paper-v1_01.pdf http://web.mac.com/ben_moseley/frp/paper-v1_01.pdf Simple Made Easy: http://www.infoq.com/presentations/Simple-Made-Easy http://www.infoq.com/presentations/Simple-Made-Easy
- icandoitbetter 15y agoYou actually get better code density with Clojure, for large enough programs. And a WAY better code density when you try to do multithreading.
- omlette 15y agowhat converted me was having to do highly stateful, real time statistical models. you have data coming in from multiple sources and you have to do lots of computation on them. if you don't have persistent data structures then it becomes so easy for the program to use data from the future or excised noise and your results will just be completely wrong and it's very hard to find the source of error. if youve never done FP, then it does feel really weird. but once you are used to it, so many things become much easier.
- spacemanaki 15y agoThe big differences between Clojure and Python are probably twofold: it's a Lisp, and it focuses on getting concurrency right. We've had Lisps for a while, and Python only really lacks Lisp macros, so let's think about the concurrency stuff... Clojure's design goals combine some deep ideas about identity, state and time together and includes data structures and a concurrency API that supports these goals. It's going to be hard for anyone to just convince you in a comment like this, and even if they could, I'm not the one to do it as I'm a Clojure noob. You should read this essay http://clojure.org/state http://clojure.org/state and watch this talk http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hic.... I think you will find that Clojure is pretty interesting, even if you don't start using it right away. I apologize for just throwing you links, but I can't do it justice, and Rich Hickey is a great lecturer, so you'll get more from his stuff.
- dkersten 15y agogetting better code density/more productivity Its not so much about brevity or productivity as it is about correctness. Functional programming and immutable data makes it easier to reason about code and to prevent bugs/errors, especially in the context of concurrent/multicore code.