zlacker

[parent] [thread] 14 comments
1. PaulHo+(OP)[view] [source] 2022-12-08 14:04:01
PHP 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.

replies(4): >>davesl+9o >>tyingq+Px >>giantr+JI >>bzzzt+NK2
β—§
2. davesl+9o[view] [source] 2022-12-08 16:08:38
>>PaulHo+(OP)
This 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.

replies(2): >>osrec+9v >>PaulHo+Dw
β—§β—©
3. osrec+9v[view] [source] [discussion] 2022-12-08 16:37:11
>>davesl+9o
The 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).

replies(1): >>PaulHo+Rx
β—§β—©
4. PaulHo+Dw[view] [source] [discussion] 2022-12-08 16:43:18
>>davesl+9o
In 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.

β—§
5. tyingq+Px[view] [source] 2022-12-08 16:48:42
>>PaulHo+(OP)
"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.

replies(1): >>torste+bz
β—§β—©β—ͺ
6. PaulHo+Rx[view] [source] [discussion] 2022-12-08 16:48:44
>>osrec+9v
PHP 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.
β—§β—©
7. torste+bz[view] [source] [discussion] 2022-12-08 16:54:46
>>tyingq+Px
Wait. 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?

replies(2): >>dysarr+pz >>tyingq+Mz
β—§β—©β—ͺ
8. dysarr+pz[view] [source] [discussion] 2022-12-08 16:56:21
>>torste+bz
FastCGI 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.

replies(1): >>torste+zG
β—§β—©β—ͺ
9. tyingq+Mz[view] [source] [discussion] 2022-12-08 16:58:25
>>torste+bz
The mod_* meant apache modules managing the process pool without a socket connection to a separate pool manager. Which meant issues there could affect the webserver, which was typically also serving static assets, etc.
replies(1): >>torste+hD
β—§β—©β—ͺβ—¨
10. torste+hD[view] [source] [discussion] 2022-12-08 17:15:04
>>tyingq+Mz
You're right, I guess I misremembered how I set my web server up. I'm using mod_proxy_fcgi with php-fpm, not mod_php.
β—§β—©β—ͺβ—¨
11. torste+zG[view] [source] [discussion] 2022-12-08 17:30:30
>>dysarr+pz
Is there no rule about GPT/bot responses on HN?
replies(1): >>dang+0U
β—§
12. giantr+JI[view] [source] 2022-12-08 17:41:21
>>PaulHo+(OP)
I 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.

β—§β—©β—ͺβ—¨β¬’
13. dang+0U[view] [source] [discussion] 2022-12-08 18:41:42
>>torste+zG
We don't allow bots on HN and ban such accounts.
replies(1): >>torste+Bb1
β—§β—©β—ͺ◨⬒⬓
14. torste+Bb1[view] [source] [discussion] 2022-12-08 20:01:39
>>dang+0U
One ChatGPT reponse to:

> Write an explanation for the user who posted the following comment: "Wait. 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?"

is:

> FastCGI and mod_php are similar in that they both use a long-running process to handle PHP requests, rather than creating a new process for each request. However, they differ in how they are implemented and how they interact with the web server.

FastCGI is a protocol that allows a web server to communicate with external programs, such as PHP, to handle dynamic content. It is typically used with web servers such as Apache or Nginx. In the case of PHP, the web server uses FastCGI to send PHP requests to a PHP-FPM (FastCGI Process Manager) process, which then executes the PHP code and returns the result to the web server. This allows the web server to handle multiple PHP requests simultaneously, improving performance.

On the other hand, mod_php is an Apache module that embeds the PHP interpreter directly into the Apache web server. This means that Apache can handle PHP requests itself, without the need for external programs or FastCGI.

β—§
15. bzzzt+NK2[view] [source] 2022-12-09 07:15:02
>>PaulHo+(OP)
Fact 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.
[go to top]