It’s official: Javascript sucks harder than PHP

The surprise outcome of last nights webtuesdayJavascript sucks harder than PHP. I still can’t quite believe it.

Maarten took the PHP corner against me in the Javascript corner, both of us shamelessly advocating each language under various headings – 1 minute max per topic – no outright lies although often bordering on truthiness. Verdicts provided by the audience, based on who could shout loudest from a choice of “OK – 0 points”, “Annoys – 2 points”, “Sucks – 4 points”, “Sucks hard – 6 points” and “Blows – 8 points”, with help from the Suckometer (thanks to the Net-Policy team for QWizard).

Now this might not sound very scientific. For starters, how can you compare PHP (server-side) to Javascript (client-side) – apples to pears? But it’s not quite so black and white, as you’ll see from the slides – there is server-side Javascript just as there is client-side PHP. And if you ignore that distinction and focus more purely on their respective merits as programming languages, there’s plenty of room for comparison. Meanwhile you might argue that a secret ballot is essential for impartial rating but that misses the opportunity for one angry coder to remind everyone just how bad it all is.

And we had some very experienced hands in the audience (many knowing both languages intimately as well as Java, C, C++, Ruby, Perl etc.) but still stunned by the final verdict: that Javascript sucks harder – I thought I’d clinched it with CSS selectors for dependency injection but by using a negative rating system, hype and buzzwords were quickly slaughtered – it became a process of catharsis in which the “winner” was the one that came out hurting less – this is the new language advocacy! ;)

Many thanks to our hosts Amiado.

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.

  • Patrice

    I still believe the result is wrong. ;-)

  • http://www.ramiro.org devberlin

    I am not surprised by the result. I would like to see other comparisons too:
    Ruby vs. Java
    Perl vs. PHP

  • http://www.phpism.net Maarten Manders

    JS is better but I just couldn’t lose! Forgive me! :)

  • http://www.phppatterns.com HarryF

    I would like to see other comparisons too:
    Ruby vs. Java
    Perl vs. PHP

    Yeah well we may just be headed in that direction of almost endless possibility, should we fail to find other more relevant topics.

  • Michael

    Languages comparison sucks even harder than JavaScript. Choose what works for you.

  • CrucialWebHost

    How do you “choose what works for you” though? I realize it’s an apples to pears things, as mentioned, but is there really even comparing the two? I mean, the choice is obvious. When’s the last time you saw a bulletin board system done in JavaScript? A form processor? A shopping cart? You get the point.

    Then again, I guess the article was done to showcase the language itself, e.g. the syntax. While we’re at it, let’s compare tables to table-less designs *rolleyes*

  • Maxime Rousseau

    LOLOLOL Javascript sucks harder because nothing sucks in PHP. BOOM! Take that silly javascript.

  • http://diigital.com cranial-bore

    I was going to click a link to learn more about this, but which link? For the love of god…which link….
    :)

  • http://www.finalwebsites.com olaf2

    What ever…
    You need javscript to access your html and CSS on the client-site, you can’t do that with PHP. That’s why this comparsion is useless, I think the best case is to use them together!

  • irkengir

    Consume with a pinch of salt I think.

    I code in PHP all the time. All day long at the moment, 12 hours days. I dabble in JS a bit, although I have read a book on it pretty much cover to cover.

    I believe PHP is a good (not great) language and probably the best programming platform ever. JavaScript is not far at all from being a great language but very poor platform indeed albeit with great potential. Now that these browser abstracting JavaScript libraries are becoming popular the JS platforms are improving. I think that turns the table some what.

    JavaScript is probably the most important
    language in the world today.

    — Shockingly I find myself partly agreeing with this and I should think more so as JS’s user base increases, the language matures and all those hundreds of great XML based technologies the W3C has on the drawing board start to appear inside browsers. I’ve got my eyes on SVG and XForms.

    Yeah well we may just be headed in that direction of almost endless possibility, should we fail to find other more relevant topics.

    Heh, can’t wait!

  • Twalker

    What exactly is it that they suck? Or blow? If it’s what I think it is perhaps we could have a better analogy? Although i’m not entirely against that.

  • Steve100

    Javascript is alot harder than PHP especially when it involves AJAX

  • Sjoerd

    Javascript is better because you can get the user’s input with it both when the ‘program’ starts and while it is running.

  • http://www.web-development-blog.com olaf2

    @Sjoerd,

    but you still need the server side since everyone can unable and manipulate the client side…

  • Sjoerd

    @olaf2,

    But the same checks you make with Javascript on the client side before sending data back to the server, can be used on the server side with JScript, so you don’t have to create each function twice. :)

  • http://www.web-development-blog.com olaf2

    Sjoerd, what if you’re using a non windows platform?

    I remember a lot of asp.net programmers which never use javascript on the serverside…

    but this is goeing in the wrong direction it was about php and JS

  • kyberfabrikken

    But MochiKit makes javascript suck less. So that should even the scores.

  • vance Dubberly

    Ya no. The problems with Javascript are predomenantly the the interpreter written by the various implementors. The language spec itself is weird but good. PHP is rotten to the core. Both the language and the interpreter are complete crap.

  • http://www.web-development-blog.com olaf2

    PHP is rotten to the core.

    funny, most of the websites and applications are using this “rotten” language (also this blog)

  • martin2001

    Great experiment I think? Is there anyone out there willing to teach me how to upload a preloaded php site onto my server? I am just starting to learn about php and I want to buy a script and I can’t figure out how to go about making it live and how to change pages, etc. I am a newbie with NO idea what to do. Is there a tutorials anywhere on the net with newbie instructions? Thanks for ANY help what so ever. I hope that this is the place I was supposed to ask questions about php and if not please forgive me and set me straight. Thanks again Mrs. or Mr. Moderator! Jim

  • http://www.web-development-blog.com olaf2

    @martin2001

    this is not the place for that kind of questions (you will never get an answer, perhaps).

    Try the support forums here at sitepoint or somwhere, if you’re looking for php tutorials search google for “PHP beginner tutorials”.

  • stu

    considering JS is a functional language and so much more powerful compared to php…

  • Mathachew

    They’re both good languages. Period.

  • http://macosbrain.com macosbrain

    i know this for years. that is the real evidence. thank you :-)

  • Alex Ries

    Nice way to compare stuff that you can’t really compare hehe. Anyway the more I have worked with real programming languages for webdevelopment –Java in the form of JSP and c# in the form of ASP (.net ofcourse)–, and the more PHP is becoming a two faced monster with their somewhat (excuse the phrase) half-arsed implementation of object oriented programming –a good example would be the whole type-hinting facade– the more I tend to go towards jsp and asp…

    I used to be a fanatic PHP scripter even though I did plenty of programming in other languages (not for web purposes) and sure it’s alot easier than anything out there, just due to the un-intuitive (to me) implementation of OO in php 5 there isn’t really any IDE that actually knows what to do with those objects that just ‘somehow’ arrive in your included php files.

    javascript is finally advancing into something real and not a could-have-been language. A few years ago noone wanted to even really touch javascript –mostly due to microsoft’s implementation of jscript. Now with the AJAX-hype things have been looking up though.

  • http://www.preferatele.com bumbescu

    I’m using php / mysql to store over 15.000 articles and it works better togheder.

  • Cameron

    I’m not intending to be argumentative – just want to hear some opinions. What are the gripes people have with PHP? You can be quick and lazy, or super structured. You can make your scripts object oriented, or choose not too. Just about everything concerning form is entirely up to the designer. And the API is pretty great.

    The only potential disadvantage I can think of is the fact that variables don’t have to be declared, causing a larger chance of semantic errors (variable typos that aren’t caught). But then again you can make PHP catch this stuff on almost any server configuration. So what are the disadvantages you all have? I’d love to hear input. Thanks!

  • Colin

    Disclaimer: my day job is PHP and JS and I know them in and out in every way. I honestly think that both JS and PHP suck hardcore as languages and I defend neither one. However, they have their place.

    What are the gripes people have with PHP?

    Where to begin? (Random order of my gripes about PHP that I can think of off the top of my head.)

    First, you have to escape HTML with <?php tag. This not only clouds business logic with display but it encourages mixing them.

    Second, PHP’s weak typing means you can easily run into issues because the language does not let you declare your intent. Perl’s == vs. eq is in the right direction.

    Third, PHP has no namespaces and, my last count a week-or-so ago, has 5,312 functions thanks to all the modules/extensions.

    Fourth, PHP has no naming consistency. strpos vs. str_replace.

    Fifth, PHP has no argument order consistency. in_array($needle, $haystack) vs. strpos($haystack, $needle).

    Sixth, unknown tokens are assumed strings. Consider define("MY_FOO_DEFINE", 10). If you accidentally use MY_FOO_DFEINE it will assume you want the string “MY_FOO_DFEINE” and continue on.

    Seventh, it has forking (pcntl) but absolutely no locking ability. (I write off-line PHP scripts that utilize my app’s classes.)

    Eighth, single inheritance on classes.

    Ninth, lack of operator overload.

    Tenth, references/aliases. They blow. Especially prior to, I forget exactly which version, 5.1 where objects were copied which made it insanely tedious to make sure all of your aliasing (adding & everywhere) were done right. If you miss a single one then you get a copy. Without pointers and a good debugger, this because nigh impossible to track down.

    Eleventh, magic quotes. They promote laziness. Glad to see its slated to be removed in PHP6.

    Twelfth, no one needs native unicode. Right?

    Thirteenth, PHP has no official spec. It’s just whatever the developers feel like doing and adding (which I assume is the root for naming inconsistency and many other gripes of mine).

    Fourteenth, PHP lacks good debugging and profiling support. I’ve attempting to use a couple debuggers including Zend’s debugger but they all lack or didn’t work. Introduce AJAX into your app and things get worse.

    Fifteenth, complete and utter lack of objects for dates, strings, arrays, etc. No operator overloading exacerbates this. It would be very helpful to have $arr->in('foo') or $date->incrementDays(7);. Heck $file->write('flooby'); for files would be nice too.

    Sixteenth, the arrays make combining lists and hashes into one data type but it becomes a chore if you specifically need one and its respective semantics.

    Seventeenth, functions aren’t objects which means you can’t pass functions around. Creating an anonymous function with create_function is a joke and a hack to get around this problem….kind of.

    Eighteenth, no late static binding (google it). Still.

    Nineteenth, all of my interactions with the development group have been the opposite of stellar. The common response is a quick, terse, copy/pastes response and goes something like “that’s not a bug, it’s a feature.”

    That’s about enough I think. For what it’s worth, I do have a list of things I like about PHP but you didn’t ask. :) In particular is the breadth of database support. I had trouble finding mysql support for Python and when I did (mysqldb module) I found out that it forces cursors for every query and it breaks when trying to do something (sarcasm) complex like joins.

    PHP has its place and I hope it stays there! :)

  • Anonymous

    Good Lord, please fix those javascript tickers that websites love to use, that my computer hates to be subjected to. Fans and processors overloading until I turn the darn javascript off in the preferences. Then everything returns to cool, quiet, and normal. You really need to address this problem.

  • Pete

    I am fairly new to web programming, but I would say php is the dogs do da’s. Its well suited to working with mysql, very fast, reliable more secure than javascript too. Obvoisly for animations javascript wud be needed, but other than that I wud prefere to use php. Dunno whoever said you cant use php with html and css, maybe they was confused just because its server side. Also php is much more browser friendly such as for hand held devices and screen readers etc…

  • Joe

    I use php and js seemless pages, html form submits target an iframe and the php does the computing, spits out the result html.. in that i do a JS to take it back to the parent.document

    BOOM Seemless… Without the other language php is just php and js is just js… together, looks like an C application or java application seemless

    parent.document.getElementById(‘div’).innerHTML = document.getElementById(‘div’).innerHTML

    ajaxy

  • Daquan Wright

    I am a beginning web developer and have a few years experience with xhtml and css. I can say that I’ve attempted to work with JavaScript, but didn’t like it. Worked with PHP and fell in love with it…

    First off, People can disable JavaScript. This alone can cause huge problems if your website is too reliant on JS. Second, JS often is the cause for so many websites not being able to validate. I especially go to websites that have both JS and PHP in them….I try to validate them and sometimes they have hundreds of errors.

    I’ve tested this myself and I know inline JavaScript is the cause. Now if JS stays in the “head” tags or external sheets, I think it’s much better off. I find PHP versatile and effervescent in it’s glory for invention. I have three books on it and I plan on mastering this baby. I definitely think PHP is the hardest thing I’ve tried to learn and I have to say that only makes it worth it for me.

    Both JS and PHP have their good sides and down sides. Personally, PHP is more versatile and more compliant to web standards.

    But what do I know, I’m just a beginner eh? :)