

Python is a voluntary language - kracekumar
http://www.johndcook.com/blog/2011/10/26/python-is-a-voluntary-language/

======
postfuturist
Programming tastes evolve over time. At one point, and for at least a few
years, I believed Python was the one true language revealed mystically to GVR.
Up until that point, I'd done most programming in C++, so you can imagine how
much fun Python was, in comparison. After further development and discovery of
other programming languages, the shortcomings of Python have become obnoxious,
much like torturing someone by dripping water on their forehead incessantly.
Part of the problem is that I have to use Python for my professional work now.
Using a language for your day job is a sure way to reveal all the issues.

Here's what rubs me raw day-in and day-out:

1\. Lack of immutable/persistent data structures. 2\. Lack of multi-line
anonymous functions/lambda. 3\. Variable scoping fail, causing hacks like the
new `nonlocal` keyword. 4\. worst_possible_variable_name_convention. 5\.
Python evangelism. (community issue, mostly) 6\. Hypocritical "explicit is
better" and "flat over nested" values with insane amounts of magic built into
language and class system. 7\. No switch. 8\. GIL. (Actually the CPython
runtime in general) 9\. No macros. 10\. the insane way "unicode" is supported.
11\. and on and on...

At this point I write Python code, but not generally by choice. Mostly my
coworkers can't even imagine writing code in another language, given that we
have been allowed to choose our implementation language(s) as a team.

~~~
sausagefeet
I went through a similar progressions, or I guess I'm still in it. I have
found multiple languages to replace aspect sof what I liked about Python but
not one that addresses all of it. I think if F# existed on *nix in strong way
I'd consider it a Python replacement.

~~~
Jtsummers
What about OCaml/SML, or is .NET/Mono the thing that really sells it for you?

~~~
sausagefeet
Ocaml, as a language, is amazing. But it's implementation isn't much better
than Python's. No parallelism for example. And its ecosystem is worse than
Python's in many ways, such as building code. I love the language, it's just
the implementation that makes it an incomplete solution for me.

------
petercooper
_I wonder whether the increasing popularity of Ruby for web development has
created pressure for Ruby to compromise its original philosophy._

I don't think it has. The original philosophies, as much as they exist,
oriented around ease of use, programmer happiness, and pure OO - things
Rubyists still enjoy. But Ruby has missed the boat on being a popular, general
programming language in the way Python is _big time_. _Most_ Ruby jobs are
related to building Rails apps in some way or another and the majority of the
Ruby ecosystem (in the West, at least) orients around Web development (and not
gaming, scientific programming, education, or the many niches Python has found
a home in).

Ruby is an interesting language and one that's worth learning and using IMHO,
but in the West, Ruby has become "typecast" as a life support system for Rails
essentially. (Before people note the non-Rails things they're doing with Ruby,
I said _most_ Ruby jobs and the _majority_ of the Ruby ecosystem. Reporting on
Ruby developments has been much of my job for the last 6 years but I am more
than happy to be swayed :-))

~~~
brandall10
I'm curious though, what was the uptake on Ruby before Rails?

I wasn't aware of Python/Ruby back in those times, but my impression now is
Python was widely used prior to Rails existence... in academia, science,
mathematics, etc, but Ruby was not much on the map until Rails came along.

I'm not saying this is how is was - I honestly don't know, just my impression
as someone fairly new to this stuff. I would appreciate if someone who was
familiar with the Ruby community prior to Rails could shed some light on this.
Doing some google searches turns up minimal clues. The wikipedia on Ruby says
"Around 2005, interest in the Ruby language surged in tandem with Ruby on
Rails, a popular web application framework written in Ruby. Rails is
frequently credited with making Ruby "famous""

~~~
kibwen
While I wouldn't quite recommend the TIOBE index in general, it's still useful
for attempts to identify significant events in the history of a language's
popularity. Here's its historical graph for Ruby:

<http://www.tiobe.com/index.php/paperinfo/tpci/Ruby.html>

According to this, Ruby really exploded in 2006 after holding steady for quite
some time in relative obscurity. Now you just need to figure out when Rails
became hugely popular to check for a correspondence.

~~~
dpritchett
I believe it was this presentation in November 2005:
<http://www.youtube.com/watch?v=Gzj723LkRJY>

------
yummyfajitas
I definitely wish I was writing something other than python. I did choose it,
but it's not the language I want to be writing in. It's just the language that
happens to have numpy, django, etc.

While writing it, I often wish it were statically typed with pattern matching.
The write/test/type error or undefined variable cycle is very frustrating to
me. The lack of pattern matching makes my code verbose and also makes it
harder to spot edge cases I missed.

I also wish functional programming in it were as easy as in Javascript. I
often find myself writing a bunch of front end code, finding it elegant, then
thinking "damn, back to python to update the api". (This includes multiline
lambdas.)

It's still my go-to language for most purposes, but I constantly feel that it
could be a lot better. I'm looking forward to the day when javascript
completely subsumes the niche python occupies.

~~~
tmhedberg
I agree with you on static typing and functional style being strongly
preferable, and that Python makes that style of programming irritatingly
difficult, but it's not like JavaScript has static typing or pattern matching
either, so it seems odd that it would be your preferred replacement. Why not
wish for a replacement that actually has all of the features you want?

~~~
yummyfajitas
Haskell is my preferred replacement, but I don't really expect Haskell to
replace Python. It might replace C++ or Java, however, or form it's own new
niche.

People seem to want a simple, dynamically typed scripting language. Javascript
can fill that niche while being a big improvement on Python. (Particularly if
we accept some breakage of backwards compatibility, add a module system, and
clean up the warts.)

~~~
rprospero
I'm going to try and say this carefully, because I don't want to start a
language war. Quite the opposite: I desperately want to change my views on
programming languages.

I've only recently started in Javascript, so I'm probably missing something,
but I've been finding it a large step backward from Haskell when compared to
Python. Specifically, list comprehensions and generators give Python a more
functional feel. Meanwhile, the object system in Javascript has had me
generating far more state than I ever would have in my Python code, while also
requiring more manual type checking than I ever needed in Python.

I'm new to the language, so I'm sure that I'm missing something. I've read
_Javascript: The Good Parts_ and it's helped me grow less frustrated, but I'd
love to find out that this language is better than Python.

So, how do you write functional code in Javascript?

~~~
yummyfajitas
I wrote poorly, I wasn't meaning to imply js is haskell-like. It's scheme
like.

I write js using underscore and backbone, so while I have state, it's pretty
well encapsulated.

So I've got a few stateful backbone models. The inside of their methods tends
to be primarily functional, followed by a stateful update:

    
    
        var intermediateResult1 = _.map( input, function (ss) {...});
        var intermediateResult2 = _.map(input, function(ss) {...});
        var intermediateResult3 = _.intersect(intermediateResult1, intermediateResult2);
        ....
        this.setState({ "my_attribute" : result })
    

My views are almost entirely functional - take a model as input, create some
dom elements as output, and one side effect when updating the view.

They may be just syntax, but multiline lambdas certainly help. And some of
this is just library support. But all put together, it makes my js code far
more functional than my python code.

~~~
rprospero
Thanks for the response. As I told Kibwen, the underscore library looks pretty
neat. Also, my problems may have just been some brain damage on my part. I'd
gathered that object hierarchies were the more idiomatic way to code
javascript.

I've been trying to write Javascript and then make it functional. I think I
need to start writing functionally and just fit that into the Javascript. From
what you've written, that looks pretty doable.

------
plessthanpt05
Nice point, and really, how many folks actually find writing code in Python
cumbersome or "work" like some languages? It's not perfect and of course if
you need really fast computing, it's obviously not (even close to) the best
for speed, but it's expressiveness & readability are a pretty big step up from
most other languages.

Also, I hadn't seen this essay by PG before (from the comments); a bit old,
but interesting take:

<http://www.paulgraham.com/pypar.html>

------
broseph
Just for the record: I used Python at work because I had to; I'd rather have
been writing Java.

The titanic investment bank that I used to work for started a major rewrite of
its entire set of booking and risk systems in which everything was to be
written in Python. It immediately assigned hundreds of programmers to the
task, shepherded by a "core team" eager to use every feature of the language.
The result was a perfect example of the problems with Python in the large.
Enormous type hierarchies mingled with copious use of eval; there was no
structure at all to much of the code.

It's possible to write terrible code in any language, of course, but using
Java would have been one way to curb some of the worst impulses of the low-
quality programmers.

~~~
lucian1900
It seems that it would be much better to hire less and better programmers.

------
swang
In terms of imperative languages, python is #2 for me. And really I haven't
done much python in the last couple of years mainly because anything I would
want to do in python I'd rather do in ruby. Of course you will definitely hear
me say, "I'd rather use python than Y" but I'd also say, "I'd rather use ruby
than python"

I don't even get what he's trying to get at in paragraph three. From looking
at jobs for startups and jobs in the Bay Area I can see that a large majority
of them are using python over ruby. So python compared to ruby is relatively
more popular at least from a job-seekers perspective.

So even though this is true, he singles out that ruby may possibly have
compromised it's original philosophy with rails because of its popularity but
yet python hasn't been affected at all by its mass popularity from most
startups and science/academia companies using it? Python also has a pretty
popular framework in django yet I don't really see any pressure by Guido to
change python because of it.

Really this article is a pretty ignorant view of ruby since he himself admits
he does not know much about ruby. So why bother writing that last paragraph
other than for the sole purpose of putting down ruby? The last paragraph feels
pretty tacked on and seems to be a nice jab at ruby for no reason other than
he likes python.

Let me just end by saying, I love python, but I love ruby more. I don't have
any ill-will towards python. But consider if this article was written about
ruby and dhh wrote it. How much vitriol do you think dhh would get from
writing an article like that?

------
knowtheory
> I don’t know much about the Ruby world, but I wonder whether the increasing
> popularity of Ruby for web development has created pressure for Ruby to
> compromise its original philosophy. And I wonder whether Ruby’s creator
> Yukihiro Matsumoto has “dictatorial” control over his language analogous to
> the control Guido van Rossum has over Python.

This is a some what irritating speculative musing, given the fact that it is a
question that could easily be answered by talking to any number of Rubyists
who are available and interested in answering such a question.

One of the major points of tension in the Ruby community is the extent to
which the non-Japanese Ruby community has input and control over the destiny
of Ruby as a language. Given a number of alternative implementations of Ruby
(JRuby, Rubinius, MacRuby just to name the popular ones), alternative
implementors have gone well out of their way to ensure conformance with the
mainline Ruby implementation.

In fact they went so far out of their way to build a spec suite to
characterize the behavior of Ruby the programming language from it's actual
implementation. And on top of that there's even a new ISO spec for Ruby.

So, yeah. Matz does have control of Ruby, and Ruby does resemble Python in its
voluntariness.

~~~
kibwen
Agreed, but I confess that I'm also a bit unclear as to Matz's active
involvement with the language. Every "Ruby expert" post on HN seems to
originate from either Yehuda Katz or DHH... is it just that Matz prefers to
communicate in Japanese, on Japanese mailing lists?

~~~
petercooper
Matz is deeply involved with the language's design and a couple of its
implementations but as a _community_ leader, in the West, at least, he doesn't
do much or have much impact IMHO. This is part of the reason people, rightly
or wrongly, have seen the well known Rails developers as figureheads for both
Ruby and Rails and then poured scorn on Ruby for their actions.

------
sasha-dv
>People who write Python choose to write Python.

People who write X choose to write X.

There's virtually no language that can't fit the bill. It may surprise some,
but there are people who choose to write Java, Perl, C, and even C++.

edit: Didn't realize that people who choose a language different than Python
aren't actually people.

~~~
rprospero
The following statement is false:

    
    
        People who write LabTalk choose to write LabTalk.
    

It is false because I am a person who writes LabTalk and I did not choose to
write LabTalk. I hate LabTalk with a passion. However, I am forced to write
LabTalk to interface with one of the systems at work. The following statement
is also false:

    
    
        People who write Tcl choose to write Tcl.
    

I had a coworker who was forced to learn Tcl to maintain a legacy system. He
hated Tcl, mostly because it wasn't Fortran. Honestly, though, I have a soft
spot for Tcl, so the following statement is true:

    
    
       Some people who write Tcl choose to write Tcl.
    

Now that statement is trivially true and most of your original argument
applies to it. In fact, I'll even agree with you that

    
    
        Some people who write X choose to write X
    

applies to virtually every language. All people who write a language different
than Python are people. The original statement does not make that claim. It
makes the claim that the set of people who write python does not contain any
elements from the set of people who did not choose to write python. That claim
is not true for Java, Perl, C, C++, LabTalk, or Tcl. It may not even be true
for Python. However, it is a meaningful claim.

~~~
sasha-dv
>That claim is not true for Java, Perl, C, C++, LabTalk, or Tcl.

Sure, it's not true for any of them, _even_ Python, but it's _meaningful_ for
any language including Java, Perl, C, C++,...

It's easy to forget that computing is a huge field and that hackers diverse in
their tastes and fetishes.

------
gordianknot
I use Python at work because I have to, but I'd rather be writing JavaScript.

------
jsofra
I use Python at work because I have to, I would really rather not.

------
its_so_on
EDIT: Python is my favorite language. But I wish a LOT more very lazy people
or people who can't apply algorithms to solve their own problems (and
hopefully in all the same domains that I work in) used it, discussed and asked
questions, etc.

It is in this vein that I write...

"Python is popular enough to have a critical mass of users" - on this point
unfortunately I have to disagree.

Often the way I write a script is to put in a little extra effort up-front: I
do three or four Google searches with the hard part of the task + Python,
Perl, PHP, etc -- just to see if someone has already done this for me. I must
say that if it's something hard and remotely web-related, the Python part is
usually not even worth trying. Either I can do it off of the top of my head,
or some fool is asking how to do this thing they can do in PHP in Python and,
well, not really getting an answer. (It's not that it's wrong to code things
up the long way, it's just that, like I said, it's not even worth doing the
Google search).

In this sense there is not a 'critical mass' of users. Let me give you a
simple example. Say you want to do fancy appointment-matching like people
saying "next friday"...you want to try to pick up on that and offer to set an
appointment. So, Google "appointment regular expression next friday php"
"apppointment regular expression next friday python" "appointment regular
expression next friday perl". You can go ahead and do it, I don't even have to
check. If you don't find anything, play around for less than 15 seconds with
alternate search terms (more general, more specific, or just different.)

I did the above search just now, and in my case I went off on this tangent and
within a couple of minutes had an answer that was satisfactory for me.

I would say, well, there are simply lots of fast scripts that you KNOW can
take you 2-3 days of head-scratching to get right _OR_ that the community
already has bumped their heads against. Which do you do? If you're NASA, of
course you go through scratching your head and getting the RIGHT answer. If
you're trying to get a demo out the door, then you go for the low-hanging
fruit, with as much leaning on the community as possible. Of course, if its
creation, trajectory calculations, whatever, involve a scripting language in
any way, would I want a _rocket_ to use Python over PHP. But if I need a
script that creates a GIF file of a rocket blasting off off-screen, based on a
static image of the rocket that I have? (Forget whether the gif is the correct
solution, I just want to see what it looks like, maybe as part of
investigating lots of possible ways to do this). Well, then I would do a
couple of minutes of Googling first... (As above, though I didn't try this
one). Usually, I'm sorry to say, Python doesn't win.

If this get smore downvotes I'll try the Python search on creating a gif file
programmatically.

~~~
scott_s
I am having difficulty figuring out your point. Is it that, when you Google
for examples for how to do something in Python, you usually don't find
satisfactory results? But that other languages (Perl, PHP) do provide such
results?

If that's the case, then what particular task you're asking about is going to
impact how successful you are. People write much more than just "web-related"
things in Python. And, personally, I don't consider that to be important for
what I consider a critical mass of users. Rather, what I think is important is
that there is enough of a community to provide good online documentation,
plenty of technical books, maturity of the toolchain, and integration in most
systems.

~~~
its_so_on
I'm sorry my point was unclear. Often I place speed (i.e. time-until-I'm-not-
doing-this-anymore) at an incredible premium to the point where I don't care
what the language is! For example, say that you want to attach a process to
monitor a logfile of your web-server(apache, say) and SEND YOU AN EMAIL when a
string enters that logfile.

Hopefully, you should be able to complete this task in every single
programming language that appears on your resum, including javascript if you
have put it there.

In practice, if you are a one-man show trying to get a whole startup off the
ground (including all of the biz dev, all of the back-end, all of the front-
end, all of the customer e-mails, EVERY SINGLE THING YOUR COMPANY IS DOING)
then you don't have the luxury to scratch every itch. There are itches that
you can scratch if someone has done it and you can find this out in 15-20
seconds, otherwise, you just don't have the time.

In this sense PHP wins where Python has not yet won.

~~~
scott_s
I understand what you're saying, but I still don't feel that its relevant.
Your example is the sort of thing that I would expect myself and other
developers to be able to produce a more reliable solution on their own than
what they could copy-and-paste from the web. In other words, I wouldn't do it
myself because I felt like I "had to scratch that itch." I would do it myself
because otherwise I would have no trust that it would work.

~~~
its_so_on
Right, I think your final sentence gets at the crux of what I'm talking about.
I have 0 trust in PHP that my script really 'works' -- however, very often I
have a lot more confidence in being able to get to something that 'seems to
work' within 30 seconds. Whereas, in Python I am pretty much guaranteed to
spend 5-15 minutes on it.

As for web work. I actually just did try "how to tail a file in php" and "how
to tail a file in python". On the PHP side I instantly saw this stackoverflow
question [http://stackoverflow.com/questions/1102229/how-to-watch-a-
fi...](http://stackoverflow.com/questions/1102229/how-to-watch-a-file-write-
in-php) which links to this:

<http://code.google.com/p/php-tail/>

 _Ability to tail small and big files for updates using PHP and AJAX. Includes
the ability to grep results for a specific keyword.

\- Fully documented

\- Fully customizable

\- Updates the page with new information without a page refresh

\- Change GREP keyword / invert on the fly without a page refresh

\- Uses JQuery / JQueryUI libraries

\- Simple to use UI

\- Automatic scrolling when required (if a user scrolls up, the automatic
scroll is disabled until the user scrolls to the bottom again)_

Wow, that is pretty amazing. If someone just HAPPENS to be looking for a quick
tail through a web-browser, with grep functionality, this is a drop-in
solution. It's not what I needed, but this is my whole point about community-
size. As it gets larger and larger, there is a greater and greater possibility
that just what you need is 30 seconds away. It would literally take you hours
to do all of the above in Python.

