Live data from Hacker News

PHP: A fractal of bad design

me.veekun.com

341–350 of 514 posts

Re: PHP: A fractal of bad design

#341
I've programmed in PHP for many years and still use it for my side projects, but I would state that the criticism in the article is mostly fair and relevant. Yes, as an environment PHP is easy to deploy, fairly well-documented and has some other nice benefits (like shared-nothing architecture, build-in templating or the ability to write config files using core syntax). However, as a programming language PHP is pretty awful. Worse, the issues it has are glaringly obvious and not that difficult to fix, if you're willing to break some compatibility, which it regularly does anyway.

It would be better for everyone if people could mentally separate PHP's features and misfeatures and learn from both, instead of just bashing the language and jumping to its defense as a whole.

Re: PHP: A fractal of bad design

#342
post #337

Earlier quoted context omitted.

> If this one thing that annoys me on HN it's the pervasive anti-PHP snobbery. If there's one thing that annoys me on programmer forums in general, it's that pointing out PHP's giant flaws is conflated with snobbery. Design matters, and that is not the same thing as saying it's impossible to build anything good with PHP.

Pointing out "giant" flaws which don't really matter and can't be fixed for 1000th time is very useful for... remind me please, what exactly purpose?

Convincing people to stop using such a flawed language when there are so many viable (and in nearly all ways preferable) alternatives.

Re: PHP: A fractal of bad design

#343
post #337

Earlier quoted context omitted.

> If this one thing that annoys me on HN it's the pervasive anti-PHP snobbery. If there's one thing that annoys me on programmer forums in general, it's that pointing out PHP's giant flaws is conflated with snobbery. Design matters, and that is not the same thing as saying it's impossible to build anything good with PHP.

Pointing out "giant" flaws which don't really matter and can't be fixed for 1000th time is very useful for... remind me please, what exactly purpose?

Oh, you mean as opposed to the usefulness of calling people snobs because they understand that PHP is terribly designed? Fuck outta here.

Re: PHP: A fractal of bad design

#344
post #330

Earlier quoted context omitted.

> But letting users write code that appears to work (yet it does not) is not a good property of a language. I still don't see the point that's trying to be made here. Whether it returns -1, FALSE, or you need a try/catch, the programmer still needs to check. To successfully program in any language with an 'index of' function, a check needs to exist regardless...

In PHP, if you forget the check, and have error reporting turned off (which you should), you'd never KNOW you forgot the check, because missing it is only a logic error, whereas an exception blowing up a python script will be caught by the runtime.

> have error reporting turned off (which you should)

No, you should not. You should never have error reporting turned off. You should certainly have it set to not display errors to the client, but all errors should be sent to a log, preferably syslog, and they should be reviewed. Your code shouldn't generate any errors.

Re: PHP: A fractal of bad design

#345
post #298

Earlier quoted context omitted.

It seems that many people disregard the fact that PHP is a very accessible language to a programming newcomer. You can quickly and easily install LAMP or MAMP and in minutes have a working, dynamic web page (albeit local) along with a plethora of examples and tutorials. This is huge. This shows the newcomer that this mysterious code stuff is actually accessible; that they can create something that works. That's a nic…

I agree with the general point but this seems more of an indictment of other languages than a plus for PHP: with PHP, it's easy to get started with the most simple features - and then it takes years to learn how to cope with the language quirks and inconsistencies, deal with outright bugs, and learn a number of non-obvious ways in which your “working” site might be hacked due to a hidden language feature. There are t…

"(Pro-PHP flamers: I started using PHP back in 1999. Your arguments are not new.)"

See, that's part of the problem. PHP has been terrible for close to two decades. It used to be even worse than what Eevee describes.

Re: PHP: A fractal of bad design

#346
post #337

Earlier quoted context omitted.

Pointing out "giant" flaws which don't really matter and can't be fixed for 1000th time is very useful for... remind me please, what exactly purpose?

Oh, you mean as opposed to the usefulness of calling people snobs because they understand that PHP is terribly designed? Fuck outta here.

You don't like it? Don't use it. You're the kind of asshole that'll walk up to somebody in McDonalds and tell them that the food they're eating isn't healthy. You know what? Mind your own business.

Re: PHP: A fractal of bad design

#347
post #327

Earlier quoted context omitted.

I've been coding PHP for years and am just starting to learn Ruby on Rails. I'm not a programming expert at all, and so most of the objections mentioned would take me a while to parse. From my perspective, Ruby on Rails is really, really difficult so far. You have to learn to use the terminal (which I've seen other people in my position use to totally mess up their computers); to make a simple application you're alre…

Don't start with rails, start with ruby. Doing otherwise is like trying to learn PHP by looking at the Drupal codebase.

I did, and Ruby was quick and easy. I wrote a bunch of programs and felt comfortable enough that I could understand stuff if I looked at it. But Rails seems like a whole other animal. And your right, this is the difference between languages and frameworks. But, without Rails I'm not sure how to get to a web app with Ruby. With PHP I was writing web apps before I really understood the language.

I don't mean to be saying that I'm doing it right, or that mine was a good way to learn programming. Just mean to be giving a data point about the relative approachability of PHP and RoR for actually making stuff as a beginner.

Re: PHP: A fractal of bad design

#348
post #340
post #331

Earlier quoted context omitted.

The article tries to be a comprehensive list of problems with PHP and @ is a notorious one, even if you personally are disciplined enough to avoid it. Not to mention that I have no idea why the original commenter picked on this. It was listed as one of the 7 or so things that can go wrong with that one single, not unusual line of code. It's not like he had a whole paragraph about why @ is bad.

> The article tries to be a comprehensive list of problems with PHP and @ is a notorious one Nonsense. The @ error suppression is a tool, just like any other. It should be used sparingly, but it does have its uses. I have been writing in PHP for over a decade and I have used it exactly one time. And yes, it irritates me when I see it in other's code all over the place ... which is why I refactor all external PHP code…

Ok, let me fix that: "The article tries to be a comprehensive list of problems with PHP and @ is an error suppression tool that is notorious for being misused throughout the community".

> I refactor all external PHP code before I place it inside of mine

> You don't like a feature of PHP? Don't use that feature. Simple as that.

I don't know anything about you, but judging from that attitude you haven't worked in many teams. Of course it's not as simple as that. If I had a penny for every time I had to fix someone not checking that strpos() === FALSE, well, I could fund my own startup. You may have the luxury of refactoring all over the place, but the reality out there is that horrible code like this is left to fester until it causes real business damage.

Re: PHP: A fractal of bad design

#349
post #264

If this one thing that annoys me on HN it's the pervasive anti-PHP snobbery. A selection from the OP: > Because of the @, the warning about the non-existent file won’t be printed. So your complaint is that when you use @ to suppress an error it... suppresses the error? > The language is full of global and implicit state. "Global" is one of those dogmatic points. Nothing is truly "global" in PHP. The "global" in PHP j…

Snobbery is exactly what this is. You can honestly create a list of complaints for any language (even the hipsters' beloved Ruby) that's just as long and passionate but it's become cool to hate PHP.

People have a lot of excuses for their snobbery but it really does all come down to snobbery. The post says that the "you can write bad code in any language" retort isn't valid and labels it as a discussion ender but I'd submit that his unwillingness to deal with that argument serves just that purpose. It's a perfectly valid point to say you can write crap in any language.

PHP really does nothing to discourage you from writing bad code. It gives lazy and inexperienced coders the false sense of security that comes with the magic quotes setting, it encourages you to mix logic and presentation and generally has lots of shortcuts that let you avoid tedious things like writing maintainable code and taking responsibility for security but there's beauty in the language too. No one has to fall victim to those things and anyone can avoid them just as easily as they could in any other language. I love the fact that PHP doesn't force any one way of doing things on you like other languages do. If you're a newbie it holds your hand while letting you screw up. If you know good application design it let's you write your scripts any way you want and trusts that you know what you're doing. I can't say that about Ruby though I too have warm fuzzy feelings for that language.

There's a lot of bigotry against not just PHP but beginner programmers. For some reason hackers have this strange mentality where many just need to be the smartest person in the room and take cheap shots at uncool technologies while masturbating over their shiny new toys that are oh so superior. They also have this weird love/hate relationship with beginners. They love to impart their knowledge and school them (while often times trying to get them to do thing their way which is not always the right way despite what they say). But then they hate the newbies when they go off and use PHP to build something cool and interesting. I can sometimes just hear them silently thinking "I spend $100k and 15 years learning to be an elite programmer and you picked up 'PHP for Dummies' and whipped up a clone of my app in a day? Well fuck you, I'm going to find everything wrong with it and knock you down a peg or two".

Seems like a fad to me. Eventually our beloved Ruby and Python will be replaced with SuperCoolScript (SCS V1.0) and we'll all be right back here hating or defending those languages. I know we don't like to admit it but it's becoming more and more apparent that deep down a lot of PHP hating is due to snobbery caused by jealousy and a need to be the smartest person in the room.

Remember when it was cool to hate JavaScript? It still is but now that's starting to change. Now we have nodejs and V8 and Geddy and JavaScript is the new Ruby. Let's all play nice, let the noobs have their fun, and just keep our heads down and focus on being better by doing better instead of being better by tearing others down.

By the way, I'm a totally unapologetic PHP guy. I fucking love PHP. I know about the problems it has but I don't mind being uncool.

Re: PHP: A fractal of bad design

#350
post #336

Earlier quoted context omitted.

An important thing to remember about PHP is that it really isn't stuck in 1996: When we say PHP you need to think WordPress , or Drupal , or CakePHP or Symfony , since that's what one actually uses nowadays. Novices are steered away from code that pipes SQL injections directly to the database, and toward one of these frameworks, which does the heavy lifting for you so that you don't need to reinvent the wheel. For ye…

I actually find php well suited to client-side rendering. Implementing a web service in php is pretty easy. The only thing i use php for is building json-rpc and soap services using zend framework's service classes, wrapping around zend framework's database classes. The app itself is all javascript.

True, and if this is all your server-side needs to be, while there's not much reason to prefer PHP for this above anything else, there's also no reason not to just keep on cruising with PHP.

My experience running PHP cloud services suggests that, operationally, PHP is a dream. It's the least problematic layer of the LAMP stack, at least once you've learned what the words "APC cache" mean.

Post reply on HN