
"On iteration": Why people leave Python - mattdw
http://brehaut.net/blog/2010/on_iteration
======
cgranade
That 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.

~~~
twp
Compared 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.

~~~
scythe
May I suggest Lua with metalua? It seems to have most of what you're looking
for (and luajit is very fast).

~~~
krakensden
Lua has a library problem for many tasks.

~~~
scythe
Such as?

~~~
s3graham
Many/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
But 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. :)

------
bobbyi
The 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
"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
Oh really? I would have said perl or perl-reloaded (aka ruby)? ;-)

------
jacobolus
Is there any evidence for this supposed trend? Or will these “many”
programmers remain merely a vague hand-wave?

~~~
pgbovine
i've found that demanding empirical evidence from a blog post often leads to
disappointment ;)

~~~
imok20
As 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...)

~~~
andrewcooke
_this is true for me ... though I'm still using Python for my next project_

i think you must mean "false", then.

~~~
dsil
No, he said he's using python, so it's False

~~~
andrewcooke
it's taken me a day to "get" that - i'd been thinking it was a confused
comment rather than a (questionable quality!) joke... have a vote back to 1
since i suspect you've been downvoted by others as confused as me.

------
dschobel
I'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.

------
jchonphoenix
As 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
_"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/s...](http://www.cs.tufts.edu/~nr/comp150fp/archive/richard-bird/sudoku.pdf)

~~~
jrockway
The 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.

------
justin_vanw
Functional 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
> 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
Ok, 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
"Name one big success story of functional programming. There isn't one."

Map Reduce. It is _implemented_ in C++ (and other languages) but MapReduce
itself is very functional. The users of mapreduce do "functional programming".
Maybe you wanted success stories of functional programming _languages_? (which
is a different question).

Another : SpreadSheets

Yet Another: SQL . SQL is (at the core) relational rather than functional, but
functions are relations. This keeps getting rediscovered every now and then
(witness all the noise around Rails3 and Arel)

"Nobody uses it who actually cares more about getting things done"

It must be nice to be so certain and knowledgeable about such things. You are
a lucky man ;-)

~~~
buster
I think he meant software. SQL is a standard on paper, not software. Map
Reduce is a framework, ok. But written in C++?

A software project that i would say counts is ejbabberd. But, that's the only
one i can think of.

Somehow i never looked at it in this way, but Lisp has been around since 1958,
Erlang and Haskell are not new either. Still there is not much software
written in those languages compared to other languages.

~~~
btilly
It sounds to me like you're the kind of person who has trouble recognizing OO
code written in C.

Once you truly understand a programming paradigm you can express it in any
Turing-complete language you want to. If you find yourself unable to do this,
then you don't really understand that paradigm. And I assure you that the
people at Google who implemented the map reduce framework understood
functional programming very well.

Incidentally the fact that you disqualify SQL from the discussion because
there is a paper standard seems to me to be silly. It is about as silly as
saying that C isn't really a software language because there happens to be a
written standard defining the language. The existence of the paper standard
doesn't change the fact of a lot of _software_ is being written with that
piece of programming technology.

~~~
buster
The fact that you compare SQL to C tells me that we clearly have a different
understanding of programming languages, yes. There are people that say "i code
HTML". Yes, call it coding and programming if you like. I won't. Clearly SQL
is powerful and great but you don't write software in it, which is my point of
differentiation.

Yes yes, and there are probably a lot of programs writen in Ada and Fortran
that have millions of lines of code and are reliable. But, you can argue with
me or not, it still is a niche.

C appeared in 1972.

Lisp (as one of the oldest i can think of) appeared in 1958.

Can we agree to say that there are far more programs written in C then in
Lisp? I don't argue which language is "the best" (because clearly, it's more
subjective then objective to state on that). But somehow, there is probably a
reason, that C, as a newer language than Lisp, has by far more "followers"
then Lisp. If Lisp (as the grandfather of functional programming, but you can
replace lisp with haskell, erlang or whatever you like) is so easy, creates
better, more reliable code, etc. etc. Why did C take off and Lisp didn't? In
fact why do younger languages like Ruby have the bigger growth? Clearly people
look for new languages, the people that nowadays learn ruby or c#. Why don't
they learn Haskell?

For example: Look at
[http://www.tiobe.com/index.php/content/paperinfo/tpci/index....](http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html)
The really brand new language Go made it to #13. Lisp/Scheme after decades is
#18. It's becoming more popular it seems, but i bet it won't be in the top10
for the next years.

Now, my simple and plain question is: Why is it like it is?

I actually don't want to argue what the best language is, there is no sense in
that. And i can't code functional. See me as an observer from the outside. I'd
like to learn erlang some time, for sure.

~~~
justin_vanw
I agree. It's like saying that a Porsche is 'better' than a Ford, but you own
a Ford because the Porsche costs more money than you make in a year.

I think functional language proponents want to compare languages using one set
of metrics, even though they actually pick a language to write software in on
an entirely different set of metrics. I mean they must either do that, or be
entirely all talk, since very little software is being written in functional
languages.

------
yesimahuman
The 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
There's always Jython for occasions like this one...

~~~
nostrademons
Jython 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.

------
manpreets7
Python 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
Clojure 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.

------
micheles
I 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.

------
Paddy3118
I 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.

------
petsos
Judging 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.

------
sfk
Well, on blogs Haskell, F# and clojure are popular, but in the words of past
decades:

Show us the code.

~~~
jrockway
I'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
Python, 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.

~~~
jrockway
Before you get too upset, the "popular" languages I'm thinking of are C# and
Java. Python is in the "smart people" category :P

------
apower
Is 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
I'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.

------
andrewljohnson
False: "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.

