10 ms·
Joe Stump: Why I switched from PHP to Python
- tdziuba 17y agoSweet jesus that header is annoying. I hope he gets slugged in the gut by a mugger on his way out of Whole Foods.
- sophacles 17y agoHah, 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.
- zokier 17y agoDoes one really need to explain why he switched from PHP to anything?
- sophacles 17y agoThis 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.
- deleted 17y ago[deleted]
- igorgue 17y agoWell, I'm actually in the same problem, but I inject Python every time I can, because is not the same saying: "Can I do this in Python?" than "I already did this in Python!"
- aristus 17y agoThat often works, but if you don't then teach others on the language and your code it will get ripped out the minute after you leave.
- jrockway 17y agoWell, 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.
- rbanffy 17y ago"Anything you can do in Python you can do in Perl just as easily" I can't read my Perl code from six months ago like I can read my Python code ages ago. There are far too many ways to do the same thing in Perl, not every one of them obvious. And I disagree with my past self a lot.
- deleted 17y ago[deleted]
- kingkongrevenge 17y agoI'm always a bit puzzled by these claims of unreadable perl. Go find me perl I can't read: http://search.cpan.org/ http://search.cpan.org/ . Where is it?
- plinkplonk 17y ago"I'm always a bit puzzled by these claims of unreadable perl." unreadable for the claimants not for you. "Go find me perl I can't read .. Where is it?" Any language, no matter how obscure, will have some practitioners who can read any code written in it. I am sure someone can say this about APL "What do you mean APL is unreadable? I can read any APL code fragment". To repeat, they are saying they can't read it not that you can't. Don't take it personally. Use what works for you.
- 17y ago
- ojbyrne 17y agoIt's all about the self-promotion. Joe works hard to get his image out there.
- quizbiz 17y agoI still don't understand why php is so frowned upon here. Easy and quick implementation and a low learning curve.
- jamongkad 17y agoSpeaking as someone who is tangled in a love triangle between Python and PHP. I do agree that PHP does have it's strengths. For the programmer just making a living, it's quite ok to etch out just using it. In terms of web applications, what you can accomplish in PHP you can pretty much do in Python. But the difference comes in when you do "care" about the tools you're using. When you want that extra power. When you want something sane to work with. Python and friends give provide that for you. I do love PHP, it's deployment is a snap and the frameworks we have now are kick ass. But Python is such a joy to work with it. And the longer I work with it, it gets harder to come back to PHP.
- jacquesm 17y agoI'm at the stage where the temptation to use PHP for something quick & dirty (a one-off script or so) is still very strong, mainly because I know all the details by heart and can pretty much realize the script as fast as I can type it in. In python it would take me a bit more time and that time is not always available. But the future is clear to me, no more PHP if I can help it. There are plenty of things that irritate me about python, but they are mostly things that you learn about, then it stays learned. PHP keeps throwing up new ways to trip you up even after years of using it. In a way I'm glad to have gone this route, in spite of the learning curve with python (and Django), I can already see it pay off when I see functions shrink to 1/3rd the size they were using PHP. The only thing really still missing from the python under apache model is a multi threaded shared state environment. That would really allow you to blow other solutions out of the water in terms of speed. Now you still have to make that round trip to the database on the next page fetch.
- zaidf 17y agoWhat python framework do you use?
- electronslave 17y agoAs 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.
- timwiseman 17y agoI know it'll go away someday, Aside from the obvious that just about everything will go away someday, is there a reason you believe this? From my vantage point (albiet limited) python looks like it has staying power. It is easy to use, effecient enough (and with unladen swallow in development it may get a lot more effecient soon), and currently seems to be gaining ground instead of losing. Eventually I am sure that it and any other language you can possibly name will get supplanted, but I am not aware of any particular reason to expect that any time remotely soon.
- electronslave 17y agoFrom my vantage point I might have dated myself above by mentioning Tcl and Pascal, but I've been programming for a few decades. Without ruining the cosmic punchline: all things go away surprisingly fast.
- kragen 17y agois there a reason you believe this? http://en.wikipedia.org/wiki/Anicca http://en.wikipedia.org/wiki/Anicca python looks like it has staying power So did the Roman Empire, JOVIAL, FORTH, and PL/1.
- steveklabnik 17y agoWhile 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.
- msie 17y agoI don't like assignment during comparison either. I do like TCO and ++.
- steveklabnik 17y agoI _love_ assignment during comparison. shrug I coded too much in C. I like all four!
- ojbyrne 17y agoThe particular comment about not enforcing private vs. protected reminded me of php4. People bitched and moaned about it.
- hristov 17y agoI 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 17y agoThat's true; Guido only says that TCO isn't going to be written into the Python you download at python.org.
- lux 17y agoYou 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 17y agoPython 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 17y agoI'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.
- ivankirigin 17y agoI'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/ http://incubator.apache.org/thrift/