5 ms·
PHP Must Die
- csomar 17y agoI think "PHP Must Die" is a lot exaggerated, I think "PHP should be improved" is a better title!
- ThinkWriteMute 17y agoYes, but so much would have to be improved that starting off with a clean slate might be easier, yes?
- ryanwaggoner 17y agoWhat does "the slate" mean here? There's not one master language out there, so "killing PHP" means one of two things: 1. Using something else for an individual project (maybe a good idea) 2. Replacing all PHP with something else (impossible) Since a massive amount of the web runs on PHP, "starting off with a clean slate" would definitely NOT be easier. In fact, it would be impossible.
- docgnome 17y agoThe problem is most of the broken behavior in PHP is never going to be fixed because it would break compatibility.
- jacquesm 17y agoPrinting a warning would be easy enough, you could disable the warning if you want it to work like this. Leave that for one generation with a 'deprecated' attached to it, remove in the major release after that. Lots of things that were wrong have been changed like that. The biggest one remaining of the 'old' bugs which I think really would break too much is the strpos return value in case of no match (which is 'false' but 0 is a legal return value as well, -1 would have been a far better choice).
- jrockway 17y agoThe improved version of PHP is Perl. Which has been around longer than PHP...
- potatolicious 17y agoI write Perl daily - and sometimes I'd rather deal with PHP...
- jrockway 17y agoYou're doing it wrong.
- nir 17y agoIf you don't like PHP, you're allowed not to use it.
- greyfade 17y agoI disagree. One who must use it on a regular basis has every right to despise it. On the other hand, if you've never used it, you have no right to an opinion in the first place. So long as your opinion is tempered with experience, you have every right to it. But, then, I'm also of the opinion that if you like PHP, you have no right to write code of any sort.
- Luyt 17y agoThe site itself is implemented with PHP. Why doesn't the author draw a conclusion from his insight, abandons PHP, and starts eating his own dogfood?
- jrockway 17y agoIn a world where you have to eat, sleep, and work, sometimes you have to live with a bit of imperfection. If the code works, and you will never need to modify it, it doesn't matter how clean it is. (This is why I use UNIX. It sucks, but it is pretty easy to paper over the suckage. If I used a properly-designed OS, I wouldn't be able to browse the web, program, etc., etc.)
- derefr 17y agoI think there's a more relevant issue here: can we please stop designing languages that use prefix-zero to signify octal? It's a horrible trap lying in wait for those just learning their first language, and then you have to keep it in mind whenever you learn another one, to see whether it's "supported" in this new one as well. Perhaps, instead, we can come up with some unified representation of a way to attach a base to a number, such as, say, [base]b[number], e.g. 2b0110001 or 16bFF, and use it in every language? (I'd say something about subscripts and their natural use née mathematics, but I'll hold that comment until the iTablet's soft keyboard layout makes people start rethinking APL-like languages.)
- kroger 17y agoIn common lisp 08 is the number 8. clisp -q -x "(print 08)" 8 An octal number has the prefix #o, as in #o3
- thristian 17y agoPython 3 has, I believe, done away with the 0 prefix for octal and uses a consistent prefix system for different-base literals: "0x" for hex, "0o" for octal, "0b" for binary.
- jacquesm 17y agoPHP like any other language has its shortcomings and its strong points. The market place decides. If you want to get rid of PHP (or 'kill' it) you will have to displace it with something better. The other alternative is to send in a patch for this bug or simply report it. I've used PHP for many years and while I certainly don't love some of its more subtle problems you can build an amazing amount of stuff in it. I have personally had good success reporting bugs to the PHP devs. That's a lot more productive than 'blogging' about it. In case it isn't clear why the 08 does not print anything, the 8 is an illegal character in an octal string and is discarded. A suitable error message would be 'invalid character in octal sequence' instead of a silent discard.
- Luyt 17y ago$I $use $PHP $on $a $daily $basis $too... ;-) Mainly because I have to. And I often have to, since many el-cheapo web providers only offer PHP+MySQL. PHP isn't too bad, I don't get bitten often by strange bugs. I see PHP as a common workhorse.
- jacquesm 17y agoIn recent memory I ran in to two real bugs, the one was where a ' in a comment would cause strip_tags to malfunction: http://bugs.php.net/bug.php?id=46578 http://bugs.php.net/bug.php?id=46578 Fixed within 6 days, with an email to my address about where to get and how to apply the patch, which was a nice touch. The other one was technically my fault but it would have been nice to see the 'expected' response from a language I've been using for such a long time.
- chrischen 17y agoIf PHP is to be improved, the new language must be easy enough a 13 year old can do it and web oriented. These are I think its two strongest points.
- jacquesm 17y agoThat and the ease of deployment, which is possibly the strongest factor. Most hosting companies will provide you with PHP on apache even if you don't ask for it.
- yaacovtp 17y agoGo to his home page, this link is from 2004! Sep 1 2004 PHP Must Die A comparison of how different scripting languages treat their users.
- edw519 17y agoThis reminds me of that old joke: "Doctor, doctor, every time I lift my arm it hurts! What should I do?" Doctor: "Don't lift your arm." Instead: "Every time I get lazy and expect Language <x> to catch my problems, it doesn't respond the way I think it should. What should I do?" Don't be so lazy. Code it right in the first place.
- jrockway 17y agoPeople make mistakes. Computers don't. So people program computers to catch their mistakes, before those mistakes become problems like "crashing" or "losing money". If you give the compiler invalid input, a subtly-broken program should not be the output. The output should be an error pointing you to your mistake.
- potatolicious 17y agoTrue, but in this case PHP corrected its error (it now returns null for this use case, as it should)... this is why you don't rely on undocumented behaviour as canonical. If it says it should return null, but returns zero instead, check this result always.
- jimbokun 17y ago"Code it right in the first place." Isn't this advice better applied to the developers of PHP, in this case?
- nir 17y agoThe developers of PHP created the most popular language on the web. They built a language that is not only preferred by people with no programming background, but also powers some of the most influential and popular websites (eg, Wikipedia, Facebook). They did all this with zero-or-negative hype around them and while competing in a space that some of the richest companies in the world (Microsoft, Sun, IBM) have poured massive resources into. So, yeah, they did screw up here and there. But very few projects were remotely as successful as theirs.
- ErrantX 17y agoAs one of my favourite friends (also a programmer) once said: "languages are like women; if you dont treat them in ways they like then prepare for unpredictability" :) EDIT: replaced "designed" with "like" - much better phrasing
- jrockway 17y agoPHP's yacc grammar is a good read, just as an example of how not to implement a yacc grammar. Changing one constant, for example, would make PHP's parse error messages about 1000x easier to understand and resolve. (I sent a patch for this many years ago, but it apparently never made it in.) The number of things that work by coincidence, like support for octal numbers, is shocking. It's clear that PHP is optimized for something other than correctness.
- jacquesm 17y agoHehe, don't get me started :) How about: - naming conventions - globals (or, better yet, scope in general) - 'objects' (I use the term lightly) And a host of other things. They could do a lot better still, but as long as nobody comes along and starts to make serious inroads into their user base I doubt this will change much. What is surprising is not how much is broken, but how far they made it with so much stuff as broken as it is. I've always thought that if python would have used braces, dropped the whitespace bullshit and came with a ready to go plug-in for apache with a similar ease of deployment that it would have kicked PHPs ass long ago.
- jrockway 17y agoPHP appeals to the people that don't really understand programming, so I doubt making the language better in a programming-language-designer way is going to convert users. The next language that's as popular as PHP will be "easier" in some way that's appealing to average users. Perl was there first; you could "require 'cgi-lib.pl'" and start writing a web application. Then PHP made that even easier, by making HTML pages valid programs. (You could add code "later"; your scripts didn't have to live in cgi-bin isolated from plain HTML files.) The average users jumped ship from Perl to PHP pretty quickly, despite Perl having more features, more modules, a better runtime, etc. They wanted to know as little about programming as possible, and PHP got them there. Inexperienced programmers want to micro-optimize for things like deployment or runtime speed, and PHP gives them that. The next Popular Language will make one of those things even easier. (Ruby on Rails almost did this, but it went overboard with the advanced programming language concepts, and is now a small niche again. It alienated the experienced programmers, who went with Merb, and the inexperienced programmers, who couldn't wrap their head around concepts like exceptions and just stuck with PHP, which lets you ignore errors if you prefix the line with an @ sign.) Anyway, what I'm getting at is, "just leave the PHP users alone". Those that want something better will find it. Those that don't, won't.
- baddox 17y agoI chuckled at the subtle unspoken complaint about the required semicolons.
- radu_floricica 17y agoTitle is troll, and not even original. A more interesting discussion would be how more advanced, especially functional, patterns can be used in php. Right now I'm returning in php after many years of java and some time with lisp and clojure, and I'd be very curious to know if any of you managed to apply a more lispish mindset to it.