
Joe Stump: Why I switched from PHP to Python - dannyr
http://www.joestump.net/2009/09/why-i-switched-from-php-to-python.html
======
steveklabnik
While Python is a great language, aren't "Things Guido doesn't like aren't
supported at the language level" and "Python treats developers as adults" sort
of at odds?

    
    
      * TCO is dangerous and hard, let's not support it in the language
      * ++ is ugly, let's not support it in the language
      * Assignment during comparison leads to bugs, let's not support it in the language
      * Python gives you more than enough rope to hang yourself, but at least hanging yourself is an option.
    

One of these things is not like the others.

~~~
hristov
I wonder why supporting TCO or not has anything to do with the language. I
mean isnt it up to the compiler or interpreter? If a compiler can get the same
final results with TCO, then why shouldn't it? And the definition of a
language should not define how a compiler works internally only what the
actual effect of the language instructions should be. Compiler writers should
be free to do what they want to realize the defined effect.

BTW as someone that moved from Pascal to C and C++, I can appreciate the
ugliness of a lot of C shorthand syntax. It is confusing and can cause a lot
of bizarre and hard to catch bugs.

~~~
gaius
That's true; Guido only says that TCO isn't going to be written into the
Python you download at python.org.

~~~
steveklabnik
You are incorrect.

"Second, the idea that TRE is merely an optimization, which each Python
implementation can choose to implement or not, is wrong. " -
[http://neopythonic.blogspot.com/2009/04/tail-recursion-
elimi...](http://neopythonic.blogspot.com/2009/04/tail-recursion-
elimination.html)

------
zokier
Does one really need to explain why he switched from PHP to anything?

~~~
sophacles
This sort of thing is still needed. I have a friend who's boss wont let him
use anything except c, php, and perl. Any attempts to get python in there are
met with resistance and vague hysteria. More posts like these from can slowly
lower people's loyalty to php, and contribute to saving my friend and many
like him.

~~~
jrockway
Well, is Perl really a problem? Anything you can do in Python you can do in
Perl just as easily; Perl actually has _more_ abstractions available for the
programmer than Python. (Grammars in regexes, real closures, coroutines, a
metaobject system, etc.)

Also, last time I checked the programming language shootout, Perl 5.10 is
slightly faster than Python 3.

So with that in mind, the logical "step up" from Perl would be something like
Haskell. Python is pretty much Perl with different syntax, less features, and
the impression that it's "cleaner" because nobody ever bothered using it for
"quick and dirty" scripting.

~~~
codexon
Python 3 smokes Perl.

[http://shootout.alioth.debian.org/u32q/benchmark.php?test=al...](http://shootout.alioth.debian.org/u32q/benchmark.php?test=all&lang=python3&lang2=perl&box=1)

And most people are using 2.x which is even faster.

[http://shootout.alioth.debian.org/u32q/benchmark.php?test=al...](http://shootout.alioth.debian.org/u32q/benchmark.php?test=all&lang=python&lang2=perl&box=1)

~~~
kingkongrevenge
That's winning at the special olympics. They are both so slow you'd never use
either for cpu constrained tasks.

~~~
sandGorgon
That is plain offensive. The special olympics are an even greater achievement
of the human body as a machine, since it must push itself with far lesser
degrees of freedom.

~~~
pieceofpeace
As I saw, it was not meant to be offensive. Special olympics are for special
people. They are not the best among all competitors. Most interpreted
languages are not comparable to compiled languages.

~~~
jrockway
Neither Perl nor Python are interpreted. They are both just slow.

------
lux
You have no idea how much I wish I could do this. Just testing my code from
PHP 5.2 to 5.3 and there are several serious problems now that I get to find
workarounds for, all while maintaining backward compatibility too.

How is it that a minor upgrade changes functions and their behaviour so much
that it breaks existing PHP5-compatible code? WTF is wrong with the PHP
developers?

If I didn't have so much code (whole product with contracts to support)
invested in PHP, I would switch in a heartbeat and never look back.

~~~
Maascamp
Python 2.x -> Python 3 Ruby 1.8 -> Ruby 1.9

Do you actually know anything about languages other than PHP and want to
change for legitimate reasons? Or are you just jumping on the bandwagon
because it sounds cool?

~~~
lux
I'm perfectly aware 1.8 to 1.9 was a pretty big move for Ruby folks (maybe
could've been called 2.0?), and 2.x to 3 in Python, that's the time for big
changes. I've also written real production software in about half a dozen
languages, so yes I do. I just happen to have a codebase of 100,000+ loc in
PHP that I support, so I'm kinda heavily invested in it more than the others.

It sucked trying to rework so much PHP4 code for PHP5 while keeping b/c, since
that felt like the slowest community migration to a new version I've ever
seen... But it seems like each additional release from PHP changes and breaks
something else. My codebase is older than many, so it's possible that's made
it a bit more brittle over time, but things like completely changing the
allowed characters in .ini file keys from 5.2 to 5.3 I find baffling. Yes,
speed things up or improve things, but consider that existing liberties you've
allowed may come to be relied on by your users. If you let them do something
in 5.2, make sure they can still do it in 5.3. I'm always careful myself to
make sure existing code will continue to work, and new features are offered as
optional or via new APIs. Code from 3.x of my software continues to run fine
on 5.x as a result, which lowers my support burdens.

So again, no I'm not just fanboying for other languages or falling for the
"grass is always greener" line of thinking. PHP just has certain inelegant
things that I find add to my overall frustration over time. I value terseness,
so things like -> versus . for objects adds up, just like $ versus nothing for
variables wears at the wrists too. I value consistency, so not remembering
which parameter goes first for in_array() versus strpos(), or why the
differences in naming add up too. Those are minor things that have been
present from the start, but then when I start getting emails from people
saying my software is messing up and I find out it's just that the latest
version of PHP totally broke something I'd been relying on, that frustration
is amplified tenfold.

------
sophacles
Hah, just be careful, having to go back the other way is kinda painful. I keep
a file for myself called pythonisms.php in it i define a few functions that
let me continue to think in ways I've come to love in python. One example, the
get function. It takes 3 arguments, and works like python's dict.get(). I
seriously have no idea how I did php without it.

------
ivankirigin
I'm going in the other direction right now. I have a sheet of notes titled
"PHP WTF". Seriously, PHP is such a mess. Thank Jesus for Thrift
<http://incubator.apache.org/thrift/>

------
electronslave
As a former academic gone mercenary, I love that programmers of all skill
levels can get into organization, language and specification through Python.
It's a wonderful gateway to learning, and in this case, it seems to have done
exactly what Python was specified to do!

For my own projects, I've used pretty much all the fad languages from BASIC to
Pascal to C. I've used industry-adopted languages like Tcl, Java and Perl.
I've experimented with Lisp and Erlang.

After all is said and done, I like Python/Cython/C. It gives me the option to
use a glue language for the Windows programming I've done, which is perfect.
It gives me a compiled (albeit ctypes-restricted) subset language for writing
hashing/storage/whatever functions. It gives me a super-awesome library set
that comes built-in.

I know it'll go away someday, but I'm glad to have worked in Python for as
long as I have.

~~~
hristov
You must be old. Basic hasn't been a fad since the 80s.

~~~
gaius
I assume he means VB(.NET).

~~~
electronslave
Now that this conversation is closed up, I'll date myself further. I do not
mean Visual Basic (nor Victoria Bitter.)

