Thursday, October 12. 2006
PHP vs. Javascript: A shit vs. poo fight.
Apparently there was some kind of PHP vs. Javascript fight, to see which language sucked the most. The results? Amazingly Banal, if not downright wrong. There is the list of topics, and their scores:
The thing about Lexical Scoping and Closures, is that once you have them, then building packaging and namespaces is not too difficult. In PHP, scope is so horribly broken, that people are yelling about needing namespaces and packages, when if they fixed the scope problem, then these other problems are solved. For free.
I (sarcastically) love the idea of using Code Generation as Meta Programming (one of the 'perks' of PHP). Code generation should be your final line of retreat. If you are generating code, you may have lost the battle. It is a good tool to have in the toolbox, but it is not one I like to pull out that often.
Why? Because to get any reasonable AOP in PHP, you need to install an extension into the language. A fully functional AOP system in Javascript however, is painless and easy to write, what with first class functions and all.
To be fair, Harry Fuecks probably had his work cut out for him. How do you explain the basics of a Closure to an audience who might not know what they are, let alone what you can do with them; all in the span of 60 seconds? (psst, objects are closures with syntatic sugar, but you can't "de-sugar" and object to get a closure). If an audience doesn't understand the idea of a first-class function, how can they understand how easy AOP is in Javascript?
- Syntax: PHP - Sucks, JS - Sucks Hard
- Data Types: PHP - Sucks, JS - Sucks
- Scope / Namespaces / Packaging: PHP - Annoys, JS - Sucks Hard
- Standard Library: PHP - Sucks, JS - Sucks Hard
- Extension Libraries: PHP - Sucks, JS - Annoys
- Procedural Programming: PHP - Annoys, JS - Annoys
- Object Oriented Programming: PHP - Sucks, JS - Sucks
- Functional Programming: PHP - Blows, JS - OK
- Meta Programming: PHP - OK, JS - OK
- AOP: PHP - OK, JS - OK
- Networking: PHP - OK, JS - Sucks
- Error Handling: PHP - Sucks Hard, JS - Sucks
- Multi Tasking: PHP - OK, JS - Sucks
- Reflection: PHP - OK, JS - Sucks
- Garbage Collection: PHP - Blows, JS - Blows
- Security: PHP - Blows, JS - Sucks
- Garbage Collection: PHP - Blows, JS - Blows
- Security: PHP - Sucks, JS - Sucks
- Tools: PHP - Sucks, JS - Sucks Hard
- Server Side: PHP - OK, JS - Sucks
- Client Side: PHP - Sucks Hard, JS - OK
- Final Rave: PHP - Sucks, JS - Sucks
Syntax: Sucks vs. Sucks Hard
I fail to see how Javascripts Syntax sucks harder then PHP. In fact, in a comparison against syntax, it is a lot like comparing whether dirt from your front garden or your back garden tastes worse. It doesn't matter, it is all dirt. For syntax to be not suck, I think it would have to be more like Scheme, where the syntax is very simple and gets the hell out of your way.Scope / Namespaces / Packaging
The very idea that PHPs Scope just "Annoys" versus Javascript is laughable. Javascripts scoping is by far superior. Show me a closure in PHP, and then show me one in Javascript, and we will see which one sucks and which one doesn't.The thing about Lexical Scoping and Closures, is that once you have them, then building packaging and namespaces is not too difficult. In PHP, scope is so horribly broken, that people are yelling about needing namespaces and packages, when if they fixed the scope problem, then these other problems are solved. For free.
Meta Programming: OK vs. OK
Now this I don't get, at all. Meta programming in either language involves using eval, along with string manipulation. This is not 'OK', this is definately on the 'sucks' end of the spectrum. To get an 'OK' in this area, you would at the very least, have low-level scheme-like macros, and be able to work with a data structure related to the parse tree. See Lisp and Scheme macros for a better idea of what OK actually means here.I (sarcastically) love the idea of using Code Generation as Meta Programming (one of the 'perks' of PHP). Code generation should be your final line of retreat. If you are generating code, you may have lost the battle. It is a good tool to have in the toolbox, but it is not one I like to pull out that often.
AOP: OK vs. OK
Dead. Wrong.Why? Because to get any reasonable AOP in PHP, you need to install an extension into the language. A fully functional AOP system in Javascript however, is painless and easy to write, what with first class functions and all.
Overall
The PHP slides are a bit of a larf. A language with 3080 built in functions is also easy? A language like PHP has a simple syntax? Umm.... No.To be fair, Harry Fuecks probably had his work cut out for him. How do you explain the basics of a Closure to an audience who might not know what they are, let alone what you can do with them; all in the span of 60 seconds? (psst, objects are closures with syntatic sugar, but you can't "de-sugar" and object to get a closure). If an audience doesn't understand the idea of a first-class function, how can they understand how easy AOP is in Javascript?
Trackbacks
Trackback specific URI for this entry
No Trackbacks
Comments
Display comments as
(Linear | Threaded)
Hey, don't insult the audience :)
And trust me, most of the people there know very well what a "closure" and functions as first-class objects are.
Well, the whole evening was more meant to be a joke (and fil-in for not having a better topic) than anything which should be taken seriously...
And trust me, most of the people there know very well what a "closure" and functions as first-class objects are.
Well, the whole evening was more meant to be a joke (and fil-in for not having a better topic) than anything which should be taken seriously...
As chregu said, the event was meant as a joke - a chance for everyone to bitch and moan about two languages they're probably too familiar with.
It was also partly poking fun at some of the language wars (mainly Perl vs. Python vs. Ruby vs. Java) that have been running around recently and general over-enthusiasm happening on blogs.
The ratings system was "designed" to produce controversial results and each result was "picked" by who could shout loudest in the audience.
The slides were deliberately over-positive; omitting obvious points of suckage - Maarten and myself were there to "hype" each language while the audience had to slay us.
Syntax: Sucks vs. Sucks Hard - can't remember how we got to this. Possible via browser compatibility problems.
Scope / Namespaces / Packaging - again can't remember.
Meta Programming: OK vs. OK and AOP: OK vs. OK - in both cases this was largely audience apathy - in reality no one is attempting either in either language so "OK because we're not doing it"
It was also partly poking fun at some of the language wars (mainly Perl vs. Python vs. Ruby vs. Java) that have been running around recently and general over-enthusiasm happening on blogs.
The ratings system was "designed" to produce controversial results and each result was "picked" by who could shout loudest in the audience.
The slides were deliberately over-positive; omitting obvious points of suckage - Maarten and myself were there to "hype" each language while the audience had to slay us.
Syntax: Sucks vs. Sucks Hard - can't remember how we got to this. Possible via browser compatibility problems.
Scope / Namespaces / Packaging - again can't remember.
Meta Programming: OK vs. OK and AOP: OK vs. OK - in both cases this was largely audience apathy - in reality no one is attempting either in either language so "OK because we're not doing it"
chregu, Harry, I didn't realize the joke-nature of it, it honestly looked to me to be an attempt to compare these two languages. Sorry 'bout the misunderstanding.
At the same time, it is good that these kinds of conversations are going on, because it means that PHP as a language has the potential to improve. I don't know if an improvement would mean giving PHP more of a lexical scope, or giving it more more freedom in the object system (more like ruby, less like java?)
I guess it depends on what is next for PHP. Is it gonna stick with the small to medium web app space, or try and branch out and compete with J2EE? Where does RoR factor into all this, cause it is eating up PHPs mindshare.
But then, this eating of the mindshare might not be a bad thing in the least.
At the same time, it is good that these kinds of conversations are going on, because it means that PHP as a language has the potential to improve. I don't know if an improvement would mean giving PHP more of a lexical scope, or giving it more more freedom in the object system (more like ruby, less like java?)
I guess it depends on what is next for PHP. Is it gonna stick with the small to medium web app space, or try and branch out and compete with J2EE? Where does RoR factor into all this, cause it is eating up PHPs mindshare.
But then, this eating of the mindshare might not be a bad thing in the least.
Add Comment




