3 ms·
Old head here. CGI scripts fell out of fashion for the same reason that PHP exists: people wanted a slightly easier, more flexible way to write and update web a
by throwawaaarrgh 3y ago
Old head here. CGI scripts fell out of fashion for the same reason that PHP exists: people wanted a slightly easier, more flexible way to write and update web apps. It wasn't really performance or security as much as the fact that C is annoying to write and debug a web app in.
> Modern application servers like Uvicorn, Gunicorn, Puma, Unicorn or even Go’s standard server have addressed these inefficiencies by maintaining persistent server processes.
PHP and Perl were doing this 20 years ago, slightly better / more flexibly than these modern app servers. Apache2 and mod_php or mod_perl would let you choose between a threaded or forked model and give you the same choices you have today. New languages are just more trendy so they reinvent the wheel in them, but it's the same old thing.
Another advantage of using Apache was you had a ton of modules, could use multiple languages to write different web apps in one "app server", and serve both static and dynamic content out of the one server, or choose to move static out to a separate array of servers to lighten load. Today you'd use Nginx for your static content and Unicorn for your dynamic, so there's more and different moving pieces to do the same thing, and you lack features in both.
And people today while a lot about platforms and want to run their own VPS just to serve a CRUD app. But you know what we used to do? Pay $2 a month to someone who managed a web server for us, giving us a /cgi-bin/ we could upload our code to, along with .htaccess files to control Apache. Totally managed server, with a management web interface, and all you do is upload a script and you have a website. No server to maintain, no operations, just pure web dev. Now, they were laughably insecure, and things like Cron jobs and persistent dynamic applications kind of didn't exist. But as they say for VPSes today "you probably don't need all that, you just need to run a basic web app" and a PHP or Perl script was good enough for 99% of the web.
- deaddodo 3y agoYes, thank you. I was reading through this and just thinking...neither of those things are true. Especially since, by the tail end of their popularity, both issues had mostly been mitigated. FastCGI solved the issue of process startup latency by keeping worker processes running and security was mostly a solved problem via user process isolation (at least on *nix hosts, I'm not sure about IIS CGI or ISAPI). Especially since mod_php was far more known for it's security issues in those days. The switch was 100% made due to ease of use and lack of desire to learn/manage/debug server architecture; the slight performance boost modules offered was a small cherry on top.
- pajko 3y agoThere was SCGI too: https://en.wikipedia.org/wiki/Simple_Common_Gateway_Interface https://en.wikipedia.org/wiki/Simple_Common_Gateway_Interfac...
- pjmlp 3y agoThat is still how my private site works, and how I do side gigs for Web development.
- sgbeal 3y ago> ... and things like Cron jobs ... didn't exist Funnily enough: i once maintained a site for a client whose hoster implemented cron jobs as client-defined URLs, which could point to your CGI or PHP scripts. The provider would hit the URL (which was presumably private) on a cron-style schedule, providing a castrated semblance of cron jobs.
- layer8 3y ago> the fact that C is annoying to write and debug a web app in. Weren’t most CGI scripts written in Perl? At least that’s what I remember.
- pajko 3y agoOr bash. Or python.
- throwawaaarrgh 3y agoPHP took the market away from Perl from the late 90s onward as it got more features. There were still tons of Perl CGI scripts but PHP was miles easier, and it eclipsed Perl in adoption many times over. By the mid 2000s, a very large site written in Perl was oddly antiquated (the P in "LAMP" changed from Perl to PHP) PHP was basically the server-side JavaScript of its time. But as programming trends changed, and more and more went "client-side", more JS frameworks popped up, until Node appeared, and then there was no need to learn two languages to make a web app. Python and Ruby had their time, but neither were as dominant as PHP was or JS became.