5 ms·
I cannot possibly hope to express the reasons I dislike PHP better than this comprehensive article: http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de
by adambard 13y ago
I cannot possibly hope to express the reasons I dislike PHP better than this comprehensive article: http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/ http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de...
An excerpt:
> I can’t even say what’s wrong with PHP, because— okay. Imagine you have uh, a toolbox. A set of tools. Looks okay, standard stuff in there.
> You pull out a screwdriver, and you see it’s one of those weird tri-headed things. Okay, well, that’s not very useful to you, but you guess it comes in handy sometimes.
> You pull out the hammer, but to your dismay, it has the claw part on both sides. Still serviceable though, I mean, you can hit nails with the middle of the head holding it sideways.
> You pull out the pliers, but they don’t have those serrated surfaces; it’s flat and smooth. That’s less useful, but it still turns bolts well enough, so whatever.
> And on you go. Everything in the box is kind of weird and quirky, but maybe not enough to make it completely worthless. And there’s no clear problem with the set as a whole; it still has all the tools.
> Now imagine you meet millions of carpenters using this toolbox who tell you “well hey what’s the problem with these tools? They’re all I’ve ever used and they work fine!” And the carpenters show you the houses they’ve built, where every room is a pentagon and the roof is upside-down. And you knock on the front door and it just collapses inwards and they all yell at you for breaking their door.
> That’s what’s wrong with PHP.
- Osiris 13y agoReally? I've heard all these ridiculous analogies but for some reason no one's every written up actual PHP examples to explain why this is true (Most of the examples in that link are weird things I've never seen anyone actually do). I've spent the last 8 months writing a fairly complex application as a REST API entirely in PHP and I can't say that I've ever run into any weird scenarios where I think to myself, "Damn, this is sure it like have a hammer but with claws on both sides." My code is very OOP relying heavily on my own classes and not quite as much on the built-in PHP functions. I have also found that when I need to do something odd that there's usually a pre-built function already in PHP for doing it. So if you're going to bash PHP at least throw out some actual PHP code and explain why it's bad (and make sure to point out that there's no other really good way to do it in PHP using you're own classes/methods).
- eevee 13y agoWeird things you've never seen anyone actually do? Test for equality, build data structures, handle error conditions? There's lots of example code, inline, but much of the article is about missing/broken features and artifacts of the design that make it unfriendly to wetware.
- adambard 13y agophp > $x = array("a" => 1, "b" => 2); php > echo $x["a"] . "\n"; 1 php > echo array("a" => 1, "b" => 2)["a"] . "\n"; PHP Parse error: syntax error, unexpected '[', expecting ',' or ';' in php shell code on line 1 I don't mean to denigrate everyone who uses PHP. But there's a whole world of great languages out there, and the vast majority of them act in more consistent (not to mention pleasant) ways than PHP. When I got into web dev I spent 2 years developing in PHP before moving on. My programs worked fine, eventually, and some were even well-written. I'm sure yours are too. That doesn't make PHP any less of a mess. But I never understood until I moved on to Ruby and Python and beyond just what a mess it was.
- krapp 13y agoI'm starting to wonder whether there should be a version of Godwin's Law for Hacker News: As any thread mentioning PHP progresses, the probability of a poster mentioning "A Fractal Of Bad Design" approaches 1.
- vecinu 13y agoThis has been reiterated over and over again and is just a bunch of fluff. It doesn't explain why PHP is bad with examples and while I know there are a ton of sites that do, many people including myself have used PHP successfully in the past. I will refer you to an even better quote: 'Software engineers are becoming like "photographers". They spend so much time arguing over the right lens type, focal length, camera body, flash and other sets of tools until they discover they've already missed their opportunity at taking some great shots. Software devs are now doing the same thing, arguing over the tools they use, wasting precious time instead of getting work done.'
- jrheard 13y ago> It doesn't explain why PHP is bad with examples The linked article specifically does explain why PHP is bad, and it does it by providing literally hundreds of specific examples. It's a really impressive essay.
- Osiris 13y agoThe very first example about @fopen is full of weird stuff about INI file changes and stuff that are not on by default and if someone turns them on they should understand what they are doing.
- wtetzner 13y agoBeing able to successfully use something doesn't mean it was a good idea. Even though it's common, I don't think referring to programming languages as tools is actually accurate. A programming language is more like a building material. And this is an important distinction. Let's look at scenario. Say Fred hired Bob to write a program for him. Bob decides to use PHP. After finishing his work, Bob moves on to other projects. A while later, Fred realizes he wants some changes made to his program. So he hires George. George can't make changes to the program in Haskell. He has to modify the PHP source. The reason I bring this up is that the choice of programming language is important, and is not the same as the choice of tools (e.g. your text editor). You can build a house out of paper mache, but chances are you'll end up regretting it.
- eli 13y agoGot it. You don't like PHP. I don't think that has much to do with this announcement. I don't like Java, but I do not feel offended that GAE supports it.
- adambard 13y agoI probably should have posted that in the existing php-sucks party above, I suppose.
- eevee 13y agoI seriously only added this metaphor as an afterthought, after pulling it out of my ass to explain all the furious typing to my partner. It's pretty funny that it's become the most famous part of the article.
- adambard 13y agoIt's definitely the most quotable bit. I'd say you actually make your point a lot better through sheer quantity, but that's a bit harder to convey in excerpt form.