4 ms·
WARNING: Frank opinions ahead. I added "To die", because that's my honest opinion after having been a PHP dev since ~PHP3. Whether it's the language's fault or
by jessedhillon 15y ago
WARNING: Frank opinions ahead.
I added "To die", because that's my honest opinion after having been a PHP dev since ~PHP3. Whether it's the language's fault or not, my experience with other people's PHP code is that anything big tends toward spaghetti except in a few well-engineered cases. Non-pasta is the exception that proves the rule.
People who actually know something about programming well, frankly, would not start new projects in PHP. Its only use to me is as a litmus test -- if your answer to "What do you think of PHP" doesn't include a significant critique of the language, I probably wouldn't like working with you. (Nor you with me)
- wvenable 15y agoThere's nothing inherent in the language that makes building non-spaghetti code difficult. All the weird annoyances and idiosyncrasies are a big pain in the ass but, unlike say COBOL or Basic (or even C), they don't fundamentally prevent you from building nice organized easy to understand code. That being said, I totally agree with you -- other people's PHP code tends towards spaghetti in the vast majority of cases. My take from this is that if PHP were to disappear tomorrow all these programmers building spaghetti would just inflict their level of skill on other platforms.
- jessedhillon 15y agoPossibly. I like to think -- informed by my own experience -- that PHP collects a disproportionate share of bad programmers because it's the easiest for bad programmers to use. Chiefly, it is possible to start writing scripts with not even a modicum of planning and forethought; you only need to know what your filename will be. So it stands to reason that they would move on to the new easiest language for bad programming. Or maybe they would rediscover their passion for something other than web dev, go back to school and get English degrees. I can hope, can't I?
- icebraining 15y agoI disagree; it's possible to write programs with planning and forethought in any language, and even simple languages like Python have much higher average quality code. I think it's a matter of culture, which is reflected in the language itself and in the community that surrounds it and writes code samples and OSS software.
- wvenable 15y agoI don't think it's a matter of culture so much as a matter of scale. It's the same with most web communities, the quality of the community tends to go down as the membership increases.
- noduerme 15y agoAny language that lets you mix it in among standard HTML is going to generate spaghetti a lot of the time, because page order display and logic flow are inherently contradictory. Logic flow should be hierarchical and static, while page display is a text representation of visual UI choices having little or nothing to do with the logic of the data behind them. But for generating models, it's nice and quick. And for writing form/json/flash service code it does certain things extremely well; you can take a json object, parse it, escape it, run it through a mysql query and return a nicely formatted result object in about five lines. Again, it's whatever you want it to be.
- Zak 15y agoThere's nothing inherent in the language that makes building non-spaghetti code difficult. Technically, that's mostly true. Culturally and psychologically, I'm inclined to say it isn't. Just as you're more likely to leave things lying around haphazardly in a room that's already messy, you're more likely to write sloppy code in a sloppy codebase. When the language itself feels sloppy, it's damn hard to avoid that effect. Sure, you can write good code in PHP, but why would you want to when there are so many other languages out there? The only reason I can think of is if you're selling a product to be deployed on shared-hosting websites belonging to customers.
- MatthewPhillips 15y agoPHP is the default web language. If you're pitching to a client who expects to maintain the code once you're done and you suggest Clojure, Node.js, or even Ruby in a lot of cases you won't get the gig. By doing so you've raised their costs; PHP programmers are easier to find. This is the main reason I'm not doing web consulting!
- Zak 15y agoBy doing so you've raised their costs I don't think that's actually true, aside from maybe $10/month extra in hosting[0], I think costs tend to be lower with not-PHP. Using PHP greatly increases the probability that a random contractor will be a bad programmer who will write things that are broken, require more billable hours to get things done or make a mess that slows down the next guy. I've never lost work due to suggesting not-PHP to a client. I have, however regretted failing to do so several times. I've come to believe that a client's insistence on using PHP is nearly as much of a red flag as a programmer not knowing anything else. [0] If a client is worried about $10/month extra in hosting costs, you'll probably also have to fight them for every dollar. They might even try to get out of paying what they agreed to. I've had it happen.
- bradleyland 15y agoPHP's death, sadly, would not take bad programmers with it. See also: Rats flee a sinking ship.