6 ms·
Any idea why PHP has such a bad reputation compared to other interpreted and dynamically-typed languages such as Python?
by ggregoire 8y ago
Any idea why PHP has such a bad reputation compared to other interpreted and dynamically-typed languages such as Python?
- sfteus 8y agoTo keep it simple, it was originally created as sort of a helper instead of a full-fledged language, and just kind of grew into that. As such, its early years were plagued with architecture, security and performance issues, as well as many "gotchas" that could wreak havoc on amateur programmers that tended to gravitate to the language. Couple that with the fact that the maintainers drug their feet in implementing modern paradigms found in other languages and fixing the latter issues in the name of backwards compatibility, and that at the time most PHP knowledge bases were years out of date, and it was a recipe for a poor ecosystem all around. PHP 7.0 took a huge step forward by straight up removing old extensions that weren't maintained, focused a lot on performance and allowing more strict standards, and tons of new improvements. In addition, more modern frameworks like Symfony and Laravel started to pop up, which helped reduce the stigma of it just being a "scripting" language and made it very pleasant to work with. I maintain a PHP app that was originally written in PHP 4, and one that was created in PHP 7 and the difference is night and day. I maintain a few Ruby and Python apps as well, but even having used these more often PHP still tends to be my go to for prototyping.
- elcomet 8y agoThis sounds a lot like JavaScript
- 1_player 8y agoGotchas in Javascript are syntactic/semantic, because there's no standard library worth its name bundled with it. PHP's gotchas are syntactic/semantic but mostly on its huge standard library, which is an haphazard collection of functions from sending emails to parsing ID3 tags from MP3 files. EDIT: JS, as the legend says, was written in 10 days, while PHP grew without much long term vision for years.
- Technetium_Hat 8y agoI think the parent poster was talking about both being messy in the past, but recently having a major version upgrade that deprecated old features. PHP 7 could be compared to ES6 (as well as ES5's strict mode)
- acomjean 8y agoIts a quirky little language and the early versions weren't great. The language can be inconsistent in places, and embedding php in the html made for a rapid though sometimes trying experience. Its keeps backward compatibility which keeps those quirks in there. (though with new 7 series php versions older stuff is starting to break.) Someone wrote an article with a title like "php a language with terrible design" that got traction. I like the language and with the right framework and templating engine its a pleasure. (I'm moving code from silex to symfony). I've been to a fair number php meetups and frankly people there seem to be end result focused not so concerned with the language. Frankly I think PHP doesn't have as strong a fan club as ruby/python, which are decent languages but they too come with their own quirks.
- gnarcoregrizz 8y ago"and embedding php in the html made for a rapid though sometimes trying experience." Funny, that is React/JSX's biggest sell
- nprateem 8y agoReact can't execute arbitrary database queries.
- gdfasfklshg4 8y agoCan too! {e = () => ajaxCallToMutateDatabase()} Or something similar... It's just people don't do it because it is a bad idea!
- Aeolun 8y agoI’m sure you can use the all JS mysql client to connect directly from your client app to your database.
- nprateem 8y agoWell yes if you're stupid enough to directly expose your DB to the world then it's technically possible, but barring such idiocy there's arguably more risk of a DB hack through PHP than client side JS in most architectures.
- h8hawk 8y agoThis article explain it well: https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/ https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/
- jbarham 8y agoPHP: a fractal of bad design: https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/ https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/ This rant is almost seven years old now, but I imagine that some things still hold true. Python in particular is indisputably more versatile than PHP.
- redwall_hp 8y agoOof. I haven't read that classic in awhile. Yeah, most of the things in there can't really be fixed without pulling a Python 3 and intentionally breaking backwards compatibility. And the scary thing is people just brush some of these horrifying things off as non-issues. PHP was one of my first languages, and it took a long time to break some bad habits it taught. I still can't get over the existence of PHP's "arrays." (Mentioned in the article.) The only data structure is one-size-fits-all. It's truly baffling when you approach it with basic CS knowledge, and the rabbit hole only gets worse...
- furicane 8y agoIn the context of what you're doing with PHP, that one-fits-all data structure is all you need. I sincerely doubt you had hurdles in your career because of PHP's array :) However, let's prove once more that languages evolve: http://php.net/manual/en/book.ds.php http://php.net/manual/en/book.ds.php The "classic" you're referring to is far from something objective. There will always be problems with languages. That's why we have the human factor who is supposed to be intelligent and work around the apparent issues and make the computer do useful work despite apparent tool glitches. Sadly, we're just creating better idiots who are only getting better at whining.
- Aeolun 8y agoI personally really enjoy the one size fits all array. It’s a serious switch going to any other language though.
- mathieuh 8y agoFor years it was a very permissive language that allowed you to do a lot very quickly but then with a lot of overhead to make sure things were correct. E.g., I've seen a payment management suite that was written using php traits, which then had a super class that everything descended from, meaning every service could do everything, completely breaking OOP. For example, a DirectDebitService has methods like processMandate(), processDd(), but then because of the traits it also has access to processCreditCardPayment(). As you can imagine this made unit testing literally anything require lines of set up code and just made things impossible to work with. With the introduction of classes, and PHP 7's scalar type declarations as actual keywords rather than just PHP docs, as well as the option for strict comparison, plus the ridiculous speed improvement between 5.6 and 7.0. Further, tools like composer (which I think was actually one of the first modern package managers (with lock files, version selectors), Behat for integration tests, plus the huge steps frameworks have made in removing in overhead have made PHP actually a very nice language to write these days. Deployment in a micro service context is still annoying as PHP's built in web server is not great, requiring you to have an Ngninx pointing at a PHP-FPM which actually serves each of your microservices. You may think you can get away with one Ngninx, but then as soon as micro services start requiring things like scaling it's a pain in the arse. E.g. you may wish to do rate limiting or rbac or something for a specific service, requiring an nginx->PHP-FPM in front of each PHP service. I'm sure there are cleverer ways to get around this but this is the way I always go and the way I've seen other PHP deva go
- kristopolous 8y agoNone of these other answers get to the real point. The entry level language gets the reputation of the code written on the platform. That's why basic, flash, php, Java, and JavaScript all had bad reputations at one time. You can knock on any sufficiently complex language, it's actually really easy. Python, for instance, gives different numerical results between 2 and 3 for the code "False - 3 * True / True / 2 + 3 * False" (-1 and -1.5) Making things look absurd isn't hard.
- aczerepinski 8y agoThis may sound trivial but I dislike the aesthetics and ergonomics of typing PHP. In most dynamic languages user.name is 9 keystrokes, but in PHP $user->name is 13 keystrokes.
- ileri62 8y ago100% agree. The syntax of languages such as php, c++ and rust just look ugly af. The use of $ and :: piss me off the most