8 msยท
The truth is, no language is perfect. PHP just happens to be good at getting stuff done fast, so it's found all over the place, and thus has a lot of eyeballs
by osrec 4y ago
The truth is, no language is perfect.
PHP just happens to be good at getting stuff done fast, so it's found all over the place, and thus has a lot of eyeballs on it. The negativity is a byproduct of it's usefulness and staying power - the price of popularity, if you will.
I love PHP, especially with the new event loop based modules that let you do things asynchronously, much like Node or Go.
If you know how to use it well, PHP is awesome, and it's getting better with each release.
- PaulHoule 4y agoPHP was the first open source language in which just anybody could write server-side web applications without terrible management problems for the sysadmin. First people wrote cgi-bin scripts in Perl, which were not efficient because they forked a process for each request. There was mod-perl which was more efficient but prone to memory leaks. A few people wrote cgi (or fast-cgi or Apache module) programs in C/C++ but that was insane since a return after a ๐๐๐๐๐๐ข is Turing complete in C and there weren't any mitigations for this in the 1990s. PHP opened the door to cheap web dynamic web hosting and in turn you had self-hosted applications like Wordpress. It was a few years later that languages like Java and C# became really attractive for back end work, you also had Ruby, Node, etc. I wrote a lot of PHP in the early 2000s because that is were the work was, thatโs what you could write open source code that people would use in, and it was really straightforward to build apps (like a social network for a secret society) without an โopsโ team watching your every move.
- daveslash 4y agoThis is a refreshingly nice, informed, and balanced perspective. I've only done PHP for small personal projects and some wordpress hacking, and that was years - so my experience is limited. But it seems to me that one of the great and tragic things to PHP is the low barrier to entry. As you put it: "first open source language in which just anybody could write server-side web applications without terrible management problems for the sysadmin". This made it extremely easy for anyone in the early 2000s who signed up for a web hosting account on godaddy/hostmonster/hostgater/etc... to fire up a text editor of their choice and start slinging code and FTP'ing up to a server. Didn't have to worry about installing, configuring, all the dependencies, build tools, etc... just edit, upload, refresh -- lather, rinse, repeat until it works. Lowered the barrier to entry, and got a lot of people into the field. Really powerful stuff. It also made sloppy, hacked-together, copy-pasta code very prevalent. In my limited perspective, I suspect that this prevalence of sloppy spaghetti-code has contributed to PHP's bad reputation. It's not that you can't do good code (totally can!), but a PHP environment can be forgiving of some pretty bad practices.
- osrec 4y agoThe thing is, I've seen sloppy, hacked-together code in finance, in a variety of languages, including Java and C, where the barrier to entry is relatively high, and the language fairly strict. You just don't hear about the coding fiascos, as they're mostly behind closed doors. PHP has a low barrier to entry, but that's a great thing in my opinion. It's something that should be celebrated, and at the very least, it shouldn't be a criticism! Bad developers exist in every language, and no language is completely wart-free. People just like to zero in on PHP to criticise it because it's easy, and it bugs me a bit (especially if they're simultaneously singing the praises of another less than perfect language such as JS or Python or Go).
- PaulHoule 4y agoPHP had the advantage of having built-in resource limits and little contention over locks and other shared resources that meant sloppy coding wouldn't crash your server. Providers could offer low cost hosting plans because you could put a lot of customers on the same server and have very little trouble. It was a big plus that it was open source and didn't have the crazy high license costs of early dynamic web hosting solutions such as ColdFusion, WiTango, Netscape's application server, etc.
- PaulHoule 4y agoIn my mind the great thing about PHP was packaged application software like PHPNuke, Wordpress, etc. that would let you make a highly capable dynamic site with little or no coding. At that time you could have made similar software for JSP, ColdFusion or ASP.NET but hosting would have been much more expensive and a big hassle. With PHP it was feasible to offer a $5 a month hosting plan good enough for blogs and simple web application. I wrote a lot of PHP because it was a great way to deliver products to customers, particularly ones that didn't have a lot of resources for "ops" but also a place where I could write open source software which might really get used and have an impact.
- tyingq 4y ago"First people wrote cgi-bin scripts in Perl, which were not efficient because they forked a process for each request" I don't recall the sequence of events that way. That is, there was regular cgi, then mod_php with problems similar to mod_perl...then later fastcgi options existed for both.
- torstenvl 4y agoWait. Isn't fastcgi essentially the same as mod_php? IPC with a long-running process rather than forking and capturing stdout? What's the newer fastcgi php method that isn't mod_php?
- dysarray 4y agoFastCGI and mod_php are both ways of running PHP on a web server, but they differ in how they achieve this. FastCGI is a protocol that allows a web server to communicate with external programs that provide dynamic content, such as PHP scripts. In FastCGI, the web server launches an external program, called a FastCGI process manager, which is responsible for starting and managing a pool of long-running PHP processes. When a request for a PHP script comes in, the FastCGI process manager assigns one of these processes to handle the request, and the process generates the dynamic content and sends it back to the web server. mod_php, on the other hand, is an Apache module that embeds the PHP interpreter directly into the Apache web server. This means that PHP scripts are executed directly within the Apache process, without the need for an external process manager. While both FastCGI and mod_php are ways of running PHP on a web server, they differ in their implementation and how they handle requests for PHP scripts.
- giantrobot 4y agoI think the big thing PHP offered was people could easily deploy their project just by copying files to a directory. A link directly to the file got dynamic content. Most shared hosting also put index.php in the default indexes to check for directories. So it was simple to have clean looking links without using a rewrite module. Deploying to the cgi-bin directory was more convoluted and error prone for end users. Even when you did it right all of your URLs had an "ugly" cgi-bin component. The easy deployment and cheap shared hosting with their managed MySQL instances really helped boost PHP's usage.
- bzzzt 4y agoFact that PHP was built-in on virtually every Linux distribution and hosting was dirt cheap since one server could easily host hundreds of customers helped too I guess. Java and .NET never were after the $5/month hosting market.
- msla 4y ago> PHP just happens to be good at getting stuff done fast, so it's found all over the place, and thus has a lot of eyeballs on it. The negativity is a byproduct of it's usefulness and staying power - the price of popularity, if you will. I don't like arguments like these because they're a tu quoque without even bothering to point out flaws in a different thing. It implicitly states that progress is impossible, that all languages will always be as bad, and nothing can ever improve because once a technology is widely-used, design flaws will magically appear. If you really believe that, write your next website backend in FORTRAN IV. It was lazy argumentation when it was people saying Linux was just as buggy as Windows Me and it's lazy argumentation now.
- osrec 4y agoI accept PHP has flaws, as do other languages. But I feel PHP gets an unfair amount of criticism, given that it's "flawed" implementation of a programming language happens to run a big chunk of the web today. > Progress is impossible Huh? My very last sentence implies quite the opposite.
- antifa 4y ago> It implicitly states that progress is impossible PHP has made huge strides in progress over the last decade.