CGI Simplicity
A while ago, I read a book called “Insanely Simple: The Obsession That Drives Apple’s Success”, by Ken Segall. In short, it talks about the idea of making the simplest thing possible when doing something, specifically in the case of Apple. While I don’t remember much about the contents of the book itself, the idea of keeping it simple kind of stuck with me.
I don’t yet see myself as someone who always does the most simple thing, especially when coding; that desire to make my program do things perfecty, or do everything, is always kind of there, nagging. But every so often, I try to step back and look at what I did or what I’m trying to accomplish, and think “Am I overcomplicating things ?”.
This question is often answered with a resounding “YES!” in the front-end world. Serving 10 html files now requires a handcrafted blog webserver, using 11ty or Astro, of course, and webpack, and a CMS to host your content separately, etc. .
Now, some websites do require a certain level of complexity ; I don’t think it’d be all that smart to try to run Rock Paper Simmer on a jekyll site. But for personal blogs and small websites, I’ve seen advice like “just use 11ty” (using 11ty as an example, I didn’t actually try it as I couldn’t understand what to do from the docs) thrown so many times, because “jekyll will get in your way”.
But what if there was another, simpler way of running dynamic content on your site ? What if you could run the same kind of scripts you did on your computer ? What if all you needed was bash ?
Enter: CGI
This hypothetical solution is actually how big parts of the web used to work : CGI !
If you’ve ever seen cgi-bin
in a url, that’s the same
CGI I’m talking about: Common
Gateway Interface. Basically, when you make a request to a
CGI-handled URL on your server, the script is ran with a bunch of
environment variables, including the requested URL, the client’s IP,
etc., and whatever it printed would be the response sent to the
client.
That’s it !
And it works with practically any language: perl, bash, php, python, whatever, as long as it can read environment variables (sorry, brainfuck fans!) and print to stdout.
I’ve now added “CGI support” to this site (read: I enabled one nginx option), and I can just feel the spark, the pleasure of “just doing things” that I think made me love programming.
I’ve been feeling for a while that writing scripts is a good way to force myself to “just do things”. I don’t have unlimited capabilities, I can’t make a thousand classes to try to model everything perfectly (hello, java!), and it’s harder to make a truly bloated program, or at least easier to trim it to not be bloated.
Especially with linux, writing scripts is absurdly easy: you can use bash, which you’re already using anyway via your terminal. If you don’t really like bash’s particularly annoying syntax, you can use any one of the thousand scripting languages available.
Scripting is a love language, and one I’m perpetually enjoyed to learn and use.