8 ms·
"On iteration": Why people leave Python
- cgranade 17y agoThat article makes some really good points, but I disagree. To me, Python is quickly becoming a good middle ground where I can use these powerful functional ideas, then drop down to imperative whenever I need to. In particular, this means that I can use Python to do scientific computing or to easily work with native libraries while still maintaining a lot of the functionality of more pure languages.
- pgbovine 17y agoagreed ... also i think the dynamically-typed nature of python (and similar languages) makes them very amenable to rapid prototyping and experimentation (code just runs without having to fight the type inferencer or checker). python lets you do clean and beautiful functional programming, but also, as you mentioned, to drop down to quick-and-dirty imperative mode the author has a good point about pure functional languages being better-suited for concurrent programming, though
- brehaut 17y agoJust to be clear, Clojure (and most lisps) are also dynamically typed and thus allow just the same experimental approach. Clojure and Common Lisp (I can't speak for other lisps, but I think some schemes too - PLT Scheme perhaps?) also have optional Type Hinting that allow the program to run quickly too.
- twp 17y agoCompared to traditional static languages (C++, Java), Python offers an order of magnitude of improvement in productivity. Compared to older scripting languages (Perl), Python offers a sane language and a rich programming environment. Compared to other current popular scripting languages (Ruby), Python offers a solid runtime and better out-of-the-box performance at the expense of some elegance and fluency. Comprare to some very interesting languages (Haskell, Erlang, Scala) Python is more widely available and allows you to produce good, portable, well-performing code quickly and easily. It's a state of flux. Right now Python is my language of choice (after ten years of Ruby) and it touches that sweet spot of expressiveness and performance. However, the bolted-on features (verbose object system, clumsy metaprogramming) deliberate crippling of language (e.g. one line lambdas) and the underlying message of "there's one way to do it" (which is my way, because I know better than you) will, for me, mean that eventually I will move on. More expressive, coherent and flexible languages will eventually reach Python's current level of maturity and performance, and then it will be time to switch. It could be MacRuby, Scala or F# (but probably not Haskell or Erlang). Who knows. But, for now, Python is a good choice. Edit: typos.
- foldr 17y ago>Compared to other current popular scripting languages (Ruby), Python offers a solid runtime and better out-of-the-box performance at the expense of some elegance and fluency. Although, Ruby doesn't have any iteration constructs as nice as Python's generators. (You could create them using call/cc, but I expect the performance would be awful).
- scythe 17y agoMay I suggest Lua with metalua? It seems to have most of what you're looking for (and luajit is very fast).
- krakensden 17y agoLua has a library problem for many tasks.
- scythe 17y agoSuch as?
- s3graham 17y agoMany/most libraries in Python are built in, so you don't need to hunt them down and install. More importantly your users need only have "Python", nothing more or less and don't have to fiddle to get things working.
- silentbicycle 17y agoBut unlike Python, Lua is smaller than SQLite. You can just put it in a DLL and install it with your project. Any users that even notice it would be shocked to see how many installations of SQLite they probably have. :)
- moe 17y agoI would expand that to say that lua has a standard library and framework problem. You can link any old C library but there's little uniformity in how everything fits together and rather few task-oriented packages/frameworks exist. I like lua and am using it for some tasks where I'd have used C in the past. But for many things where ruby/python have strong, pluggable libraries (e.g. everything web-related) there is simply no equivalent in lua-land. Kepler project is nowhere near a django or rails.
- jacobolus 17y agoIs there any evidence for this supposed trend? Or will these “many” programmers remain merely a vague hand-wave?
- pgbovine 17y agoi've found that demanding empirical evidence from a blog post often leads to disappointment ;)
- joe_the_user 17y agoI left Python for c++ because the job called for c++. But there wasn't anything in Python that I found compelling so I never came back. As a scripting language, Ruby seems so much more compelling, despite it's friendliness seeming to doom it to eternal slow bugginess. I'd go back to Ruby before Python. But I'm more likely to add Python support to an app I'm developing, since I know it's more sensible. Python's functional aspects seem chronically undeveloped so leaving it for a real functional language makes sense. But functional approaches seem limited in the "real world".
- regularfry 17y agoRight now, for me, it comes down to the libraries. I'm much happier in Ruby, but Ruby doesn't have nltk, scipy or boto. Then again, Python doesn't have rake.
- brehaut 17y agoRight on the money ;) All the evidence i have is purely subjective and anecdotal, but I personally know of a number for whom this is true.
- imok20 17y agoAs additional anecdotal evidence, this is true for me, though I'm still using Python for my next project simply because it's a proven language with proven libraries. But I'm certainly ready and interested in moving toward a more functional language -- I've always been interested in the Lisps, and have always tended to write code in the functional style, where possible (even though my first language was Java...)
- sfk 17y agoWell, on blogs Haskell, F# and clojure are popular, but in the words of past decades: Show us the code.
- hga 17y agoF# and Clojure are rather new and Haskell is only now maybe coming out of it's "Avoid success at all costs" phase (or so I judge by the Coders at Work interview of Simon Peyton-Jones).
- jrockway 17y agoI've gotten paid to work on a lot more Haskell than Ruby or Python. The languages you see depends on the languages you want to see. Haskell is really quite adequate for real work these days. It has the libraries you'd expect, and it's a nice language with a nice runtime. It's also worth noting that blog-popular languages are blog-popular for a reason. The people that blog about programming are the ones that need tools that give them a bit more productivity between the occasional nap or meal; the people that use the more esoteric languages want to solve so many programming problems that a sharper tool is essential to their survival. (There is only finite time, after all, and programming languages are easier to build than time machines.) In contrast, the "popular" languages are mostly used by people whose goal is to warm their chair for 8 hours and receive a paycheck. There are a lot more people that want money than that want creative time with a cold, unloving machine, so it follows that the languages where you can get paid and not care are going to be most popular. But if you are the second type of person, there is little advantage in worrying about what is "popular" in "the real world". You don't want to be in the real world.
- Paddy3118 17y agoPython, popular!!! that is just so great! I've watched it grow for over a decade and a half. Python got were it is, largely without the big initial push of large companies. Maybe people now blog about python because the community has always tried to be friendly. It is usually nice to blog about Python, and have fellow enthusiasts give measured, polite feedback. "... so it follows that the languages where you can get paid and not care are going to be most popular." But it does not follow that there are less caring, articulate, and productive souls in a more popular languages camp. - Paddy.
- andrewljohnson 17y agoFalse: "There is an observable trend in Python programmers that results in a reasonable section of them moving to functional programming languages." True: There is an observable trend that more and more people are using Python, and there is a smaller set of people that is not a subset of Python in any way that is toying with functional programming, usually for academic or masturbatory purposes.
- bobbyi 17y agoThe reason Python is such a joy to use is that it hasn't felt the need to be all things to all people. Those of us who use python are often coming from C++, perl, etc. and know all too well what happens to languages that try to add every feature that someone might find useful. If you want to use a lazy purely functional language, you know where to find one. It's not python. If you want a language that allows you to express your inner emotions by using your personal pet programming style, this isn't it either.
- nostrademons 17y ago"If you want a language that allows you to express your inner emotions by using your personal pet programming style, this isn't it either." That would be Lisp. ;-)
- moe 17y agoOh really? I would have said perl or perl-reloaded (aka ruby)? ;-)
- jchonphoenix 17y agoAs a programmer who has used variants of SML (F# is Microsofts variant), Haskell, and Python, I would say that in terms of concise expressiveness, you have a point that the functional languages match Python's. However, the true power of programming in Python is that the programming logic is easy to understand. If you are actually experienced in functional programming, you'll realize that it is, in all definitions, code. Python is more like english and thus, the appeal will always be there.
- mbrubeck 17y ago"Python is more like english" Having written non-trivial programs in Haskell, ML, and Python, I agree with this, but I would add: Functional programming is more like mathematics. English expresses some ideas more clearly, while mathematics is better for others. And notations that are more "mathematical" often have other nice properties like composability and equational reasoning.* *The best example of what I mean by equational reasoning is the Sudoku functional pearl: http://www.cs.tufts.edu/~nr/comp150fp/archive/richard-bird/sudoku.pdf http://www.cs.tufts.edu/~nr/comp150fp/archive/richard-bird/s...
- jrockway 17y agoThe paper you posted is a good example. The conclusion is: sudoku = map (map head) . search . prune . choice Note how the "code" never mentions the data to which it is applied, namely the Board object. This is why I can't agree with the GP's argument that FP is closer to "code" than anything else -- I think it's as far from "code" as you can get. There are no "instructions" here, just an equation representing something complex ("the solution to sudoku"), in terms of slightly simpler parts. The simpler parts are, earlier in the paper, the complex parts; and are of course described there by simpler parts. And, this is not just something that's useful for esoteric mathematics papers; my "enterprise" code in Haskell looks very similar.
- deleted 17y ago[deleted]
- 17y ago
- justin_vanw 17y agoFunctional programming simply isn't any better than the usual style of python development. I have used much of itertools. When you need to do some complex iteration through lists, itertools is great. When you need to pull an address out of a web page, itertools does absolutely nothing to make that easier, nor does any other functional programming technique. So here is the difference. Procedural style is better for dealing with a problem. Functional style is great for applying a solution to lots of pieces of data in a structure that can be iterated over or recursed into. The hard part is dealing with each problem, not the part where you apply it.
- mattdw 17y ago> When you need to pull an address out of a web page, itertools does absolutely nothing to make that easier, nor does any other functional programming technique. I'd say an approach like "iterating through all nodes, filtering for the one(s) you want" is quite functional. Add lazy iteration to that, so you're only parsing/consuming as much of the document as necessary, and on-demand, and you've got a really nice, _functional_ solution. [edit: toned it down a little.]
- justin_vanw 17y agoOk, that is great so long as you are processing XML. Actually, it isn't great even if you are processing xml. What is the functional way to get the 3rd - 8th li in the 2nd ul where the ul has id="foo" and is in a div (either directly or as a decedent) where the div is directly before the 'comment' <-- content area --> ? You use XPath, or CSS after finding the comment with a regex. People get incredibly retarded about functional languages, but in reality the only software that I have used that is written in one is XMonad. So in your mind everyone who actually gets things done is using the 'wrong language'? Or an inferior one? Name one big success story of functional programming. There isn't one. Nobody uses it who actually cares more about getting things done than reading self congratulatory blogs between CS classes. [in no way toned down]
- plinkplonk 17y ago
- yesimahuman 17y agoThe only reason I'm starting to leave Python is because of performance. When you see a program that used to take 2 hours to run in python now taking 10 minutes in Java, it kind of makes you realize you've been making a mistake by using it places it doesn't belong.
- viraptor 17y agoThere's always Jython for occasions like this one...
- nostrademons 17y agoJython is closer to Python's speed than Java's. Or if you mean Jython with the speed-critical bits written in Java...well, there's always C for that.
- deleted 17y ago[deleted]
- LBarret 17y agoDid you try cython/numpy/fileinput ? just curious. Our team met perf problem in the past and each time, a rewritten code or even a rewritten module was all it took to get back on track.
- gte910h 17y agoTry: Weave Cython SIP Python is really easy to tie into other languages for the slow parts.
- dschobel 17y agoI've had the opposite experience with C#. MS' adding of lambdas and deferred list operations in 3.5 has delayed my switching to F# for all of my heavy number crunching work (For those who have yet to try ruby, python, scala, c# et al-- being able to switch between imperative and functional style on a per task basis is a wonderful way to work). In the real world, suffering a few weeks of diminished output due to learning new syntax, idioms and best practices is not always (dare I say, rarely) feasible so making an existing language more powerful through the addition of functional constructs can only extend their productive life.
- apower 17y agoIs this like the exodus of the Ruby programmers? Remember Ruby was on rage couple years ago? But suddenly became out of favorite due to various issues. Looks like Python is the same way. People play around with it and find out all kinds of issues. When a new language appears (Clojure), people leave in doves. Just another fad.
- brehaut 17y agoI've been using python for about 8 years before feeling like i wanted to move. I think that puts me well outside the fad window.
- micheles 17y agoI am a Python programmer. I have toyed with functional languages (Scheme, SML) for many years. Over the time my code is becoming more and more functional, in every language I code in. Nevertheless, I do not plan to quit Python at all. Readability counts in my book and I do not see Clojure to be more readable than Python. Moreover, I am not considering F# since it is platform specific and I do not develop on Windows. In my experience Python is not losing programmers; perhaps 0.1% of them are moving to functional languages, but more are coming from C++, Java and even Ruby.
- manpreets7 17y agoPython holds a strategic middle ground. It's far more productive, expressive and concise than the traditional procedural and OO languages. Although not as expressive and elegant as the new FP languages like Clojure and F#, the latter lack massive libraries and modules that have been written for Python. That makes them useless for any 'real' work. Python is seeing some heavy use by the scientific community due to tools like NumPy, matplotlib, libsvm and what not. Good luck finding that range of independent libraries for a new FP language. I am not dropping Python in the near future, but I am watching.
- mattdw 17y agoClojure can use (with very little mismatch) any available Java/JVM libraries. F# can use anything available for the CLR/.NET. Libraries are not really an issue.
- petsos 17y agoJudging from the comments, people leave Python to do toy projects in functional languages. My guess is that after using functional languages in real projects, most of them will go back to Python.
- Paddy3118 17y agoI am an active contributor to www.RosettaCode.org where I browse many languages. What I have seen of the functional languages doesn't make me want to switch. Despite knowing Pythons functional tools, it wasn't Python that introduced me to that style. I find Pythons mix comfortable and happily switch between programming in Python 3 and Python 2. Maybe the OP hopes to start a trend? - Paddy.