Constantly, and only in Python channels, I hear the argument brought up that “PHP is <insert random insult>” or “<N> is a PHP developer so he must suck”. One of the things I hate most, is stereotypes, based on false information. Stereotypes about people from Texas being rednecks are ok, because it’s true. Now, let’s get into this a bit more.
PHP is thought of as a poor language because:
- Namespaces are nonexistent.
- There are 80000 globals.
- The language is very lazy in its syntax. You can code in at least a dozen styles.
- You haven’t used the language but you like to troll.
- [insert a hundred random reasons]
Now while these are VERY valid points, this doesn’t make PHP a horrible language. Let’s take a look at something like Perl. Now, I’m sure I’m going to get an earful for this, but it’s completely fucking useless. It’s not good for web apps, it’s outdone for shell scripting, and it’s not very useful as a scripting language (relative to other, more useful languages, such as LUA). PHP also has an extremely high availability, and is relatively simple to deploy. Python doesn’t, and isn’t (each site needs it’s own configuration to an extent).
The fact of the matter is, PHP tends to attract more unprofessional developers, and younger developers, because it is so widespread. If Python was the same, you would be able to talk just as much smack about it as you do PHP. So more to the point. There is nothing wrong with PHP or PHP developers.
And yes, I write both PHP, and Python, and I excel at both, but I prefer Python. So please, educate yourself, and stop talking shit
(For the record, no one has said anything bad about my PHP code, I just get tired of hearing the opinion “PHP sucks”.)
Correction: I wrote this hastily, so let me correct myself. I don’t mean in by any shape or form Perl sucks. What I meant to say, was it’s completely outdated. There haven’t been any *real* updates to the language in quite a while (correct me if I’m wrong).

24 Responses to "PHP vs Python — Where Opinions Aren’t Wanted"
Constantly, and only in David Cramer’s weblog, I hear the argument brought up that “Perl is ” or “ is a Perl developer so he must suck”. One of the things I hate most, is stereotypes, based on false information. Stereotypes about people from Texas being rednecks are ok, because it’s true. Now, let’s get into this a bit more.
(For the record, no one has said anything bad about my Perl code, I just get tired of hearing the opinion “Perl sucks”.)
Completely wrong. PHP sucks. I’m a very strong developer with strong background in C, C++, Java, Coldfusion and Python. When I needed to write a web app I opted for PHP 5 because it was supposed to be wonderful with OO features and lots of the warts removed. It took me six months of evenings and weekends to get 50% of the app working. I switched to Django and Python and had a production Version 1. The win was assisted by Django’s ORM, but the mostly the consistent language structure and library format of Python.
I will never go near PHP again. Facebook and Yahoo can keep it.
Ok Evan, good point
What I meant to say, was it’s a much superior language, in terms of functionality and deployability, for what it’s designed to do, than some of the alternatives, such as Perl
Zonk, maybe you’re just not good at PHP?
>> And yes, I write both PHP, and Python, and I excel at both
Are you sure about that?
No
But I am sure about the PHP part, still fairly new to Python
hehe … could be. Anything is possible, but I’ll fall back on Occam’s Razor as my defense.
The thing is, there is nothing wrong with blaming the language as the source of the problem. Perhaps the reason PHP attracts young/noob/bad developers is because the barrier to entry is so low with respect to structure and design. A PHP file *usually* equals an HTML page. But that rule of thumbs breaks pretty quickly.
As a professional developer you come to expect certain things from your tools. Consistency is one of them. Consistency of language constructs, of exception-handling, of file/socket/stream handling. PHP seems to go out of its way to trip you up. Python isn’t perfect in this respect, but it’s certainly *much* better.
All the time I was using PHP I kept thinking “This is like the QWERTY keyboard. The worst possible design which evolved slowly over time. Sure I could get good at it if I keep pounding my head off the bricks; but do I want to?!”
I don’t draw the conclusion that because PHP is bad that it implies PHP programmers are bad programmers. I don’t care about the other developers. I want my project to succeed.
PHP, as a language and set a libraries, makes me inefficient and I don’t want to get used to wearing a hair-shirt.
Hi,
I’ve been into PHP for almost two years and discovered django a week ago and love it so far.
I personally feel that PHP is still good for quick and dirty projects and can also be used to build larger ones. In a way, it almost builds character compared to python. (http://xkcd.com/409/)
Zonk, comparing your productivity as a new PHP developer to your productivity developing in Django is apples to oranges. Use a PHP web framework at the least for your comparison. Even then, it’s hard to distinguish between the gains you made because of PHP versus Python and the gains you make because of framework X versus Django.
I personally prefer python and Django for my web application development productivity, but that it took 6 months for 50% of your PHP app and you just switched to get a version 1 doesn’t make much sense. As someone converting a PHP5 MVC (Smarty with “custom” ORM) over to Django, my experience is that Python is more fun and looks better than PHP, but Python does not turn me in to some super-productive machine compared to PHP. There are bad developers and bad applications in both.
@Wes,
I agree with your point. I was a little concerned that my message would be misconstrued by the mention of Django.
The reality is that I feel I was comparing apples to apples. I used Smarty as my template engine and admitted that the Django ORM was a great gain. I should also mention that I was struggling with InnoDB on MySQL for transactions under the PHP project and switched to Postgres for the Python project … which was also a speed up.
David started with a pretty good list of problems with PHP and I’m sure a quick google would find the rest. I won’t repeat them here. But PHP started as a Coldfusion/ASP alternative for HTML pages and then tried to evolve into a standalone language. It has too much historical baggage to do that effectively.
I agree as well, PHP has taken on a lot of baggage because of the way it started things off. Hopefully they get their act together with PHP6 and get some decent namespaces
I’m in the position where I get to choose my language most of the time, but there’s legacy code, and I have a lot of projects in PHP as well as Python, and then a bunch in JavaScript. Going back and forth is a pain in the ass, but it also makes you realize how little the difference is sometimes.
who cares? why would you bring this shit up. Apples and oranges people. Different use, different market, different everything. Everything has a time and a place.
I suspect at least part of the reason Python people talk smack about PHP is that a lot of them are PHP refugees.
At least in the Django circles I think a lot of people came to Python because of Django and had previous web dev (PHP or Perl) experience (myself included: but see also David Cramer :), Simeon Willison, Paul Bissex, etc).
As a former primarily PHP dev I resented all the anti-PHP sentiment that floated about. I’ve got a CS degree. I wrote a framework that got out of the embed-php-in-html/one-file-per-url paradigm pretty early on… I did take security into consideration, used OOP when appropriate, made heavy use of PEAR libraries, etc etc. All that said - Django is so much cleaner than my old hand rolled framework and Python as a language is so much cleaner and more powerful than PHP - especially the PHP4 many devs targeting shared hosting were still on a year ago. And the Python community is much smarter in my experience.
That sort of experience leads (for some) to the need to talk down PHP. If I used to use PHP and switched, it must suck, right? Or if I know lots of people who abandoned PHP, it must suck, right? I think that’s at least part of the reason Python people talk down PHP more than others (say Perl people) tend to. Of course there are a lot of Rubyists who feel the same way for the same reasons…
@Zonk
That’s fine because not everyone working with PHP find them PHP-competent. When I worked with PHP at the
You are apparently not good at PHP.
first time with Java background, I found that PHP is so messy. It turned out that I was wrong because I was not competent enough. I chose a
messy way to work with PHP and I took my personal experience to claim that PHP was messy. After 5 years working with PHP, I found that my
approach to software development in PHP was not relevant any more. I found I needed to change my way of programming instead PHP needed to
change. Smarty sucks. Page-based web development sucks (not mixing PHP with HTML sucks. It doesn’t suck at all, really :D). As of 2006, I used
Front Controller to work with PHP in web development and it rocked. A tiny PHP code (foreach, while, if, date, for, echo and few other OOP
helper code) mixed with HTML to build template pages making them very maintainable and extremely easy to build. Page-based web development
abuses that kind of mixing logic and html but front controller-based does not. It just likes using Servlet with JSP but in Java you have to
care about the difference in nature between JSP and Servlet. In PHP, it is just Plain Old PHP. Smarty sucks.
In conclusion, you should never use PHP in messy way and say it messy. PHP is too flexible and easy to be abused. PHP is a general programming language. It does not encourage you to use it this way or that way. Frameworks do.
Regarding to inconsistent function naming, I don’t care. Code completion rocks. Eclipse-based PDT rocks.
Regarding to PHP namespaces, I can tell you that there are some way to simulate namespace in PHP 5.2–. You can see it in Zend Framework,
SolarPHP framework. If you really care about built-in namespace in PHP, you can download PHP 5.3 from http://snaps.php.net and try it. This
feature is available at the moment. Don’t wait for PHP6 if you don’t have to work with Unicode everyday.
There is a fact in PHP world that you don’t ever need a MVC framework to make your web development more discipline. You can create a tiny one at any time without any special skill because it is so easy. Zend Framework is too bloated. To Python world, it is different, right?
On Python
I find that I am easily annoyed with some Python features.
The fact that Python avails white spaces as part of variable scope and block separator makes it annoyed a lot, especially when working with
HTML. To do it, you need to use a different template language to mix template logic code with HTML code. It is not OK all the time. Th fact
that having to use another DSL language to make Python work with HTML more easily does not satisfy me.
Python white spaces make me think that I have to come hack to VIM instead of using decent IDEs with features like bracket matching, code formater, bracket highlighting, code collapse….
Also, having to assign lot of “self” as method parameter makes Python a bit poor OOP language. Why not use keyword “this” (or “self”) and make
it available in class scope automatically?
Also, there is not true PPP (public, private, protected) in Python making someone unsatisfied, not me.
In fact, Python has a broader set of APIs in system programming, compared to PHP but it is not as relevant or flexible as PHP in web
development. PHP has broader convenient APIs to deal with web page processing because the team behind it has invested lot of effort in many
years to create and test them.
No language is perfect in its design
You list two serious problems with the design of PHP (globals, lack of namespace) and then state that nothing is wrong with PHP. And the fact that you think people can get more work done with Lua than Perl just shows how far you have your head up your own ass.
Perl completely fucking useless. It’s not good for web apps, it’s outdone for shell scripting, and it’s not very useful as a scripting language??????
Please tell that to a gazillion bio oriented programmers who can’t live without bio-perl, catalyst, cpan and all the perl based scripts, api’s etc etc.
Don’t forget, a lot of python modules found their roots in perl modules. Don’t get me wrong. I mix python, c++, java and perl for the above but to classify perl as fucking useless is a slip of the tongue at least.
(you might have noticed I banned PHP from the above
PHP is a horrible language. It doesn’t mean that one can’t build good PHP-based web apps. It’s horrible, but it’s dead-easy to deploy and host, has lots of libs, and lots of coders.
No. You are wrong. PHP sucks.
Just kidding. I think it is great that ‘non-professional’ developers get into coding, if they do it via PHP, great! They will learn about more advanced languages as they traverse the software universe. It’s all good. Would I use PHP (anymore)? Never.
PHP sucks. It does. Find a single programmer experienced in both PHP and python that would vouch for PHP. Find a single programmer that gleefully switched from python to PHP!
I have programmed a lot on PHP with symfony, one the best frameworks for PHP.
I programmed much less with python for the web but i’ve been MUCH more productive with python and django.
PHP has never been created for big frameworks. At best it’s a botched up templating language if you want to add some dynamic features to an existing HTML page. Doing big sites like facebook or yahoo in PHP is just asking for troubles.
If you tell people who think that python is better than php that they are not good at PHP you completely miss the point.
Lastly, I hate the of arguments of the type: “well, no language is perfect and every language has his plus and minus sides”. This kind of reasoning will get you nowhere. It is true that python and, say, ruby are comparable and similar. It is true that python is neither better nor worse than C because they achieve different purpose.
But it is true that python is much better than PHP. Why not admit it?
Take a look at this..www.qcodo.com. I agree that PHP usually is a frikken mess, but qcodo makes it beautiful.
I have been a programming for more than 25 years. I have programmed professionally in Basic, Fortran, several Assembly languages, Pascal, C, Perl, Java (i’m a certified Java programmer), PHP, Javascript, and Python.
The language I like the LEAST is PHP (Basic and Fortran aren’t too hot either, but they’re old… like me :). I would take Perl over PHP ANY DAY! But my Favorite language is DEFINATELY Python! Python and Django are GREAT!
I am late to this patty (php programer) after 27 years programing (basic,dbaseIII,clipper,etc.)
I have been searching about ruby and python because the fact there are many things about php that just make programing sometimes really hard. Yes, there was a big step on the kind of OO, and error handling routines in recent PHP releases, but late.
All languages have obscure sides so there are many ways to compare them, all have bugs, the lack of good documentation, etc. But from all the winner is PHP with its horrible syntax.
Now, I know PHP is the winner (popularity) but even if it were the number one in OO, the fact is that 90% or more of the PHP programers do not use or know about Objects, and of course if you check more than 90% of the php opensource apps, are only functional, not OO.
By nature, 80% (my experience) of the php programers will never use Objects as neither relational databases and neither transactions. It took 10 years for programers to start using SQL, the same will take for php programers to start using Objects, relations and transactions. So only the real programers (redbones) and the new kids in town are getting into the wagon of OO, and in that case Ruby on Rails is to this programmers what was PHP3 in its conception in the past. So the point is, Python is the programing language for Experts, but the only chance for Python to get the popularity and support needed worldwide to get a better position is through Django, otherwise, the unstable, inmature, webtoy of Ruby on Rails will be the programming language (framework) of preference in the years to come. Either way, if you need formal, comercial, trouble free applications, you need Python, because it has already solved many problems and is stable in really hard situations. Not the same for Ruby, up to this days still have serious problems about memory, threads, networking, etc. It seem they are working on that because of Rails popularity, but it takes time, and that not counting on the serious problem of Rails itself. When PHP 6 will be ready to the level of Python? Never, because it is funcional from inside, it will have always many barriers to be ported to a 100% OO environment, and remember, they have to support more than 50% of the todays web applications working already. Why Python? please change that name, I don´t know, maybe Cobra would be a better name.
I know many languages, but for me PHP is what “C” should look like. “C” idea and future has been destroyed by “pointers”.. PHP does not support this feature and… it works.
I don’t understand where you see PHP syntax problems. For me it is so clean, almost as Pascal.
There is a lot of messy PHP code on the net, because it is popular and can be used by amatours… because it is easy to learn and productive too.
There are a lot of good frameworks for PHP, including CakePHP, you should try it before judging it.
I agree with Oscar Duron that it can be a problem to introduce OOP in a large scale to PHP world. In Object Pascal OOP was the only solution, so there was no possible exception (Turbo Vision). In PHP you can even have problems with finding good structured code (functions) because you can mix HTML with PHP. But it doesn’t mean you cannot do it correctly by yourself.
Python has many nice features - I’m not using it, but I have read many articles about it. The only thing I really hate in this language that stops me from trying it is it’s positional syntax (white space shouldn’t mean anything important).
@pcdinh
see pydev for Eclipse, includes code completion for python.
In PHP’s defence it has (many) rough edges but it came be written used properly, Zend Framework provides a very good MVC implementation and web applications can be written entirely OO. That said of recently started using Django.
For my latest project we started with PHP5 + Zend Framework after we had a simple prototype we where not entirely happy and have since ported the application to DJANGO. I’ve only been using it for a week, but I don’t think php will ever get a look in again.
Another big thing that has yet to be touched on here is that in a large scale web application there is always going to be a requirement for background processing, be it triggered by the db or a cron job, while php can technically be used for this task Python is a fair better solution. Personally I’d rather stick to one language for a project so just on this point PHP not an option.
Leave A Reply