on May 20th, 2008PHP is the new VB6 in a C dress

I love programming, it’s that part of my life that let me express all these crazy ideas I get. Most of my work is done in PHP, and has been for a long time - there’s a simple explanation for that; Where I live (Sweden) PHP has had an incredible boost the last few years, I’m literally drowning in job propositions and there seems to be no end to it. This rise in popularity for PHP comes from a couple of key factors, at least from my point of view: It’s cheap, effective, stable and runs everywhere. But, I’m digressing now - this post is about the simple fact that programming should be fun. PHP is not fun.

Every solution I’ve ever seen or developed in PHP feels clunky and bulky, there is no elegance or grace. Working with PHP is a bit like throwing a 10 pound concrete cube from a ten story building: You’ll get where you’re going fast, but it’s not very elegant. There’s no doubt you can build any website with almost any language, this is no post about “You can’t build X at scale Y with language Z”. This is about having fun while doing it and not feeling hindered by the tool you’re using.

There are a couple of problems with PHP from my point of view, and please put an in-memory <em> tag around the “my point of view” part, because this really is my point of view. First you have all the standard complaints, which all of them have good merit: dollar sign for variables, usage of -> instead of . as the receiver operator, inconsistent naming of functions, inconsistent argument order. These are all things you can live with.

However there are things you can’t live with, such as: Old and out-dated object model even though it was released as recently as three years ago (why didn’t “they” give us a fresh and fun object model when they decided to change so much from 4 -> 5 anyway), Anonymous function syntax being so horribly broken I never seen anyone use it, No support for closures, No namespaces (they are coming yes, but given the slow adoption rate of new PHP releases I’d say there’s quite some time before we can use them for real things), The usage of the array() for creating arrays, making the usage of nested arrays ugly and cumbersome.

There are more subtle problems also, things that most people don’t think of right away, for example returning an array or string from a function requires you to store that in a variable before using it, here’s an example:

function test() {
  return array(1, 2);
}
echo test()[1]; // Does not work

$a = test(); // This
echo $a[1];  // Works

The above example applies to everything except object references that you can, for some reason, chain calls on. Then there’s also the problem of having true primitive types which heavily conflicts with a nicely structured object oriented application. There are a couple of more annoyances I have with PHP, but I think you would’ve gotten my point by now.

If we look behind the language, there are a couple of problems - at least from, again, my point of view. The entire PHP community seem to have a serious case of “Not Invented Here”-syndrome (even Zend, who developed their entire framework from scratch, despite the fact that many of the components they have built were available from other sources long before they even thought of the ZF). The amount of O-R M implementations in PHP are almost equal to the amount of frameworks available, since they all looked at Ruby on Rails and ripped it straight of. My other gripe with the community is the amount of hobby developers offering their services for a cheap buck, pouring out sub-quality code driving a lot of projects into the ground (which then results that those of us that know how to build something properly get called in to clean up the mess, and honestly - no one likes that, except maybe the sub-par scripter that got his buck and then vanished).

My third problem with the community, is the community itself. I don’t want posts like this or blogs like this passing themselves of as good advice and good code.

Lastly, the salary - which has a lot to do with all my second grip with the PHP community, I’ll be the first to admit that I don’t have a formal CS background, but I’ve spent the better part of my days since I was fourteen or so studying computer science; everything from maths to language theory, linguistics, set-theory, object orientation and what not. This is my trade, I’m good at it. So why am I only worth half the salary of someone doing the same work in but in another language? Simple: The abundance of dirt cheap and crappy PHP script-kiddies around.

Programming should be fun, you should enjoy you work. I don’t enjoy spending my time in a semi-language with a mediocre salary and a mostly amateur-level community. Don’t get me wrong, I love PHP - I just can’t stand it. I urge every PHP programmer who’s gotten stuck in the language to go out and have a look at some of it’s competitors: Python, Ruby, Lua, Haskell, F#, Erlang, Groovy, Scala and .NET to mention a few. They will all take your programming knowledge to a whole other level, expand your mind and make you cry when you have to go back to PHP in your day to day work. For me, Python is the holy grail. It has the perfect blend of all components i consider vital. It’s also a joy to write, almost only a-z plus a simple dot and colon.

To sum it up: I love PHP, and it’s the right tool for some jobs. It’s just an ugly, cumbersome tool that makes me cry and have nightmares. It’s the new VB6 in a C dress.

47 Responses to “PHP is the new VB6 in a C dress”

  1. PHP is the new VB6 in a C dresson 20 May 2008 at 4:25 pm

    […] unknown wrote an interesting post today onHere’s a quick excerptIt’s also a joy to write, almost only az plus a simple dot and colon. To sum it up: I love PHP, and it’s the right tool for some jobs. It’s just an ugly, cumbersome tool that makes me cry and have nightmares. It’s the new VB6 in a C … […]

  2. spepson 20 May 2008 at 5:19 pm

    I agree with your point of view. I actually did some coding in PHP but it was a while ago and I never felt I was writing beautiful code. I tried Ruby recently and fell in love right away.

  3. Fredrik Holmströmon 20 May 2008 at 5:27 pm

    speps: Ruby and Python are supreme examples of good language design, sure they both have their flaws - nothings perfect. But PHP doesn’t have a flaw, it has a huge gaping fucking hole in the middle.

  4. Craigon 20 May 2008 at 5:48 pm

    “inconsistent naming of functions, inconsistent argument order. These are all things you can live with.”

    I disagree entirely!!!

  5. Chalamanon 20 May 2008 at 7:38 pm

    go back to cold fusion… you fucking designer.

  6. Fredrik Holmströmon 20 May 2008 at 7:52 pm

    Designer? Now that’s a stretch, If you’re going to criticize me or my work at least put up some decent arguments. Oh and about the tag-parser, yeah it’s sub-par and probably not my best job, but then again it was only a 15-20 minute job for a couple of friends on irc, so ye.

    Not that I think that you’re going to read this and reply to me, but yeah.

  7. Thomason 20 May 2008 at 8:12 pm

    See, for me the fun is in building something. I don’t care if my tools are imperfect as long as I get the job done and get it done well. My Mazda isn’t the greatest car in the world, and sure I could complain about it. But I get places quickly and get a great value out of the car. On the road, it’s not about who has the fastest car but rather who’s best at driving it — especially in traffic. But that’s a lame analogy and just makes me want to go driving right now. Anyway, that’s an imperfect analogy so I’ll quit it. My point is that, very often, PHP is the most efficient way to do web development, and often it’s the only way when you’re going to deploy to a shared server (and yes, I’ve built software in PHP for a couple grand that runs on a client’s shared host, so availability and easy deployment are relevant concerns for most devs).

    A programmer who’s always getting hyped up for another language when he or she can already get the job done well with available knowledge is like a hobbyist spending time drooling over the latest power tools but who seldom builds anything that basic, manual tools couldn’t accomplish in about the same time.

  8. Fredrik Holmströmon 20 May 2008 at 8:28 pm

    Thomas, I agree with you about the “best tool for the best job” - despite your weird analogy ;). I don’t agree that PHP is the most efficient tool for the job, in a short perspective yes, maybe. But not in the long run, there are no built in tools for managing, grouping or packaging code in PHP.

    And deployment? Ruby (rails), Python, Lua, .NET, Groovy and Scala all can be deployed with the same ease as PHP.

    I’m not “always getting hyped up for another language”, and I said in my original post the reason I’m working with PHP is because atm. all the web-dev jobs here in my area are in it. The first chance I get of getting out of PHP and into ruby or python, I will take it.

  9. Thomason 20 May 2008 at 8:41 pm

    My point wasn’t “best tool for the job,” it was “the tool doesn’t matter nearly as much as you think.” Just wanted to clarify that.

  10. Fredrik Holmströmon 20 May 2008 at 8:47 pm

    Oh yes, you are so right - miss-read you a bit, my bad. But the point with my post was not about tool X or Y making a better product in the end, more about that I feel that it’s a chore to code in PHP.

  11. Bobon 20 May 2008 at 8:52 pm

    Dude, you need another job.

  12. Fredrik Holmströmon 20 May 2008 at 8:53 pm

    Bob: Care to elaborate? :)

  13. in PHP hellon 20 May 2008 at 9:12 pm

    PHP sucks so bad I’m speechless. “Huge gaping fucking hold in the middle” …. preach it!

  14. Non 20 May 2008 at 9:14 pm

    Man you really nailed it. Did you have any raises since you started doing Python?

  15. Robert S. Robbinson 20 May 2008 at 9:54 pm

    You did not mention the real problems with PHP which are similar to the problems with classic ASP. In PHP and ASP you have too much code mixed in with your HTML making for a real mess. Throw in some JavaScript and CSS and you can have four kinds of code all jumbled together.

  16. Oddon 20 May 2008 at 11:06 pm

    What about a job with Java then? In Norway at least, they’re plentiful… Put Spring and Hibernate on your resume, as well as good oop foundations == job.

  17. Mikeon 21 May 2008 at 1:00 am

    So true.

    The best descriptive word that fits PHP, any PHP is … fugly, as in f****** ugly.

    Second closest would be irritating cause clunky syntax irritates, needle, haystack, haystack, needle irritates, strpos or str_pos irritates and strcspn … just wtf.

    Its not getting any better either. The syntax for namespaces in 5.3 is fugly too. :(

    It only gets worse when you misuse PHP to do long running maintenance scripts (which my current employer is guilty of by the bucket load).

    The only thing I can say about PHP that is semi-praise is it somehow promotes a “getting shit done” approach to development. The downside to this of course is the “keeping the shit you just wrote working” stage since that approach tends to produce sub-optimal design decisions.

  18. JBon 21 May 2008 at 4:05 am

    > Every solution I’ve ever seen or developed in PHP feels clunky and bulky, there is no elegance or grace.

    Are you sure it’s not just you? I mean, if you really want elegant and graceful there’s Lisp or Haskell. I have seen crap written in both. Sometimes it’s not the tool that’s broken, it’s the person using the tool.

    I wish people who feel like writing a rant about PHP would read this instead:

    http://www.tnx.nl/php

    It pretty much sums up everything you ever want to hate about PHP.

  19. Fredrik Holmströmon 21 May 2008 at 6:20 am

    N: Well, I still do PHP for my daily work (hence the rant) since it’s _very_ hard to find any work for python here in Sweden.
    -
    Robert S Robbins: Well, that is more of an older problem of PHP, now a days
    most people have a nice clean separation between their business and layout code, sure it could get better - but it always could.
    -
    Odd: Yeah maybe, why not. Don’t feel like moving to Norway though ;)
    -
    Mike: Couldn’t agree more, especially about the “getting shit done”-approach of PHP, short-term it works - long term it always ends up like a big pile of poo ;(.

    And yes sure, all the little annoyances with PHP, you could live with them one by one - but all bunched together into one language? No way.
    -
    JB: I have read that page, but I felt like expressing my own views on it anyway - hey that’s what the internet is for? Sure it could be that the problem lies in me, somehow I doubt it though.

    Take the Zend Framework, sure it’s by far the best PHP framework in my book, but when you work with it looks exactly like a weird, crappy version of Java.

    I often hear the argument “you should work with PHP’s strengths” ? What strengths? The inconsistencies ? The annoying $-sign ? The half-assed oo-model? Lack of code organization ? Lack of modern day features ?

    But maybe I was a bit out of line with the “Evere solution … “-comment, there are decent solutions in PHP, they’re just far and few between.

  20. Davidon 21 May 2008 at 7:01 am

    If you use a programming language for a certain amount of time you find it’s ceiling but i think it doesn’t mean the language is bad.

    I’ve been using php for quite some time now and i’ve found the constraints of the language a long time ago but i still discover functions that can make my live easier. I think the number of functions is too big for the fast and easy development motto the language has.

    I like the way your snippet should work but i wonder which language recognizes the output of user added functions on the fly? What if the function has different kinds of output?

    I have to agree on the “Not Invented Here”-syndrome but i think this is happening in every language that many people use. It’s easier to change your own code than somebody else’s. I think most components that are build serve one master. And then it’s hard to incorporate it into another solution.

    I think the best advise you can get is don’t php everything, every language has it’s strengths and flaws but you use it for the strengths and not for the flaws.

  21. devsmton 21 May 2008 at 8:38 am

    as VB, none likes it becouse it is too simple to show the hard p***s you got, everyone actualy uses it because it works.

  22. Elmeron 21 May 2008 at 12:10 pm

    I totally agree that it is so damn easy to write crappy software in PHP. And the sad fact is that a lot of crappy software is created by all those f*cking script kiddies.

    As for the inconsistent function naming; this is something I see all too often in open source software. It would probably help if there was a single party overviewing the roadmap for PHP.

    But I still love PHP and use it almost dayly!

  23. Josh Daveyon 21 May 2008 at 4:00 pm

    I’m so sick of these posts. We all get it. I’m a PHP developer and it’s not like I’m blind to all the short comings of my language I work with on a regular basis. You’re going to find crappy programmers in any community we just have a bigger community.

    Rails forces you into good practices as do other mature frameworks. If you start hacking away with Ruby it’s not like you’re going to write pretty code that’s automatically organized like Rails is.

    You’re comparing ZendFramework and Rails but Rails is a much more mature framework and has a much larger community supporting it. Wait until the other PHP frameworks have reached that stage and you’ll start to see more quality coming from the PHP community.

  24. scratch programmingon 21 May 2008 at 5:06 pm

    […] […]

  25. […] Fredrik Holmström […]

  26. […] includes links to several other articles that follow the “PHP sucks” train of thought too, but he notes that none of that really […]

  27. […] Fredrik Holmström: Every solution I’ve ever seen or developed in PHP feels clunky and bulky, there is no elegance or grace. Working with PHP is a bit like throwing a 10 pound concrete cube from a ten story building: You’ll get where you’re going fast, but it’s not very elegant. … I love PHP, and it’s the right tool for some jobs. It’s just an ugly, cumbersome tool that makes me cry and have nightmares. It’s the new VB6 in a C dress. […]

  28. Behrangon 23 May 2008 at 6:01 am

    I had a look at those blogs and I didn’t see anything wrong about them. I don’t know why you don’t like them.

  29. John Wardson 23 May 2008 at 8:07 am

    Huarra someone else who thinks those blogs should be hit around the head with a stick while shouting “No!”

    The…build every page with php just in case had me spitting…but I walked away…but quick point….static html apace serving page…1000 requests a second on basic box….”hello world” php/apache 100 requests a second on basic box..

    The “Gotcha” php form….Jebus wept. Html in a function…un escaped post data…..

    As for your point about PHP, yip we all laugh around the office here at the daft naming conventions sometime…whats that function for “X string handling i’ve had a look through str_” and its actually begins with something else. Who would have known.

    PHP is however our swiss army knife. Yes we could knock out websites in .NET or Python..or if we were really desperate Rails (but we’re not 12). But PHP gives us speed, power and flexibility and that is just in getting things done.

  30. Danielon 23 May 2008 at 2:09 pm

    This blog is written in php.

  31. Rockon 23 May 2008 at 3:17 pm

    Taken from coding horror:

    The TIOBE community index? It’s written in PHP. Wikipedia, which is likely to be on the first page of anything you search for these days? Written in PHP. Digg, the social bookmarking service so wildly popular that a front page link can crush the beefiest of webservers? Written in PHP. WordPress, arguably the most popular blogging solution available at the moment? Written in PHP. YouTube, the most widely known video sharing site on the internet? Written in PHP. Facebook, the current billion-dollar zombie-poking social networking darling of venture capitalists everywhere? Written in PHP.

    Notice a pattern here?

    Some of the largest sites on the internet — sites you probably interact with on a daily basis — are written in PHP. If PHP sucks so profoundly, why is it powering so much of the internet?

  32. Fredrik Holmströmon 23 May 2008 at 3:21 pm

    Daniel: As I said, I work with PHP on a daily basis and have so for a pretty long time, I still think the language as such blows.

  33. Robert Speeron 23 May 2008 at 3:37 pm

    I’m the only person I know whose primary language is PHP. I wanted to be a web developer, that’s what I started using and I fell in love with the php manual.

    I have to agree with the pay issue though, I’ve dealt with “real programmers” getting paid 10K a year more to fail at multiple projects.

    What makes PHP more like VB6 for me are things like ExtJs.com. I’ve been developing a project with ExtJs for a couple months now and it reminds me of VB6 without the IDE doing most the UI for you.

  34. thecanceruson 23 May 2008 at 5:04 pm

    funny, i used to say to everyone that “php has ease of VB6 and coding style of C” as the strength of php , that’s why i came to read this article only to find that it is just another article in series of “php sucks”.

    But who is stopping you to follow the best practices of programming in php, my bet is only a lazy developer(or the person who no nothing about) will not follow the best practices, when it is not enforced by programming language.

    Who is stopping you to do the things in correct way, in the jobs that you do.

    If we developers do the right things, why would our code suck?

    common guys stop saying php is bad, instead start doing something to improve the quality of code, if nothing else improve your knowledge about how to code.

    it is interesting to see that a language is bad because it does not enforce some stupid rule on it users. And if you miss some feature so much then use that language, simply because it is not their in php, does not make php bad.

    common GROW UP.

  35. Andrew Johnsonon 23 May 2008 at 5:43 pm

    I don’t understand how you can say that a reason to not use a language can be:

    a) stupid bloggers
    b) immature community
    c) low pay because of script kiddies

    These exist for most languages in varying degrees. I agree that all three are huge annoyances and things I wish wouldn’t happen, but to condemn a language because of them doesn’t make sense.

  36. Daniel Harringtonon 23 May 2008 at 9:52 pm

    Just found your post and had a look at all the links (post and comments). I know and live with these “shortcomings” day by day. But instead of arguing about “best language” or “best behaviour” … I’d like to ask:

    What can we (developers) do to 1) “teach” good coding standards and 2) “push” PHP development into a more “fun to work with” direction?

  37. syntax linguisticson 24 May 2008 at 11:20 am

    […] in PHP, and has been for a long time - there??s a simple explanation for that Where I live Swedenhttp://loveandtheft.org/2008/05/20/php-is-the-new-vb6-in-a-c-dress/Research and Markets: Essential Handbook of Clinical Linguistics Business Wire via Yahoo! Finance […]

  38. rubayeeton 24 May 2008 at 12:26 pm

    1) Namespaces will be there in PHP 6. The slow adoption rate of new releases is neither the fault of PHP nor the coder. Have your client update his server to PHP 6, so that he can see how “beautiful” your code is.

    2) No language is perfect and hence ‘annoyance free’. There are problems inherent in PHP, as well as in C or whatever other language you like to code. You have to wait

    3) PHP requires self discipline. It allows script-kiddies to make a quick buck and pay their rent. But that does not mean their are no high-paying PHP jobs.

    4) Lastly I am tired of hypocrites like you. You guys code in PHP at day and then go home and write a PHP bashing article, on a blog engine powered by PHP. Shame on you guys!

    PHP is here to stay. Whether you like it or not.

  39. Fredrik Holmströmon 24 May 2008 at 1:11 pm

    Rubayeet:

    1) Actually you’re wrong, they will be here in 5.3, however namespaces still only solve about half the problems you have with libraries and how to structure them in PHP - and the implementation itself is a bit quirky atm… so yeah not looking forward to it.

    2) Of course not, but - the amount of “annoyances” in PHP is staggering compared to every other language I’ve worked in.

    3) What (imaginary?) land do you live in where PHP programmers get the same pay as Java developers for example? And that a language requires you to have self discipline and construct other things that other languages gives your free, I hardly see that as an advantage.

    4) So? Am I not allowed to express my thoughts over something I work with all day long?

    Maybe it is, maybe it’s not - I sure hope it’s not (unless the php group cleans it up)

  40. chamoon 24 May 2008 at 10:33 pm

    troll detected…

  41. […] PHP is NOT elegant? The Realm of Zod argues that it doesn’t matter, it’s the community that counts. Adrian Sutton argues that it’s not the elegance that matters, it’s the results. […]

  42. Larry Smithon 26 May 2008 at 7:46 am

    I find it interesting that a script kiddie called me a script kiddie (despite the fact that I have been coding since before this kid was out of junior high). I do agree however that it is a messy language, but if you’re going to bash it like that you should run Mephisto or roll your own solution maybe? You are using Wordpress, which is written in PHP. In an ideal world we could write whatever language we want, but if you want to make money you write what your employer or clients want, period. From what I’ve experienced programming is programing, if this than that. Sorry if that comes off harsh, but it is what it is and people write about what they know, not what they don’t.

    And did you actually say that all frameworks ripped RoR off? To my knowledge similar frameworks have existed since before Rails.

  43. Fredrik Holmströmon 26 May 2008 at 1:18 pm

    Larry Smith: I can’t see where I specifically called someone a script kiddie, it was more a general term I used against all the low-cost / crap PHP developers I see every day around me.

    You seem to have gotten the same thing wrong as almost everyone else, sure I bashed PHP pretty heavily, and no I don’t like the language. But if someone can put up with it and in the end produce a decent bloging software (wordpress) I’m not silly enough to not use it because it’s written in a specific language, I just wouldn’t want to write one myself in it (but I’ll probably end up doing it anyway, what the client wants the client gets, etc.)

    I meant *most* PHP frameworks, Cake, Symfony, Php on Trax, etc. Not every framework every written in the entire world to any language…

  44. […] PHP is the new VB6 in a C dress, Ruby is a Playground, PHP is a Factory, The future is PHP, PHP Sucks, But It Doesn’t Matter, An Argument for PHP […]

  45. application framework in vb6on 26 Jun 2008 at 12:18 pm

    […] in PHP, and has been for a long time - there??s a simple explanation for that Where I live Swedenhttp://loveandtheft.org/2008/05/20/php-is-the-new-vb6-in-a-c-dress/VisualBasic.NET support - MonoIf a Visual Basic application requires COM or ActiveX controls, those […]

  46. PHP Sucks | am i works?on 01 Jul 2008 at 8:12 am

    […] PHP is the new VB6 in a C dress […]

  47. computer science a structured programming approach using c…

    It has since been implemented in most other blogging tools. Some weblog software programs, such as Wordpress, Movable Type and Community…

Trackback URI | Comments RSS

Leave a Reply