5 ms·
I was a big fan of the: lazy python programmer, lazier python programmer, and python expert programmer series. Having been through that series, and watched many
by sophacles 17y ago
I was a big fan of the: lazy python programmer, lazier python programmer, and python expert programmer series. Having been through that series, and watched many others go through it themselves, I find it to be the best HAHA-only-serious bit in there.
I'm not sure what it is, but at some point every pythonista seems to go through this love affair with functools + itertols + roll your own haskellish modules.
- dkersten 17y agoIt would seem that the better you get at python, the more you really want a functional language. I know I went through this too (and I have moved onto functional languages for personal projects since..)
- sophacles 17y agoI remember that the "Real World Haskell" was one of the first books sold-out at the OReilly booth at Pycon 2009, if you want more supporting (anecdotal) evidence.
- Deestan 17y agoTo add to the evidence, I'm an experienced Python programmer who is currently waiting very impatiently for his Amazon shipment of "Real World Haskell" and "Purely Functional Data Structures". (Oh, and "Garfield Minus Garfield".)
- silentbicycle 17y agoWhile you're waiting for PFDS, here's Okasaki's thesis (http://www.cs.cmu.edu/~rwh/theses/okasaki.pdf http://www.cs.cmu.edu/~rwh/theses/okasaki.pdf). It's the seed of the book.
- gtani 17y agoThere's sort of an emerging Big 4 (plus 1) of FP http://book.realworldhaskell.org/ http://book.realworldhaskell.org/ http://programming-scala.labs.oreilly.com/ http://programming-scala.labs.oreilly.com/ http://caml.inria.fr/pub/docs/oreilly-book/ http://caml.inria.fr/pub/docs/oreilly-book/ http://www.freetechbooks.com/introduction-to-objective-caml-t698.html http://www.freetechbooks.com/introduction-to-objective-caml-... don't know of any freely available content books on Clojure or Erlang;
- grammati 17y agoThe last of those books opens with "Objective Caml (OCaml) is a popular, expressive, high-perfomance dialect of ML...". This must be some hitherto unknown usage of the word "popular"...
- sophacles 17y agoPopularity is relative -- in this case you must compare OCaml to other forms of ML, in which case the popularity is obvious :)
- gtani 17y agoforgot about these http://learnyouahaskell.com/ http://learnyouahaskell.com/ http://learnyousomeerlang.com/ http://learnyousomeerlang.com/ http://java.ociweb.com/mark/clojure/article.html http://java.ociweb.com/mark/clojure/article.html
- nailer 17y agoI write what I believe to be functional style Python, and have great coverage and fairly easy multithreading (normally using 2.6 Queue objects) as a result. I really like the clean syntax of Python, the less I have to look at on screen the better. Do you think there's a functional programming language I'd like? I've looked at Erlang but not been persuaded.
- brehaut 17y agoHave you looked at Clojure? [Huge ramble to follow] Clojure is a particularly interesting functional language for a python programmer IMO. It shares a number of asthetic and cultural properties with python that other lisps and other functional languages don't provide. Syntactically they are approximately distantish cousins. Clojure's syntax is much more restricted that pythons (obviously ;) but more prominent than other the other big lisps. Of note there is literal support for Vectors (much closer to pythons lists than the functional singly linked list), Maps, Sets, and these are used in the special forms too. A comparison (lets use identical implementations of factorial - taking some liberties so that the code is actually semantically identical, There are more idiomatic versions down the thread) def fac(n): "A function to calculate factorial in python" return reduce(lambda x, y: x * y, range(1, n + 1)) (defn fac "A function to calculate factorial in clojure" [n] (reduce #(* %1 %2) (range 1 (+ n 1))) In particular there is the vector in the form ([n]) used for the arguments list. The other thing to comment on is the funny looking #(* %1 %2) bit, thats an anonymous function/expression. There are two ways to write functions in clojure, that way and using a fn form. That same expression would look like (fn [x y] (* x y)) Clearly this becomes a matter of readability in most cases. Like python it means you have two ways to express a function. In this case you could actually just drop * in instead of the lambda, because it is just a symbol referencing a function like any other name. Python would require importing the operators library to do the same thing. Both languages are quite opinionated about the right way to do things. You are probably familiar with pythons. Clojure has a strong philosophy behind it, but its still pragmatic. Clojure promotes pure functional programming wherever its possible, and provides an excellent range of tools to break out of that where needed. Like Python, Clojure has good package management, good core data structures, lazy sequences (much stronger than pythons generators), quite a few batteries included (in particular if you consider clojure.contrib) though not as many as python. So if there are so many similarities, why would you switch? A number of reasons have made me do more and more of my development in python rather than clojure. First up i want to do more functional programming. Like many long time python programmers i started using functools and itertools, generators etc more and more, but functional style is not encouraged by certain parts of the community. Secondly, concurrency. I've written a bit of concurrent code in python (usually in an actor style using the queue objects) but python is ill suited to this, Clojure's persistent datastructures are much stronger here. In addition there is no GIL so concurrent code is able to run fast, not just asynchronously. On top of this, clojures references types provide _many_ options for concurrency which often simplify your design considerably compared to writing a message passing thing in python. Packaging and deployment is much better. If you are using a unix system http://github.com/technomancy/leiningen http://github.com/technomancy/leiningen is a must get. This is a build tool that manages dependancies for you automatically. It integrates with the clojars.org repository. This pairing replaces pip/easy_install and the cheeseshop as well as tools like virtualenv. The community is great. If you want to get started, the following comment by hga might serve you well http://news.ycombinator.com/item?id=1033503 http://news.ycombinator.com/item?id=1033503 Rich Hickey's various presentations and lectures make a compelling case for the language, and teach you a lot about how to use it at the same time. Even if you never end up writing code in clojure, these videos will teach you a huge amount, i highly recommend them. As you can probably tell from the amount of blather here, clojure has impressed me, and i would recommend any python programmer who has become interested in functional stuff check it out.
- l0nwlf 17y agoIt all started with ProjectEuler :)
- notaddicted 17y agoI'm constantly fighting an internal battle between functional programming and being more pythonic. For example: I once rolled my own lisp style immutable list type using nested tuples, i.e. (1,(2,(3,None))) for a problem that they were particularly well suited. (http://en.wikipedia.org/wiki/Knapsack_problem#0-1_knapsack_problem http://en.wikipedia.org/wiki/Knapsack_problem#0-1_knapsack_p...) and got about a 10% speedup. In the end though I threw it out because it was far too ugly. But I always prefer a def and a map to a for loop.
- rbanffy 17y ago"But I always prefer a def and a map to a for loop." For those I either go with a list comprehension or a generator expression.
- jordanb 17y ago^-- Hear hear. I started getting pretty deep into the functools until I discovered list comprehensions and generators. You get all the concise goodness of the functools while remaining Pythonic. The list comprehension is a really good, intuitive syntax too, I think.