86 comments

  • DannyBee2 hours ago
    I wrote &quot;CGI Programming Unleashed&quot; when I was 16, a scant 31 years ago (it was published in 1996, but not written in 1996). So this sort of brings me back. Almost as much as watching people review the book 20 years later and be like &quot;it seems dated&quot;.<p>I think the conclusion that CGI made sense to die then but not now is probably correct, but for a different reason.<p>The main reason CGI died in large part is because it wasn&#x27;t fast enough. Not the only reason for sure, but this is the general consensus. Spawning cgi children was slow, etc. Solutions were built to do in-process CGI, or separate CGI daemons. This even happened per-language with in-process CGI support for Perl, etc.<p>In the end, as people wanted more speed, they moved away from CGI to various other ways of doing things (client side, etc).<p>This aspect probably no longer makes sense - i&#x27;d be shocked if you couldn&#x27;t make CGI &quot;fast enough&quot; these days without anywhere near as many hoops. To the degree hoops are necessary, they are probably saner to implement.<p>That doesn&#x27;t mean folks should move back to CGI of course - but as i said, it is probably accurate that the main reason it died probably does not hold up anymore.
    • pjmlp1 hour ago
      In a way we kind of moved back to CGI, it just happens we call it serveless nowadays. :)
      • wannabe4452 minutes ago
        If I don&#x27;t invoke the serverless for a whole day, I don&#x27;t have to pay for it.<p>Irony is that it&#x27;s most useful for hobby projects. In production I&#x27;d not use it.
  • ramses021 hours ago
    My favorite trivia is that busybox has built-in cgi-bin support (and `rclone serve webdav` seems remiss to not mention as well). `<a href="https:&#x2F;&#x2F;elixir.bootlin.com&#x2F;busybox&#x2F;1.37.0&#x2F;source&#x2F;networking&#x2F;httpd.c#L2401" rel="nofollow">https:&#x2F;&#x2F;elixir.bootlin.com&#x2F;busybox&#x2F;1.37.0&#x2F;source&#x2F;networking&#x2F;...</a>`<p>Everything the post mentions is 100% true and well-reasoned, especially with the inclusion of pledge&#x2F;chroot&#x2F;etc. for dropping privileges.<p>There&#x27;s two diametrically opposed deployment mechanisms:<p>1) stack towers of glop on top of each other until you&#x27;re running a simple `echo &quot;hello world&quot;` on top of a docker container inside a vm in a proxmox server as part of a k8s cluster under a hypervisor running on remote compute...<p>2) just run `bash -c &#x27;echo &quot;hello world&quot;&#x27;` and front it with CGI (stateless, single binary, yada yada yada...)<p>Take a peek at <a href="https:&#x2F;&#x2F;github.com&#x2F;Domain&#x2F;bash.cgi" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Domain&#x2F;bash.cgi</a> ... not that i&#x27;m suggesting that &#x27;bash over busybox using cgi-bin&#x27; is the &quot;proper architecture&quot;, it&#x27;s more trying to illustrate that the amount of code that holds you back from being nearly truly &quot;frameworkless&quot; is tiny and easy to reason about.<p>For some of the internal tooling I&#x27;m doing for work, I&#x27;ve been tending towards:<p><pre><code> some-cmd [--json|--markdown] ...yet-more-args... </code></pre> When you use the process and shell environment itself as a repl, you start trending towards `[--cgi-bin]` would &quot;just&quot; be another output type, and the ability (nay: foresight!) to ensure that your commands are independent, reproducible, and only depend on their input arguments leads you directly towards being runnable in both &quot;hostile&quot; (ie: firecracker vm &#x2F; lambda-style) or very &quot;comfortable&quot; environments (ie: shell, debuggers, unit&#x2F;integration tests).
    • rpdillon20 hours ago
      Mirrors my experience, and it&#x27;s funny you mention busybox: I just discovered busybox&#x27;s ability to serve via `busybox httpd -p 9000 -h . -f -v` with a `cgi-bin` folder dropped in the current directory.<p>I already write Python services using Bottle that function both as a standalone server and as a CGI script, and I&#x27;ve been updating them to work with busybox&#x27;s more constrained CGI environment (basically being able to handle the lack of .htaccess rewrite rules).<p>I definitely see a chance for simple deployment tools to make a resurgence as we create more one-off&#x2F;disposable&#x2F;personal software, and the low system requirements for something like busybox + lua stack are extremely minimal, which fits well with the current DDR4-is-good-enough zeitgeist. I&#x27;m running them on an old Raspberry Pi 2B and it&#x27;s plenty performant for the ~10 people that access it regularly.
      • MomsAVoxell20 hours ago
        Instead of busybox+Lua, I just use TurboLua:<p><a href="https:&#x2F;&#x2F;turbo.readthedocs.io&#x2F;en&#x2F;latest&#x2F;" rel="nofollow">https:&#x2F;&#x2F;turbo.readthedocs.io&#x2F;en&#x2F;latest&#x2F;</a><p>Event driven, fast, all the networking basics in place including http, mustache templates and encryption, light and small executable, very nice for embedded applications, signals and fd handling built-in, very easy to use…<p>Have used it very successfully for million-dollar projects, including some scientific applications running on limited-resource systems (512 megs of RAM) ..<p>Was very, very easy to add C functions to interface with the web front-end, libffi is great for this purpose, but its also very easy to extend as a standard, well-written Lua&#x2F;C application ..
        • rpdillon19 hours ago
          This is exactly the sort of thing I&#x27;m really interested in. I&#x27;m particularly excited about various takes on Lua+batteries, have looked into designing my own (C wrapper with bindings to networking, JSON, templating, and DB libraries), but found Redbean to be almost ideal so never got past overall design to dig into code.<p>Turbo looks fantastic, though! It&#x27;s precisely the niche I was looking to have filled, so I&#x27;ll build a prototype or two in it to see what I think. Very much appreciate the pointer!
          • MomsAVoxell19 hours ago
            You’re welcome - we share interests, I too am interested in the Lua+batteries approach to life - I’ve used Lua very successfully in many commercial projects, so I’m quite convinced of its power in spite of the warts and thorns that many newbies in the ways of Lua tend to whine about.<p>TurboLua is particularly great because it really integrates about all of the I&#x2F;O mechanisms you could want in a network-centric application, plus it has a pretty nice runtime loop which is easy to hook into and coordinate properly with signal handlers and fd sets and things. Can’t beat it as a very quick way to do embedded stuff too - very easy to do gpio, signal handling, etc.<p>Good luck, if you have time to share your thoughts after an initial first-pass, I’d be happy to hear your perspective ..
        • Bluestein10 hours ago
          &gt; limited-resource systems (512 megs of RAM) ..<p>I am offended on behalf of all for whom that is more RAM than their first computer had :)
          • BobbyTables29 hours ago
            Having a computer with 256MB of RAM was once my dream …<p>Seemed like a lot when I only had 2MB…
            • Bluestein5 hours ago
              What was that Gates quote again? (No. Not the one from his latest, AI-oriented diatribe ...)
          • MomsAVoxell7 hours ago
            Yes, I know. I learned to program on a system with 64k, which was only fully available if one used assembly.<p>512 megs is not a lot for an embedded Linux project these days, but it can do a lot. Especially if you use Lua. ;)
        • mathnode7 hours ago
          This is the first I am hearing about turbo lua, very cool! I was aware of openresty but I still resorted to flask for quick endpoints or concepts. This changes things for me.
        • JSR_FDED9 hours ago
          Fantastic, thanks. I love Lua and especially the mindset that goes along with it. Will definitely check this out. Combining it with Datastar could be brilliant - I wonder if TurboLua supports SSE streaming.
          • MomsAVoxell7 hours ago
            All the basics are there (chunked mode), I think you’d only need to do some thing things:<p><pre><code> local SSEHandler = class(&quot;SSEHandler&quot;, turbo.web.RequestHandler) function SSEHandler:get() self:set_async(true) self:set_header(&quot;Content-Type&quot;, &quot;text&#x2F;event-stream&quot;) self:set_header(&quot;Cache-Control&quot;, &quot;no-cache&quot;) self:set_chunked_write() -- first event self:write(&quot;data: hello\n\n&quot;) self:flush() -- later events via IOLoop local ioloop = turbo.ioloop.instance() local count = 0 local timer timer = ioloop:add_timeout(1000, function() count = count + 1 self:write(string.format(&quot;data: tick %d\n\n&quot;, count)) self:flush() if count &lt; 10 then timer = ioloop:add_timeout(1000, timer) -- reschedule else self:finish() end end) end</code></pre>
    • fr202913 hours ago
      [dead]
  • OleksandrC21 hours ago
    For people who find interest in weird web applications, I have been working on a game project, in C++, where the client is compiled to WebAssembly with Emscripten, and the application server is also implemented in C++ (behind nginx).<p>This is from pre-AI era also. The game is Civ-like. Custom engine from scratch (including both the 3D stuff, and all the web handling also).<p>Take a look: <a href="https:&#x2F;&#x2F;statebuilder.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;statebuilder.com&#x2F;</a>
    • hughw20 hours ago
      It&#x27;s beautiful
    • fercircularbuf10 hours ago
      I&#x27;m also working on an educational game project in C++ compiled to WebAssembly with Emscripten. Absolutely awesome to work with.
    • HugoDz3 hours ago
      Very cool!
    • nmstoker17 hours ago
      Nice. I know your comment was on the technical points, but it definitely under sells the game!
    • Transformanshen17 hours ago
      That&#x27;s cool
    • Teever15 hours ago
      I&#x27;m doing something similar but with a Red Alert++ type of game with C and WebAssembly and Emscripten.<p>It&#x27;s something I&#x27;ve been picking at in my free time but these posts from the last week regarding game decompiling old games and rebuilding the as web apps have inspired me to pick it up again. It&#x27;s interesting to me how many people were critical of the performance of these games and that recent Sim City clone definitely had my laptop fans whirring but I find that my game doesn&#x27;t have any of these performance issues. Performance-wise WebAssembly and Emscripten seem remarkable, and I haven&#x27;t even added SIMD or multicore functionality yet.<p>One of the nice features about building it this way is that the desktop version can easily interface with 3d model &#x2F; image generators which I intend to in the desktop unit-editor to generate assets for the game.<p>The pipeline that I&#x27;m envisioning is a 3d model generator that pushes the models into Blender to generate different perspective stills of them and then feed that to a stable diffusion image generator that paints them and a unit icons and such, and a voice model that generates their &quot;ready to serve&quot; peon type sounds when you click on them. I&#x27;m picturing a system that I can leave over night unattended to generate a bunch of units that I can look at in the morning to add to the game if I like them.
  • assimpleaspossi19 hours ago
    I started a web dev company 22 years ago after developing an online menu ordering system for a restaurant I owned. I, then we, did pretty much the same thing as talked about in the posting but we used fastcgi. I started with C because I knew C. That was my real job. It ran so well, the franchise bought the software from me--and then devolved it to all the Microsoft stuff and had issues upon issues from then on out. That&#x27;s another story.<p>I continued to make sites for other venues that needed online ordering; such as theatre companies and restaurants. All in C, fastcgi, FreeBSD, postgresql and h2o-server cause it always did what we wanted without bending to someone else&#x27;s rules. It was fast and easy to make changes while changes weren&#x27;t made for us or without our consent. We did very well for ourselves.
    • glouwbug18 hours ago
      Feels so long ago the way you write about it, but 22 years ago was basically 2005
  • peter_retief10 minutes ago
    I never understood why we abandoned cgi apps rather than fixing them.<p>Not sure why but it probably had something to do with Microsoft and the browser wars.<p>Is it time to fix web development?
  • benlivengood20 hours ago
    Golang also makes it possible to serve a web site or service from a single binary. You can even avoid linking libc if you stick to core Go (CGO_ENABLED=0), and it comes with all the http and tls libraries you need to replace the traditional web server (nginx, apache, httpd) as well.<p>I love C and wrote some CGIs in C in the past but I don&#x27;t love concurrent programming in C. While forking and execing can use shared read-only mmap on .text segments, the .bss and .data will need initialization and copying; there&#x27;s unavoidable startup overhead that a threaded process avoids, and raw pthreads is kind of painful. If all you need to do is serve a low traffic site, CGI is fine.<p>My biggest worry would be how often the SQLite DB gets backed up because there&#x27;s no way a C web server will be free of RCEs in today&#x27;s world.
    • ncruces17 hours ago
      Shameless plug: if you value Go, <i>and</i> CGO_ENABLED=0, <i>and</i> SQLite, <i>and</i> are worried about C in a web server and RCEs, may I interest you in my SQLite driver?<p><a href="https:&#x2F;&#x2F;github.com&#x2F;ncruces&#x2F;go-sqlite3" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ncruces&#x2F;go-sqlite3</a><p>I just wrote up the security goals of the tool I use to translate C to Go: <a href="https:&#x2F;&#x2F;github.com&#x2F;ncruces&#x2F;wasm2go&#x2F;blob&#x2F;main&#x2F;SECURITY.md" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ncruces&#x2F;wasm2go&#x2F;blob&#x2F;main&#x2F;SECURITY.md</a><p>I obviously can&#x27;t make any promises, as it&#x27;s just a personal pet project, but those are the goals, and they do catch memory corruption bugs in practice: <a href="https:&#x2F;&#x2F;sqlite.org&#x2F;bugs&#x2F;forumpost&#x2F;543f94984b" rel="nofollow">https:&#x2F;&#x2F;sqlite.org&#x2F;bugs&#x2F;forumpost&#x2F;543f94984b</a>
      • bheadmaster5 hours ago
        FWIW, there&#x27;s modernc.org&#x2F;sqlite which already provides pure Go sqlite implementation.<p>Might be useful to test your own implementation against.
        • ncruces4 hours ago
          I do. I had it listed in my own README as an alternative for a long, long time, and both show up in these often posted benchmarks: <a href="https:&#x2F;&#x2F;github.com&#x2F;cvilsmeier&#x2F;go-sqlite-bench" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;cvilsmeier&#x2F;go-sqlite-bench</a><p>But for the point I was making, it is in fact <i>not</i> an alternative. In my version each SQLite connection is confined to a sandbox, and a C memory bug <i>cannot</i> corrupt the Go runtime, call stack or heap. In their version, a C pointer becomes an unsafe.Pointer that can address all Go memory.
    • HackerThemAll6 hours ago
      &gt; there&#x27;s no way a C web server will be free of RCEs in today&#x27;s world.<p>That&#x27;s a bold claim not supported by facts. The following one had not had any RCE for 27 years, since its inception, and counting. I am certain there are more C web servers written securely.<p><a href="https:&#x2F;&#x2F;cr.yp.to&#x2F;publicfile.html" rel="nofollow">https:&#x2F;&#x2F;cr.yp.to&#x2F;publicfile.html</a>
  • GuB-423 hours ago
    I wonder if it would be more efficient to skip httpd and implement the HTTP server directly in the app. It would be consistent with the idea of using C with very few dependencies, give a lot of flexibility, and avoid the overhead of CGI.<p>Implementing an HTTP server from scratch in C is quite simple, clients are harder though, so I would keep using libcurl.<p>HTTPS can be tricky though, so you probably want to delegate this part to a reverse proxy.
    • hmry3 hours ago
      I personally found implementing an HTTP2 server from scratch quite difficult. The parsing and state machine was okay (and is also the easiest part to get from an external library), but correctly handling stream priority &#x2F; bandwidth sharing and backpressure was really hard. Of course one could go HTTP1.1-only, but then you&#x27;re losing out on the efficiency gains anyway :&#x2F;
    • Retr0id3 hours ago
      &gt; Implementing an HTTP server from scratch in C is quite simple<p>Implementing <i>an</i> HTTP server is easy, but implementing a fast, feature-complete and secure one is complex.
    • jacquesm3 hours ago
      HTTP is easy, HTTPS much, much harder. Also, in HTTP there are plenty of footguns that can lead to security issues if you&#x27;re not super careful. That goes for C in general but in particular doing this with un-sanitized input straight from the net into your application is not a path I would recommend.
    • cavoirom3 hours ago
      httpd is really minimal, it event doesn&#x27;t have compression built-in, skipping it don&#x27;t bring much benefit. OpenBSD provided a cozy environment for system operator by default.
    • coolius3 hours ago
      sounds like a security disaster just waiting to happen
      • GuB-422 hours ago
        Done well, not really. As I said, it is not that hard and not that big, a thousand lines of code maybe, maybe two or three if you support a few extensions. There are some footguns, but most of them related to reading the documentation of system calls carefully. And we are in the age of LLMs, and LLMs are very good at noticing edge cases you forgot, especially if you didn&#x27;t vibe-code the thing in the fist place. That&#x27;s in addition to traditional tools, such as sanitizers, linters, and fuzzers.<p>What you gain by rolling your own instead of using a battle tested solution is a reduced attack surface. For example, an off-the-shelf HTTP server may be tricked into revealing the content of a file the user should not have access to, but if your custom server doesn&#x27;t read files at all (you don&#x27;t even make a open()) because everything is in RAM, or hardcoded in the executable itself, then such a vulnerability cannot exist. You may also decide to allocate most of your memory statically, because you know in advance how much you will need, and doing that, eliminate an entire class of potential vulnerabilities. An off-the-shelf HTTP server doesn&#x27;t have this luxury.<p>And with one less dependency, you are also less vulnerable to supply chain attacks.
  • Hendrikto2 hours ago
    &gt; I was hesitant to write the entire frontend in C, but it wasn&#x27;t nearly as painful as I imagined.<p>&gt; All too many times have I:<p>&gt; * Fought vim to highlight Go&#x27;s html&#x2F;template syntax.<p>&gt; * Fought helix to detect Go templates without breaking html detection.<p>&gt; * Fought rustrover to recognize jinja templates for a project using askama.<p>&gt; Using C means there&#x27;s no second language for your editor to half-detect, no mixed-syntax where highlighting falls apart, no plugin dance to get the two languages to cooperate.<p>None of that has to do with C. You can apply the exact same approach in Go, or in any other language for that matter.
  • hughw20 hours ago
    I disagree with the first sentence. In 199x the first people I knew making web pages dropped perl scripts, not C programs, into cgi-bin.
    • jim_lawless2 hours ago
      I was writing them in C in 1995. I published this article explaining how to write a C CGI program in DDJ that hit the newsstands in Fall of 1995.<p><a href="https:&#x2F;&#x2F;jimlawless.net&#x2F;articles&#x2F;ddj95&#x2F;index.html" rel="nofollow">https:&#x2F;&#x2F;jimlawless.net&#x2F;articles&#x2F;ddj95&#x2F;index.html</a>
    • nkozyra20 hours ago
      May have pre-dated you by a bit. Perl definitely took foot not long after but the earliest cgi-bin days were dominated by C before people got tired of fighting compilation for web apps.<p>IIRC the spec itself says it was built for C applications.<p>mod-perl was a godsend, of course.
    • pjmlp1 hour ago
      As I discussed on the Zig thread a few days ago, some of us were actually using C, alone or mixed with scripting languages.<p>For example, it wasn&#x27;t uncommon to have C extensions for Perl scripts dropped into CGI directory.
    • minaguib20 hours ago
      Perl&#x27;s CGI.pm was updated as recently as 5 months ago :)<p><a href="https:&#x2F;&#x2F;metacpan.org&#x2F;pod&#x2F;CGI" rel="nofollow">https:&#x2F;&#x2F;metacpan.org&#x2F;pod&#x2F;CGI</a>
    • PaulDavisThe1st19 hours ago
      We did the CGI-bin in C thing at amzn in 1994.
    • forinti18 hours ago
      I learnt Perl because I had to make a page with a form that would then be turned into Postscript and printed. My only options were C, which I knew well, and Perl, which I had never seen before. So I got to learning Perl. Doing it in C just seemed like too much work for the task.
    • icedchai18 hours ago
      Same. My first &quot;web app&quot; was a Perl CGI that saved data to mSQL (not MySQL), probably early 1995.
    • rjrjrjrj19 hours ago
      I started using Perl in 1996.<p>But the very first CGI scripts I wrote were in C, late 95 or early 96. Apache on Slackware Linux.
    • layer818 hours ago
      I still have such Perl scripts deployed, though using FastCGI.
    • fleeno16 hours ago
      My first CGI programs around that time were in bash! I wrote so much useless but fun things back then.
    • Udo5 hours ago
      I dropped Pascal programs in there, because it was the language I knew best, good times! It was really slow, too, because the bundled runtime had a massive startup time.
    • user012039712519 hours ago
      [dead]
  • RandomMarius1 hour ago
    I never thought it would come full circle, but here we are. I&#x27;ve helped develop and huge UI application in C&#x2F;C++ using basically zero frameworks (Used ImGui) and is being used productively by many people and is stable. It runs on Mac, Windows, and Linux. But have also got it fully working on Wasm64. Anything less than WASM and it would have buckled under the load. It&#x27;s beautiful on Web.<p>A few years ago one would have thought that it would not be worth the pain to develop it in C, now with AI that is no longer a concern as well, and we&#x27;re so glad we did not compromise.
    • bagacrap1 hour ago
      Does ai not footgun itself in C?<p>I only use it in C++ but I&#x27;m glad to have memory safe constructs and other modern primitives to keep it somewhat verifiable by me.
  • Levitating22 hours ago
    CGI is great. Sadly nginx doesn&#x27;t support it natively as opposed to lighttpd.<p>I like this project for adding CGI to nginx: <a href="https:&#x2F;&#x2F;github.com&#x2F;pjincz&#x2F;nginx-cgi" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;pjincz&#x2F;nginx-cgi</a><p>There&#x27;s also methods of starting Rack applications directly form nginx via passenger[1]. Rack is the CGI like interface for ruby webapps: <a href="https:&#x2F;&#x2F;github.com&#x2F;rack&#x2F;rack" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rack&#x2F;rack</a> It easily allows for writing applications and middleware with a few lines of ruby.<p>[1]: <a href="https:&#x2F;&#x2F;www.phusionpassenger.com&#x2F;documentation&#x2F;Users%20guide%20Nginx.html" rel="nofollow">https:&#x2F;&#x2F;www.phusionpassenger.com&#x2F;documentation&#x2F;Users%20guide...</a>
    • synergy2020 hours ago
      I just use lighttpd
      • Levitating18 hours ago
        I used it for a long time but the configuration of nginx just allows for more stuff.<p>I have my own configuration template for nginx: <a href="https:&#x2F;&#x2F;git.levitati.ng&#x2F;Levitating&#x2F;nginx.conf" rel="nofollow">https:&#x2F;&#x2F;git.levitati.ng&#x2F;Levitating&#x2F;nginx.conf</a>
    • BirAdam22 hours ago
      fastcgi wrap.
      • assimpleaspossi19 hours ago
        Exactly what I used and wonder why the OP didn&#x27;t. I&#x27;ll comment at the top.
        • Levitating18 hours ago
          Ease of configuration, I think? I don&#x27;t remember my gripes with fcgiwrap exactly.<p>I have used it and I&#x27;ve even made PR for it which led to a response from the lighttpd maintainer: <a href="https:&#x2F;&#x2F;github.com&#x2F;gnosek&#x2F;fcgiwrap&#x2F;pull&#x2F;62" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;gnosek&#x2F;fcgiwrap&#x2F;pull&#x2F;62</a><p>Essentially I wanted fgciwrap to be able to accept arbitrary response bodies without headers, so I could use it with programs that weren&#x27;t actually made for cgi. Lighttpd supports this but apparently that&#x27;s an happy accident.
    • huijzer20 hours ago
      But the real question is, does Caddy support it?<p>The answer is: it does but via community plugins.
    • zelcon12 hours ago
      You can write a ngninx module. That would be the actual 2026 way to write C web apps. Used to be a huge pain, but now AI can just read the nginx source and do it correctly.
  • unixholder17 hours ago
    The deeper you go into complex web technologies &amp; frameworks, the more obvious it becomes that simplicity wins.
    • sthuck8 hours ago
      yes, but when I think simplicity I don&#x27;t think string handling in C
  • makz45 minutes ago
    I don&#x27;t understand how are they writting html in C. Is it like they are doing puts(&quot;&lt;html&gt;&quot;);?
  • brainless12 hours ago
    I remember CGI days and I have written tiny web &quot;features&quot; with Perl and C many years ago. All my product backends are now in Rust and SQLite but I use frameworks and libraries. Like Tokio, Auxum&#x2F;Actix Web, Diesel.<p>I am not sure I like the idea that the binary will be called by nginx on each request. I prefer the backend binary to have state. A 256 MiB virtual instance is enough for any software shared between friends, family or even a small community.<p>SQLite backups are easy. I really like how I am building web apps these days. Been with PHP for 7 years and then Python for 10+ years. Single binaries are awesome. I am looking at multi-server backends as well, still 256 - 512 MiB per instance but with a shared Redis. Still with SQLite. Should easy enable medium sized business software.
  • melasadra9 hours ago
    I am very surprised at the lack of pushback. Seems like most is just glazing the simplicity of C.<p>I know very little of web technology, just a faint memory from when I took Odin Project years ago.But surely there are hackers out there that can give us good justification why we currently need such a long list of stack?<p>Why do people use : TypeScript + React + Next.js + Tailwind CSS + shadcn&#x2F;ui + PostgreSQL<p>I honestly dont know.<p>Are these still needed in 2026<p>Maybe in just some use cases such as high interactivity + needing to scale ?
    • bottlepalm9 hours ago
      In 2026 the stack is SQLite + Rust + AI<p>As long as the tokens keep flowing we&#x27;ll all be fine. If they stop flowing we&#x27;re going to be boned with this mountain of low level software we&#x27;re creating that will need to be maintained. Let&#x27;s not think about that.
      • Gormo3 hours ago
        Well, the only way the tokens will stop flowing is if your CPU and GPU stop working, at which point you have bigger problems than what languages your programs are in.<p>And unless you&#x27;re writing in assembly or raw machine code, &quot;low level&quot; isn&#x27;t quite the right terminology. There&#x27;s nothing more inherently complex about maintaining code in Rust, Go, or even C than in TypeScript or JS.
    • lelanthran2 hours ago
      They&#x27;ve never been <i>needed</i>, well, maybe postgresql is.<p>You can get quite far with boring enterprise stack.
    • prmoustache3 hours ago
      &gt; Are these still needed in 2026<p>Need has never been the correct word.
    • chr15m8 hours ago
      Software developers love complexity. They love to construct huge beautiful towers of the stuff.<p>Also it&#x27;s the code version of this old phrase: (&quot;I Had More Time, I Would Have Written a Shorter Letter&quot;) <a href="https:&#x2F;&#x2F;quoteinvestigator.com&#x2F;2012&#x2F;04&#x2F;28&#x2F;shorter-letter&#x2F;" rel="nofollow">https:&#x2F;&#x2F;quoteinvestigator.com&#x2F;2012&#x2F;04&#x2F;28&#x2F;shorter-letter&#x2F;</a>
    • pjmlp8 hours ago
      We don&#x27;t.<p>Given the option, I will always go to a Java or .NET framework.<p>Using anything other than that, the decision wasn&#x27;t done by me, rather my employer or customer.<p>The only reason I would not expose C or C++ directly into the Internet, is as Gen X I have been there, and don&#x27;t miss the possible security issues, which I also failed to match 100% even though we already used tools like Purify, BoundsChecker and Insure++.
    • kbrannigan9 hours ago
      Model are trained on them in 2026 .<p>Me Raw php .<p>Many people here have machines that can handle all of AOL , yahoo, msn of 2001 combined in their closet .<p>I have been going backwards in time as an experiment . I use mature extremely documented tools . Has to be at least 20 years old
    • Quothling8 hours ago
      You don&#x27;t need all those things, and for the most part you likely never did. Today I think most of it is legacy. A member of one of my teams recently wrote a node template for azure function apps, and when I reviewed it I asked them why they were using 20 dependencies when they needed 3. There was a lot of reasons, but the main reason was &quot;that&#x27;s what we&#x27;ve always done&quot;. One of these prevented updating to typescript 7 which is why I was reviewing it to begin with. A day later they&#x27;re down to 4 dependencies that are actually being used for something useful.<p>SPA&#x27;s and their frameworks still have their use cases. I don&#x27;t think you can really get full &quot;simplicity&quot; when you have a lot of people working on the same code that goes into enterprise production. I do think that a lot of the more complicated stacks mainly exist because &quot;that&#x27;s how we&#x27;ve always done it&quot;. Which is frankly also a fair consideration if you&#x27;re not in a position where changing it would generate a lot of value.<p>I find that it always comes down to people. The fewer people you are, the easier it is to make rapid changes. With a lot of people, and maybe people with very different backgrounds and skill-sets things changes. Change management isn&#x27;t easy, and often the actual tech stack will matter a lot less than building a good team around it. You obviously still want to work toward changes and approvements, but switching a 100 people from their safe and overly complicated tech stack to something else will take a while. You&#x27;ll also have to be damn sure it&#x27;s worth it.
    • locallost4 hours ago
      I would argue the need to scale, but not the tech. Instead it was scaling the people. Around 15-20 years ago you had a much clearer separation of tasks, e.g. back and frontend work. So you could have people that just wrote HTML and CSS with a bit of JavaScript. To be fair, doing that was a lot more difficult back then than today, regardless of AI. A lot of this has gone away as &quot;full stack&quot; became more and more of a thing.<p>I think the author of the article has the right idea, although they do not use AI. But I think with AI now, people are anyway stepping out of what they would normally dare do, and so one person can accomplish more than before. So it makes sense to simplify again, although again I think for most people this will mean use AI.
  • cube007 hours ago
    &gt; Process forking isn&#x27;t nearly as expensive as it was; modern kernels optimize it heavily.<p>When I start to dig into how complex async is to debug I&#x27;m really starting to come back around to regular forking.
  • Panzerschrek22 hours ago
    &gt; There&#x27;s no separate database server. You open the database file through SQLite&#x27;s C API.<p>&gt; Every request spawns a fresh process.<p>How does it work when multiple concurrent requests are possible? Does SQLite allow simultaneous write access from multiple processes?
    • citrin_ru21 hours ago
      SQLite does allow write access from mulitple processes - file locks (fcntl) are used to ensure at any given moment only one of processes modifies the database (or WAL if WAL is enabled).
    • prophittcorey21 hours ago
      SQLite can handle multiple concurrent requests if it&#x27;s set to WAL mode. Reading is all non-blocking&#x2F;concurrent but writing is still synchronous. You should also set the &quot;busy timeout&quot; or else your blocked writes will timeout immediately.
    • tomjen317 hours ago
      In Wal mode you can have multiple readers. Writers block, but because there is no network traffic, the writers finish very quickly, so in practice you don&#x27;t usually wait that long.
    • warkdarrior21 hours ago
      Users who send concurrent requests will be summarily banned and their data deleted. It&#x27;s the only way to be sure.
    • huijzer20 hours ago
      SQLite is a database. The main idea of a database is to support concurrent reads&#x2F;writes although databases differ in how much concurrency they allow
      • td521534f1220 hours ago
        The answer is more complicated for SQLite: <a href="https:&#x2F;&#x2F;sqlite.org&#x2F;isolation.html" rel="nofollow">https:&#x2F;&#x2F;sqlite.org&#x2F;isolation.html</a><p>&gt; There can only be a single writer at a time to an SQLite database. There can be multiple database connections open at the same time, and all of those database connections can write to the database file, but they have to take turns.<p>However, it can also be configured in WAL mode where the single writer is applying WALs while the applications append to the log.
      • sophacles19 hours ago
        The main idea of a database is to support storing data in a structured and queryable way. Concurrency came later.
  • bijowo167620 hours ago
    Author described good ole PHP 3.<p>Early PHP (3 and 4) were the thin layer over the C libraries and were pretty fast and easy. it came about right when CGI was deprecated and it solved CGI&#x27;s problems
    • zelcon12 hours ago
      That’s ironic because 99% of PHP code today is served using PHP-FPM which is essentially a FastCGI wrapper around PHP.
  • ok12345620 hours ago
    A Go binary with CGO=0 and all templates&#x2F;documents embedded gives you a better overall tooling and deployment experience. Put it in a scratch container for complete isolation.
    • doublepg2320 hours ago
      CGO=0 came in clutch at previous job when we were deploying Go apps compiled on builders that had a newer glibc than the actual prod server.
  • noduerme3 hours ago
    I reallllly appreciated the coder&#x27;s explanation of the C executable.<p>But the website itself is awful. I mean, it&#x27;s impossible on desktop or mobile to tell what buttons are active or disabled. There is basically no UI at all to tell you what you&#x27;re dealing with or what you get if you unlock it by signing up.<p>And I&#x27;d say I appreciate the raw simplicity of the dark mode interface, except it also <i>looks</i> like it&#x27;s LLM-generated, even if it&#x27;s not.<p>So, I&#x27;m not sure what the gains were here, really. I like the hand-written approach, but wish it had some sort of personality. And not to be a debbie downer, but the purpose of this site is also to entice some long tail of small game developers to <i>pay to feature their games with influencers on youtube, twitch, etc.</i> which, as a business model, fine, parasitic but fine, but maybe the most depressing thing I&#x27;ve seen all year even in the middle of the death of most of the industry. On top of that, you&#x27;re making people pay to sell dead games to dead-eyed streamers on a site that looks like a fucking mortuary. At a glance, there are even more influencers dying to get paid on this site than there are shitty AI slop games going out now; and I don&#x27;t even know who&#x27;s playing them; so <i>zayt gezunt</i> to everyone involved.<p>The best thing about this is that it was written in C, without AI. Ostensibly. Everything else about it makes me want to shoot myself.<p>My art director critique: make some fucking bright pink rollovers on the buttons or something. At least. Add a stupid pink polar bear as a mascot. Don&#x27;t make me feel like I&#x27;m selling my soul to satan by signing up for it.<p><i>edit</i> I&#x27;m still confused by which assets were compiled into the C .exe. Are there assets?
  • mc00720 hours ago
    came back to C&#x2F;C++ for same reasons, no supply chain trouble, fits in my head, runs forever, ... here a playground for win32, using partially webview2, all batteries included, openai client , tts, stt, vpl, images, audio, video, ... comes with webview2 apps, settings (and encryption), config, rest server, ipc, testing, CLI11, postgres, installer, doc gen, modbus, OpenCV, daemon, computer use, agent memory, image tools, mcp server&#x2F;client, experimental flow editor - what a fun and exciting times :) <a href="https:&#x2F;&#x2F;github.com&#x2F;polymech-info&#x2F;win32-boilerplate" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;polymech-info&#x2F;win32-boilerplate</a>
    • anilakar5 hours ago
      &gt; no supply chain trouble<p>In other words, you are the supply chain. You&#x27;re responsible for the bugs you create, but at least they are <i>your</i> bugs not caused by upstream&#x27;s upstream&#x27;s upstream&#x27;s maintainer installing an infected JS library.<p>Shall we call this &quot;vertically-integrated programming&quot; then? :-)
    • codazoda17 hours ago
      I agree on &quot;fits in my head&quot;. I haven&#x27;t used C++ but I used to love ANSI C. I had a reference manual for it that was something like 30 pages and basically covered the entire language. There&#x27;s something magical about the compact size of regular C.
    • rietta17 hours ago
      It&#x27;s been a long time since I have tried to do Windows work in C&#x2F;C++. Is this Win32 the actual Win32 API of yesteryear or something else. I thought CMoke was a Unix tooling.
      • criddell16 hours ago
        Microsoft added CMake support to Visual Studio in 2017.
  • jjuel19 hours ago
    I just really wish it had some examples of code in there to get a better idea of what is really going on. It sounds interesting.
    • tomcam18 hours ago
      They use this framework: <a href="https:&#x2F;&#x2F;learnbchs.org" rel="nofollow">https:&#x2F;&#x2F;learnbchs.org</a><p>Their example is:<p><pre><code> #include &lt;err.h&gt; &#x2F;* err(3) *&#x2F; #include &lt;stdlib.h&gt; &#x2F;* EXIT_xxxx *&#x2F; #include &lt;stdio.h&gt; &#x2F;* puts(3) *&#x2F; #include &lt;unistd.h&gt; &#x2F;* pledge(2) *&#x2F; int main(void) { if (pledge(&quot;stdio&quot;, NULL) == -1) err(EXIT_FAILURE, &quot;pledge&quot;); puts(&quot;Status: 200 OK\r&quot;); puts(&quot;Content-Type: text&#x2F;html\r&quot;); puts(&quot;\r&quot;); puts(&quot;Hello, world!\n&quot;); return EXIT_SUCCESS; }</code></pre>
      • throwaway20378 hours ago
        That code sample comes from here: <a href="https:&#x2F;&#x2F;learnbchs.org&#x2F;easy.html" rel="nofollow">https:&#x2F;&#x2F;learnbchs.org&#x2F;easy.html</a>
      • hliyan12 hours ago
        Thank you for this. Incredibly simple.
  • Kuyawa18 hours ago
    The time is right for AI to generate a basic C web framework just like Node Express with request, response, template, cookies, auth, db, websockets and some other libs<p>It would be blazing fast, for use by AI itself<p>Just for fun
    • Shorel5 hours ago
      There&#x27;s already vibe.d. A web framework for D lang. Blazingly fast. The fastest webpages I have ever seen are the D lang forums. And it has the right name!<p>Better and safer than C. Much nicer for the programmer than Rust.
    • nostrademons17 hours ago
      Why C instead of Rust if you&#x27;re using AI anyway?<p>C introduces the possibility of memory-safety issues, which are deadly in server software that&#x27;s exposed to the Internet. And AI, from what I&#x27;ve seen, is not all that great at writing software with zero memory bugs.<p>Rust closes the memory safety holes, at the cost of making the programmer think through ownership and architecture much more carefully. Those are exactly the skills that AI is good at. So if you want something fast and are writing it with AI anyway, why not have the AI generate Rust code?
      • hollowonepl8 hours ago
        Rust comes with dependency hell comparable to NodeJs, and sorting out memory issues is experience not platform choice. Simplicity of C versus complexity of Rust plus Rust being a new “java” religion to solve C++ ain’t convincing to everybody. We had this religion already. Every new generation comes with an idea to fix C&#x2F;C++ while some still prefer to stay disciplined in the first one and let it fix itself.
      • joshheitzman16 hours ago
        Because the memory safety Rust offers isn&#x27;t worth the supply chain risks: <a href="https:&#x2F;&#x2F;safeguard.sh&#x2F;resources&#x2F;blog&#x2F;rust-supply-chain-security-landscape" rel="nofollow">https:&#x2F;&#x2F;safeguard.sh&#x2F;resources&#x2F;blog&#x2F;rust-supply-chain-securi...</a>
        • zanecodes16 hours ago
          A problem that C solves by simply not having a supply chain! You can vendor dependencies in Rust just as easily as you can in C; far easier in fact thanks to `cargo vendor`. Cargo won&#x27;t review them for vulnerabilities though, you&#x27;ll still have to do that yourself.
          • hollowonepl8 hours ago
            There is… standard library and posix standard or other system level libraries, once you learn them you discover you don’t need to auto download a library to convert string to bool that relies on 5 other stupid libraries to work all together.<p>Lean yet complete standard library is what should be preferred instead of that supply chain, especially in AI era that makes half of them obsolete and redundant.
            • skydhash3 hours ago
              And a lot of C&#x2F;C++ library are incredibly mature, so no need to update your code every 3 months just for dependency updates.
          • uecker9 hours ago
            &quot;Cargo won&#x27;t review them for vulnerabilities though, you&#x27;ll still have to do that yourself.&quot;<p>Cargo is a danger to society. People need to stop using these unsafe and dangerous technology.
          • 171862744016 hours ago
            It does, the package systems of C evolved alongside the OS, so they are now the OS package managers and also cope with all other language mangers.
          • Ygg216 hours ago
            C (and C++) has a supply chain. It&#x27;s called unpaid Linux maintainers.
            • throwaway20378 hours ago
              <p><pre><code> &gt; unpaid Linux maintainers </code></pre> In 2026, I would say most are paid, certainly all of the really important leads. They are employed directly by Linux Foundation, or by a tech giant, like Google, Meta, Amazon, IBM, etc.
              • Ygg27 hours ago
                Not Linux as in kernel. Linux as in distro. I doubt most of Arch, NixOS, GoboLinux, Slackware maintainers are on FAANG payroll.
                • prmoustache3 hours ago
                  RHEL&#x2F;Fedora SUSE&#x2F;OpenSuse, ubuntu then?
        • nostrademons16 hours ago
          Don&#x27;t use packages you didn&#x27;t vibecode and audit yourself then. That&#x27;s the situation C puts you in anyway.
          • joshheitzman15 hours ago
            The Rust ecosystem isn&#x27;t structured for the high friction dependency model the C has. Its structured around nearly frictionless dependencies so its no surprise that dependency trees are very large and frequently changing.<p>The typical C project has far fewer dependencies than the typical Rust project. Those dependencies are usually individually larger and either maintained by OS maintainers or there is a copy of the code that is built for the project and is readily available for audit. Those copies can&#x27;t change without direct action.<p>Its less trouble to setup static analysis, address sanitizer, and similar tools for a C project than it would be to manage local copies of thousands of dependencies for a Rust project.
            • nostrademons14 hours ago
              There&#x27;s nothing stopping you from <i>ignoring the ecosystem</i> and just using Rust with the stdlib. Remember that the context for this thread is AI-generated code. If the AI is writing it all, the code is effectively free, you can write tens of thousands of lines of it with a single prompt, you can customize it all to your specific use-case, and you can throw it away and have the AI write it again instead of maintaining it. Also as manual programmers we&#x27;re accustomed to programming being a team sport where you fit in gracefully into the ecosystem and build things with the maintainer and rest of the team in mind, but in the AI world, you can ignore the ecosystem, there is no maintainer (because you throw it away and have the AI write something else when the requirements change), and the rest of the team has all been laid off.<p>There&#x27;s a bunch of threads going on simultaneously on HN now about how people often misuse AI by applying rules of thumb learned from doing things as a professional to what they prompt the AI to do, rather than just asking it directly for what you want. This is one of those cases. Many of the rules of thumb of professional programming no longer hold under the radically different economics of AI-driven development.
              • joshheitzman14 hours ago
                &gt; If the AI is writing it all, the code is effectively free<p>Its not even close to free in either $, your own personal time, or calendar time.
              • uecker9 hours ago
                My assumption is that people are productive in Rust mainly because of the ecosystem, just like Python programmers are because they can download so many ready-to-use parts. The great mashup languages.
            • steveklabnik12 hours ago
              &gt; Its less trouble to setup static analysis, address sanitizer, and similar tools for a C project than it would be to manage local copies of thousands of dependencies for a Rust project.<p>It is trivial with Rust to set up asan and friends. You just<p><pre><code> $ RUSTFLAGS=-Zsanitizer=address cargo build -Zbuild-std --target x86_64-unknown-linux-gnu </code></pre> And you’re off to the races.<p>This works for your dependencies too. This isn’t C, you don’t need to manage all of those builds individually. That’s what the build system is for.
      • cozzyd16 hours ago
        supply chain, compile times, binary size
        • nostrademons16 hours ago
          Not huge problems for a web app, where you are controlling deployment yourself.
  • Retr0id2 hours ago
    I don&#x27;t think &quot;computers are faster now&quot; (and the unspoken &quot;LLMs write my code for me now&quot;) is a great reason to be using an inefficient design.
    • PaulRobinson2 hours ago
      What&#x27;s inefficient about this approach?<p>I&#x27;d wager a CGI written in C uses less memory and CPU than an equivalent application in any other language or framework. I&#x27;d wager this design has lower latency meaning higher throughput and therefore higher capacity, too.<p>Or perhaps you mean developer efficiency? Well, with the right tools you&#x27;re going to catch memory issues so they&#x27;re gone. It&#x27;s a tiny language you can keep in your head, so that&#x27;s not an issue - I&#x27;d argue you need an LLM to write good C (if you know what you&#x27;re doing), than to write good Java or Python.<p>I sure do love a modern language and environment (I spent years as a Rails dev, and I love me a bit of Elixir), but to argue that C is not efficient is kind of wild.
      • Retr0id1 hour ago
        The inefficient part is execing a fresh process on every incoming request. The article alludes to FastCGI etc. as alternatives but they&#x27;re still workarounds for a fundamentally inefficient architecture.
  • binaryturtle9 hours ago
    Wouldn&#x27;t it be even more ideal to have the webserver and app be one and the same binary, all bells and whistles included? No need for CGI at all. Just one static binary, no extra disk I&#x2F;O needed to load resources (all compiled in statically). Basically you can make the OS deny this app any additional disk access for additional hardiness.
    • athrowaway3z7 hours ago
      I&#x27;ve done what you described with Rust and 1 dependency. The reason to not do that is because TLS is a pain in the ass.<p>But more to your point, I think what makes this httpd scheme especially attractive (for C users especially) is that you can&#x27;t try to &quot;optimize&quot; anything. There is no temptation to lock&#x2F;mutex&#x2F;cache yourself into more problems. Its 1 process that then dies. Even &#x27;free&#x27; becomes optional in some cases.
      • Ono-Sendai4 hours ago
        What was the problem with TLS you ran into?
  • rjrodger2 hours ago
    My first web app in 1995 was also built like this!<p>Except I had no idea malloc existed and the whole thing was static arrays...
    • fps-hero1 hour ago
      That’s one way to avoid use after free bugs!<p>Most of my initial foray in programming was on microcontrollers, of which dynamic memory allocation came late.<p>Atmel ATMega didn’t support it at all. Rabbits supported allocation but not freeing, so, static memory with extra steps. It wasn’t until I was using cortex’s that the idea of using malloc was even entertained.<p>Even still today, I pretty much stuck with static global with reference passing or allocate everything at initialisation time. It’s a surprisingly robust strategy.
  • creatonez17 hours ago
    Is the CGI process opening up the SQLite database for every request...? That would have the most insane contention ever.
    • zbentley17 hours ago
      Would it? The file handle doesn’t contend for a lock IIRC; just writes.
      • creatonez17 hours ago
        I mean sure, you could still win if almost no requests are opening the database in write mode
        • zbentley16 hours ago
          Does it lock if the DB is opened in write mode, or only when a write query is issued?<p>If the latter, then it’ll only contend on simultaneous writes, which mutex anyway.
        • ihateolives8 hours ago
          I think you severely underestimate the speed of sqlite + nvme.
    • zelcon12 hours ago
      These things usually get 1 visitor per month and it’s Googlebot
      • sweetjuly12 hours ago
        fortunately AI (scrapers) have solved this problem so now you&#x27;ll have no end of traffic
  • mvk6662 hours ago
    reminds me of the deprecated C web framework <a href="https:&#x2F;&#x2F;github.com&#x2F;DanielWaterworth&#x2F;raphters" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;DanielWaterworth&#x2F;raphters</a>
  • fmo9122 hours ago
    It&#x27;s not very clear to me why the author has chosen C in the first place. I appreciate the effort of sharing the experience with us, anyway.
    • prophittcorey21 hours ago
      I didn&#x27;t want to state why C and not &quot;X&quot; because the comments would have devolved into an all out language war.
      • kanbankaren20 hours ago
        As someone who works on C compilers, I find the obession with C language insane.<p>For any greenfield project, pick up C++ in lieu of C if you want a C language.<p>There is no runtime penalty for using C++ if you stick to plain structs and don&#x27;t use virtual functions, but you get better static type safety, lvalue references, namespaces, etc. even if you don&#x27;t use the OO features.<p>Even for virtual functions, the overhead is minimal that it is just noise.<p>C compilers themselves are written in C++ for the last 15 years. Oh, the irony!
        • glouwbug18 hours ago
          Because in practice it’s really hard to not succumb to C++ feature creep. You start with good intentions and limit yourself to namespaces and structs, but then the “this will benefit from a vector, or this from a map” appears, then you realize you’d like a templated use case, and a single raw pointer or resource handle from a call to something like fopen() suddenly is not releasing its resource on a linked list pop and now you’re writing move semantics on top of copy semantics because a destructor declaration silently enforces copies on a std::move without move semantics. You reach for a unique pointer and, and all of a sudden, you have most of modern C++ without a single virtual call.<p>So people obsess over C because you’re hard limited by the upper feature bound. And that’s not so bad because C gets feature updates too - microscopic but effective feature updates; see C29 for the poor man’s RAII: defer
          • uecker9 hours ago
            Indeed, my experience is that just sticking to C leads to better software. I found it relieving and not limiting.
          • ricardobeat18 hours ago
            C3 lang gives you defer + a <i>lot</i> of significant ergonomic improvements right now: <a href="https:&#x2F;&#x2F;c3-lang.org" rel="nofollow">https:&#x2F;&#x2F;c3-lang.org</a>
            • rurban9 hours ago
              gcc also gives you defer nowadays, called cleanup
            • feelamee16 hours ago
              and what it does take away? most &quot;better C&quot; languages basically looks like C++ (except zig, maybe). Nobody write something real in them, so nobody knows about their pitfalls.
              • ricardobeat15 hours ago
                What do you mean by that?<p>n=1 but I&#x27;ve probably written (sic - a lot of AI) over a million lines of it this year. I like it precisely because it is <i>nothing</i> like C++, it&#x27;s really just a better C, and the compiler &#x2F; tooling is almost as good as Go.
            • bogdanoff_211 hours ago
              &gt; fn int foo(){<p>Eh? What&#x27;s the point of a `fn` keyword if I can&#x27;t `grep -r &quot;fn foo&quot;`?
            • glouwbug16 hours ago
              C3 is very good
        • prophittcorey20 hours ago
          I generally like &quot;C-style C++&quot;, but I find it difficult to draw the line between C and C++. It&#x27;s too easy to keep reaching into C++ for &quot;just one more thing.&quot;<p>That may be a me problem.
        • kevin_thibedeau19 hours ago
          T&gt; here is no runtime penalty for using C++<p>Large portions of the standard lib depend on heap allocations. C is a much safer target for environments with limited resources.
          • mpyne12 hours ago
            So use the C standard library instead of the C++ one. You still get RAII &#x2F; constructors&#x2F;destructors and runtime polymorphism, along with stronger compile-time type safety.<p>I frequently do that myself on simple C++ programs just for compile time reasons alone, where I&#x27;ll use stdio.h instead of std::iostream or std::format.
        • lelanthran10 hours ago
          &gt; For any greenfield project, pick up C++ in lieu of C if you want a C language.<p>Depends on the metric.<p>1. If the metric is &quot;How many features can I have&quot;, then, sure, C++ wins - it has everything.<p>2. If the metric is &quot;how few footguns are there&quot;, then C++ loses by a mile - there&#x27;s too many ways that the different features from #1 above can interact with each other to make it viable to keep track of all the footguns when writing code.<p>You may not value having fewer footguns and&#x2F;or lower cognitive burden, but many do.
        • zelcon11 hours ago
          For any greenfield project, pick up Rust instead of C++. Why? Ask any AI and it will pick Rust. Since AI is writing the code now and it likes Rust, because the pre-AI internet in its most trustworthy training dataset liked Rust. Therefore all code will eventually be Rust.
        • PaulDavisThe1st19 hours ago
          It&#x27;s what we did at amzn in 1994 ...
          • bigbuppo18 hours ago
            Wasn&#x27;t amazon running on tandem back then?
            • PaulDavisThe1st17 hours ago
              In 1994, amzn ran on a single solaris workstation. Same at the beginning of 1995. I can&#x27;t comment after that.
              • prmoustache3 hours ago
                caveat: Amazon was just a simple online bookstore at the time. There was little relation to what amazon is now (no AWS for example) except it was already selling and shipping stuff and keeping an inventory like any other online store.
        • ricardobeat18 hours ago
          There is a huge mental overhead penalty...
      • christoff1221 hours ago
        Fair enough. But I am also curious if you&#x27;d like to share your rationale.
    • prmoustache3 hours ago
      Probably because he knows it well and he rely on pledge and unveil capabilities of openbsd and it is well documented on how to use those in C.<p>You can do that in other languages but you need to use aditionnal dependencies (modules or bindings).
    • uecker21 hours ago
      Yesterday or so there was a post about using Zig. When I read it I thought that using C would work equally well.
      • christoff1221 hours ago
        Yeah, I thought it was interesting that both of these[0] were on the front page.<p>[0] - the other one: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=50051573">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=50051573</a>
    • Kevin_Flynn21 hours ago
      I can never figure out why everything isn&#x27;t in C. :|
      • ricardobeat18 hours ago
        Is it because you segfault before reaching the answer?
        • uecker9 hours ago
          From all the programs I use, the ones written in C are the most reliable (such as vim, bash, coreutils, terminals, X11¹, ... also larger software such as gimp, blender). Over decades I literally can&#x27;t experience a single crash!<p>¹ The exception is the Nouveau driver, but without it X was also perfectly stable for me.
        • 171862744016 hours ago
          A segfault IS the memory protection taking in effect.
        • Kevin_Flynn5 hours ago
          [dead]
    • layer818 hours ago
      The underlying libraries you use tend to be in C anyway, so it simplifies things to just use them with their native interface, and not having to add another language runtime and its idiosyncrasies.
    • EGreg22 hours ago
      I&#x27;m old enough to remember when the OKCupid guys wrote their own webserver in C++!<p>I took the concept of &quot;slots&quot; in requests, from it: <a href="https:&#x2F;&#x2F;github.com&#x2F;okws&#x2F;okws" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;okws&#x2F;okws</a>
  • macleginn19 hours ago
    &quot;A modern web application typically puts a web server like nginx in front and reverse-proxies to an application server written in another language like Ruby, Python, Go, or Rust. That always felt a bit strange to me: you essentially have two web servers, and one of them is also responsible for your business logic.&quot; -- Is the fundamental difference here that the business-logic binary is not always running but gets spun out with each request? This looks like a relatively minor thing, to be honest.
    • prophittcorey18 hours ago
      I meant to express the layers of abstraction feel strange to me in a typical setup.<p>A typical setup today looks like:<p>nginx -&gt; puma&#x2F;unicorn&#x2F;gunicorn&#x2F;etc -&gt; your code<p>With cgi that middle layer is gone. It&#x27;s just:<p>nginx -&gt; your code<p>The layer reduction is nice when it comes to things like debugging. You don&#x27;t have to guess if the middle server is removing a header, failing to forward a header, etc.<p>It&#x27;s obvious who does that with cgi.
      • zelcon12 hours ago
        Both nginx and Apache have modules that keep a Python&#x2F;PHP&#x2F;Perl interpreter loaded and invoke your entry point using FastCGI, completely leaving HTTP handling to the real web server. They went out of style for some reason, but there’s nothing stopping you from using them.
        • fodkodrasz8 hours ago
          Some reason: isolation and economies of scale. Apart from the obvious security aspects imagine the situation that you are serving multiple applications, developed by different teams, on different roadmaps... and you need to do a major version update of the runtime. This strong coupling of application lifecycles makes the overhead of isolation worth it.
      • macleginn16 hours ago
        Yes, this makes sense. Although you will probably have to implement at least some of the middle layer&#x27;s functionality, which means (at least for me) roughly the same level of debugging complexity when coming back to your own code later.
  • hollowonepl20 hours ago
    I was not thinking about vanilla C and CGI but I wrote my own modern web api server app in C++ (std+boost only) and I found it extremely pleasant experience. very reliable and little supply chain&#x2F;dependency hell problematic too.<p>It’s for intranet business app so although it’s not yet production ready yet, definitively winning against many other modern approaches in web development in my consideration, and quite refreshing POC project.
    • whizzter17 hours ago
      Yeah, shuddering at trying to manage memory vs static strings (with OOB risks) in plain C, modern C++ does give so much.<p>I&#x27;m actually also rewriting a header-only server (std c++ and sockets) I wrote a few years back to take advantage of C++26 reflections and similar to give it something similar in capability to AspNetCore+EFCore.
  • rurban9 hours ago
    Why Apache in front? I wrote my own single page C++ multi-threaded http server for our embedded needs, accepting only a single route. Nothing simplier than that. Now I also know if a client is connected or not, how many, and process the backend task accordingly. Like streaming from a camera or not.
  • KolmogorovComp7 hours ago
    Sadly it doesn’t look like the server is source-avalaible, so we could count the number of security issues included. There is a reason why C is not used for web servers today.
    • tzury7 hours ago
      Nginx is written in c.
      • KolmogorovComp6 hours ago
        Are you comparing their one-person project to nginx? Linux is written in C and out-of-bounds bugs are still found.
        • tzury4 hours ago
          I commented on the statement “There is a reason why C is not used for web servers today”.
  • codazoda21 hours ago
    It hasn&#x27;t been touched in a long time, maybe that&#x27;s because it&#x27;s &quot;complete&quot;, but here&#x27;s a quick CGI library:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;codazoda&#x2F;cgi-lib" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;codazoda&#x2F;cgi-lib</a>
  • jonenst6 hours ago
    Ok but what about basic features like metrics&#x2F;observability, logging&#x2F;alerting?<p>Maybe not all projects benefit from the full package but some things are now so commoditized that you should have them everywhere (and for heavier project add readiness&#x2F;liveness probes, configuration management, live documentation, connection pooling, background task scheduling, dev tools like profiling and tracing)
    • account423 hours ago
      The basic feature is serving a website. The things you mention are optional addons and almost always unneccessary for the primary purpose.
    • Udo5 hours ago
      I think the approach here is to code these basic features by hand. What&#x27;s preventing the author from building what they need on top of their basic stack?<p>Speaking as someone who hand-rolled their server stack as a C++ framework for years, there is nothing in there that can&#x27;t be done relatively easily. Some things certainly get easier even, the actual change in paradigm here is not that it&#x27;s a hand written web app server in C, it&#x27;s that it runs in its own server container which you have to manage. That&#x27;s the actual tradeoff. You can&#x27;t just deploy to Vercel.
  • reacharavindh9 hours ago
    Is BCHS still maintained?<p>The last update seems &gt; 5 years ago.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;kristapsdz&#x2F;bchs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kristapsdz&#x2F;bchs</a>
    • aragilar4 hours ago
      I&#x27;m not sure what you think specifically needs maintaining, it&#x27;s the same as LAMP, LEAN, JAM and the various stack acronyms? The BSD you choose is naturally maintained by the various BSD distros (though there&#x27;s an implicit assumption of OpenBSD as will become obvious), C is C (so defer to your C-complier), httpd comes from OpenBSD (<a href="https:&#x2F;&#x2F;man.openbsd.org&#x2F;httpd.8" rel="nofollow">https:&#x2F;&#x2F;man.openbsd.org&#x2F;httpd.8</a>), and SQLite is SQLite. You can naturally choose to add additional libraries (some are suggested on the site, I don&#x27;t know what their status is, but the article includes libcurl and libsodium, which are also well maintained), but as the example shows, you don&#x27;t need much to start with. A key thing that&#x27;s a bit hidden is the use of CGI and the various OpenBSD hardening tools (e.g. pledge, unveil), which make exploiting the C binary much harder than on other systems.
    • lioeters6 hours ago
      That&#x27;s a fresh C codebase if it&#x27;s only 5 years old.
  • lilbigdoot21 hours ago
    I&#x27;m still in the middle of reading but I wanted to comment first that I had a pleasantly surprising experience a few years ago with CGI. I hadn&#x27;t thought about CGI since I was a kid and I was tasked with adding a simple dynamic page to a server that had nothing running yet except apache. For whatever reason I though to try out CGI because of how simple the page was going to be, and yeah. Would recommend<p>I just got C FFI working in my LLVM based language last night so I&#x27;ll need to take a look at playing around with BCHS :)
    • so-cal-schemer15 hours ago
      All my BCHS are hustlers.<p>Give it a shot; I bet you&#x27;d like it a lot.
  • Aldipower8 hours ago
    &gt; CGI gives you a single web server that calls your business logic directly. It&#x27;s clear who does what.<p>One could simply put a Node.js server directly on the line. And then it is crystal clear who calls the business logic. I mean, there are reasons why we use Nginx in front of it. Distribution, filtering, rate limiting, etc..<p>BTW, the cgi-bin competitor back in the days was JavaScript too with the Netscape Communication&#x2F;Enterprise Server that supported server-side dynamic JavaScript in 1997! Funny enough. :-)
  • Surac20 hours ago
    i also do that way, but i also have written my own webserver so i have no cgi interface. it serves files and provides &quot;special&quot; sites for the application written in. I use html and css as a frontend. nealy no js code in the html. Things i hate: - applicatin status handling - mixing html, css, js and c in one file - having no web &quot;widgets&quot; - having to make them by myself
  • keyle15 hours ago
    And the cycle is born again. Seeing the cost of a rust conversion today, there is an argument...
  • chasil16 hours ago
    I have used ccgi.c when I needed access to system calls and PHP was too much of an attack surface.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;moths&#x2F;libccgi&#x2F;blob&#x2F;master&#x2F;ccgi.c" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;moths&#x2F;libccgi&#x2F;blob&#x2F;master&#x2F;ccgi.c</a>
  • rietta19 hours ago
    There is Boost in C++. It is very mature and honestly modern C++ has a lot of extremely powerful stdlib functionality and classes that will still be orders of magnitude more performant that the vast majority of the web app languages we use today. See <a href="https:&#x2F;&#x2F;www.boost.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.boost.org&#x2F;</a>
  • Scubabear6822 hours ago
    From the article, &quot;WRITING HTML AND CSS IN C ISN&#x27;T TOO BAD&quot;.<p>Um, any and all string handling in C is pretty miserable.
    • prophittcorey21 hours ago
      To be fair, the HTML and CSS in C wasn&#x27;t too bad.. the Youtube scraper was also written in C and that was a lot more painful :)
      • sam1r21 hours ago
        I can empathize entirely. After writing a scraper for html in C, outputting html in C is a piece of cake.
    • PhilipRoman21 hours ago
      Emitting strings is fine, it&#x27;s the parsing that sucks.
      • uecker9 hours ago
        Of course, you could spend half an hour to write a string abstraction first before writing the parser, and which case this is not a problem anymore.
    • Joker_vD21 hours ago
      If you do it with the string functions from the standard library then yes, it is.
      • prophittcorey21 hours ago
        The standard string functionality is painful. I wrote my own string view and string builder that work with fixed size strings. No memory allocations, etc.
    • feelamee16 hours ago
      tell me where working with strings is not miserable? Practically, modern languages with RAII make it easy at the cost of perfomance (doing a lot of allocations). So, if you doing lot of string handling, you still need to think how to do it in performant way. If doing it a bit - why care about miserable.
      • jiggawatts10 hours ago
        You can &quot;have your cake and eat it too&quot; in Rust, C#, and I suppose C++ if you&#x27;re a masochist.<p>These modern languages have both easy-to-use &quot;owning&quot; string types <i>and</i> a &quot;string slice&quot; type that can be passed around efficiently. Unlike C, in these languages a string and a slice are largely interchangeable, which makes them easier to use throughout not just your own codebase, but third-party libraries too.<p>For example, the Rust `httparse` crate `Request` type returns parsed fields as string slices, not strings, which means it doesn&#x27;t allocate anything on the heap: <a href="https:&#x2F;&#x2F;docs.rs&#x2F;httparse&#x2F;latest&#x2F;httparse&#x2F;struct.Request.html" rel="nofollow">https:&#x2F;&#x2F;docs.rs&#x2F;httparse&#x2F;latest&#x2F;httparse&#x2F;struct.Request.html</a>
  • modeless11 hours ago
    This could be a defensible choice, reasonable even, if you use Fil-C to guarantee memory safety. Otherwise, I would call it irresponsible.
  • Quitschquat21 hours ago
    I worked on a FORTRAN 77 CGI application in the early 00s. I think the host was Apache httpd, on some old HPUX version.
  • gitowiec8 hours ago
    It is so fresh look at the old! I learnt a lot reading this article. Thank you!
  • jan_m_savage10 hours ago
    impressive!<p>which also makes me wonder if it wouldn&#x27;t have been more programmer-friendlier had it been written in Perl?
  • dhuan_20 hours ago
    How about modern web apps in shell scripts only:<p><a href="https:&#x2F;&#x2F;dhuan.github.io&#x2F;mock&#x2F;latest&#x2F;examples.html" rel="nofollow">https:&#x2F;&#x2F;dhuan.github.io&#x2F;mock&#x2F;latest&#x2F;examples.html</a>
    • chihuahua17 hours ago
      Ideally, it should be a shell script for CMD.EXE, using the finest scripting language ever invented. The elegance of using FOR for such diverse tasks as enumerating files, file contents, string splitting, lists of numbers, and parsing the output of another command, is unmatched.
  • 6c696e757816 hours ago
    fcgi tends to be overlooked
  • zhangyimin11 hours ago
    I love this kind of simplicity. It&#x27;s unexpectedly satisfying.
  • emersonrsantos21 hours ago
    Does anyone know if Hacker News uses CGI as well? I know there&#x27;s some JavaScript and AJAX magic for the interactive elements on the frontend.
    • jaza6 hours ago
      AFAIK Hacker News was built (about 2 decades ago) by Paul Graham completely in Lisp (I assume with CGI) and AFAIK that&#x27;s still how it runs today.
  • throwaway203720 hours ago
    I am confused. Is this project open source? If yes, I could not find a link to the source code. Can someone help me?
  • bigbuppo13 hours ago
    Best I can do is use a framework built on top of a framework.
  • geoffbp20 hours ago
    I remember the days of wrangling cgi-bin on Linux hosts! Not a common paradigm these days..
  • devmor21 hours ago
    I still like writing web applications in PHP for many of the same reasons listed here - modern PHP anyways.<p>I shy away from frameworks unless I am building something that I expect a large team to work on, or I specifically need multiple complex features that don&#x27;t make sense to maintain.<p>I&#x27;ve written a few applications for my own personal use or targeted at friends&#x2F;family recently that have no third party dependencies other than Bootstrap, which I still like more than tailwind for anything that doesn&#x27;t need to look like a marketing page.
  • Alifatisk20 hours ago
    Reminds me of the Vibe.d web framework for D lang. Good memories.
  • dorongrinstein16 hours ago
    Many tools can achieve the same thing. I can write a note in pencil, pen, crayon etc. I will tell you a secret, but don&#x27;t tell anyone: you can write it in assembly also.
  • NetOpWibby7 hours ago
    &gt; It was refreshing to just write C. It isn&#x27;t pretty, but neither is Tailwind.<p>LMAO, I&#x27;m sold.
  • HackerThemAll6 hours ago
    I like everything about it EXCEPT the Apache HTTP Server (if I understood the article correctly). It should be discouraged nowadays. Its lack of progress, lack of features, poor performance and lack of security makes me never consider it again.<p>To give you more context. I recently closed a security gap in a customer&#x27;s web server that most likely resulted in a data leak. That web server stored (of course) database backups and other personal data. The directory listing was visible and accessible from the open internet, because - note that - the .htaccess file where the access was disabled had INVALID END OF LINE CHARACTERS according to Apache (and it wasn&#x27;t me who prepared it in the first place). Therefore - note - the server IGNORED that file and its default setting was OPEN ACCESS and enabled directory index. It&#x27;s wrong on so many fronts. The Apache&#x27;s philosophy is not &quot;I cannot parse the config file, therefore I disable access to the directory tree until administrator notices and fixes it&quot;. It was not logged in the server logs as &quot;invalid EOL detected&quot;. Apache after over 30 years of development cannot parse all 3 end of line sequences - the process which is TRIVIAL to the point of being ridiculous. Deciding not to include CRLF or bare CR is not about performance. It&#x27;s just the decision of its makers, there&#x27;s no justification these days. It violates &quot;be liberal in what you accept and conservative in what you send&quot;. In 2026, when the cybercriminals are everywhere, just waiting for the data, scraping it all over, the server&#x27;s default should be &quot;close everything until it&#x27;s explicitly open&quot; and &quot;if the config is broken, disable access and&#x2F;or fail&quot;.
    • 60317693 hours ago
      You can criticise Apache for many things but lack of features is surely not one of them. It comes with the kitchen sink and has plenty of add-ons for all those extra cases you might want.<p>I&#x27;d also take issue with the &quot;poor performance&quot; slur. It&#x27;s never going to beat out lighttpd for pure static speed but all the &quot;poor&quot; benchmarks I have see for it are entirely due to low quality (or no) configuration. Configure it properly and it flies.
    • theinfamousmobb5 hours ago
      &gt; I like everything about it EXCEPT the Apache HTTP Server (if I understood the article correctly).<p>You didn&#x27;t.
  • chmaynard20 hours ago
    Not open source, apparently. Am I missing something?
  • psychoslave7 hours ago
    Hmm, ok for minimalism, but C is not going to minimize the pain and risk of ugly standard library and manual memory management for something that is not relevant to optimize at this level.
  • orphereus18 hours ago
    Wow, you are a role model for me
  • kimi6 hours ago
    Web apps work on input text and generate text, and C is not the most text-friendly language there is. There is a reason why early CGI-BINs were usually written in Perl.<p>(I won&#x27;t even get started on the issues of creating new software in a language that is unsafe by design, and where any performance advantage will be dwarfed by the cost of forking. Whatever floats your boat, dude.)
  • ActorNightly20 hours ago
    <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26271117">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=26271117</a>
  • a3w18 hours ago
    why not dietlibc&#x2F;gatling&#x2F;append-only-DBs?
  • so-cal-schemer18 hours ago
    Who needs rust or javascript anymore when we can write all our code in C again and put an agentic zero-day hunter in the toolchain?<p>&quot;Make no mistakes.&quot;<p>Or a comfy scripting language with a great FFI as X intended.
  • TZubiri16 hours ago
    Fun fact, you don&#x27;t need busybox or an httpd, just open a socket on port 80. You can use openssl for port 443 or use stunnel
  • andrepd18 hours ago
    Instantly reminded me of this: source code of the first big Portuguese www portal and search engine: <a href="https:&#x2F;&#x2F;github.com&#x2F;celso&#x2F;sapo" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;celso&#x2F;sapo</a>
  • paularmstrong22 hours ago
    &gt; Everything about marketyour.games is modern<p>I can&#x27;t read any of the text on that page other than the headings. Is that what makes it modern? I assume the stack mentioned in the blog post is vibe-slop as well.
    • prophittcorey21 hours ago
      I wanted to try my hands at a monochromatic website and chose two shades that were far enough apart to pass a AAA contrast rating for accessibility. I&#x27;ll try to improve it soon.<p>It was 100% human slopped :)
      • mrweasel21 hours ago
        My eyes aren&#x27;t particularly bad, not at the point where I need glasses to read books, program or anything, but I&#x27;m at 160-170% zoom before it&#x27;s comfortable to read. HN is the same... so it might just be me.
      • amval5 hours ago
        This has to be the least readable website I&#x27;ve seen in a few years.
    • blodorn17 hours ago
      The BCHS stack is OpenBSD, C, OpenBSD&#x27;s httpd, and SQLite.<p>Is that the stack you are referring to, or something else?
  • UltraSane19 hours ago
    Connecting any C code to the internet is a terrible idea as we have learned over and over again.
    • assimpleaspossi19 hours ago
      Your server, operating system and database might all be written in C right now.
      • BirAdam19 hours ago
        It&#x27;s essentially a guarantee.<p>Linux is C.<p>Windows is C and C++.<p>macOS is C, ObjC, and C++.
        • kimi2 hours ago
          And nobody in their right mind sleeps soundly at night.
      • UltraSane18 hours ago
        And great effort had to be made to fix all the thousands of severe security bugs.
        • assimpleaspossi18 hours ago
          As if no large software system ever had such a problem and doesn&#x27;t still today.
          • UltraSane10 hours ago
            When windows was first widely connected to the Internet security was so terrible Microsoft actually had to pause all work on the next version of windows to fix the current version.
            • rramadass9 hours ago
              The main problem was not the language itself, but how the OS&#x2F;Software was initially written and how it evolved gradually with layers of cruft added to maintain backwards compatibility as they went through 16&#x2F;32&#x2F;64-bit architectures and different kernels (eg. NT vs. Win95).<p>It was the complexity and legacy baggage that was the crux of the problem.
    • hliyan12 hours ago
      Whatever it is that you&#x27;re writing this comment on, runs on something that is written in C. Whatever that is responding to your posted comment on the server side, runs on something that is written in C.
      • BobbyTables29 hours ago
        And whatever they happen to be, they’ve had multiple serious CVEs because they were written in C…
      • UltraSane8 hours ago
        And new stupid memory safety bugs are found in it constantly that are impossible in better languages.
  • t0020 hours ago
    &quot;Every request spawns a fresh process&quot; &lt;- this is when I stopped reading to save some time for the latest news in AI. Apologies for an abrupt interrupt.
  • sourcopolo13 hours ago
    &gt; One binary, a SQLite file, three dependencies and the entire thing fits in your head.<p>clearly AI slop
  • smstl4 hours ago
    Bro invented php
  • gfalcao18 hours ago
    Yes, but why? Why really? Are you Valgrinding the s*t out of the code? What about memory leaks? No template language? Did you use an A.I. Agent? I mean, the code is probably porn for GTK&#x2F;glib coders, unless it&#x27;s a horror movie instead. I&#x27;m really confused on the motivation there.
    • fg13717 hours ago
      &gt; CGI&#x27;s decline was justified in 2004 but doesn&#x27;t hold up in 2026.<p>I mean, the article should not be taken seriously on any technical level. It&#x27;s ok just for fun.
      • chihuahua17 hours ago
        I think the best parody is one that leaves the reader wondering if it was intended as parody, or if the author was serious.
  • EGreg22 hours ago
    <i>&quot;Every request spawns a fresh process. Deploying a new version is replacing one file. That means no server restart and no downtime. New requests simply pick up the new binary.&quot;</i><p>I think that&#x27;s why FastCGI exists. It is the equivalent of PHP&#x27;s &quot;Swoole&quot; or &quot;FrankenPHP&quot; or &quot;amphp&quot; or Laravel&#x27;s &quot;octane&quot;, etc. Each process is long-lived and tries to clean up its state as much as possible between requests. Forking a new process can take around 8ms (<a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19005586">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=19005586</a>)<p>When I was building <a href="https:&#x2F;&#x2F;github.com&#x2F;Qbix&#x2F;webserver" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Qbix&#x2F;webserver</a> in PHP, I was faced with forking a new process per request. I implemented fork-per-request at first, similar to PHP-FPM and then implemented the &quot;FastCGI&quot; approach of long-lived processes that clean up after each request. (Modern PHP has introspection so the engine can know what to clean up, before calling the php files to handle things.) However, some things are not really possible to completely reset in PHP, and you have to be careful with database connection pools, etc. Typically those are left open even by preforking processes like php-fpm.<p>Anyway, I ended up flipping it: use the &quot;FastCGI&quot; approach as a default, and if the original PHP code doesn&#x27;t work (rare), then for that app, you can choose the regular CGI approach of forking a process per request. That way you get maximum speed by default, and manually opt into safety (this is an exception to my usual priorities).<p>PHP is actually quite fast. But I was also interested in transpiling it to C. So I built the transpiler at: <a href="https:&#x2F;&#x2F;ulanguage.org&#x2F;playground" rel="nofollow">https:&#x2F;&#x2F;ulanguage.org&#x2F;playground</a> ... used Claude to transform about 1000 PHP functions to their native equivalents, but if you use any of the others, it would hook into the Zend runtime and link with it. (There are some nuances with zvals and objects, and resources in previous PHP versions, but I managed to overcome them.) By the way, it also works with Node and Python FFI the same way.<p>You can basically now take PHP, Python or Javascript&#x2F;Typescript code, and speed up the CPU-bound parts about 10-50x. A lot of that is because of string and JSON handling. Many web apps use strings and JSON a lot. So underneath, I had the compiler use &quot;ropes&quot; for the strings, and avoid concatenation. It also parallelizes the JSON encode and decode into code that can run on multiple cores at once, i.e. large JSON payloads are encoded and decoded in parallel. Those are just huge speedups.<p>Anyway... all of this is mostly focused on speed optimization, so you can solve the literally C100K problem (forget C10K) today, on a regular box. If you don&#x27;t need speed or FastCGI, your approach is fast enough for the vast majority of applications.<p><i>PS: By the way, if you fork after your program already loaded the framework and initialized the configuration, then you can run a lot more workers, literally 10x-100x more of them, because Linux and Mac will share all the loaded memory between processes, and do Copy-On-Write only on dirty pages. And when your request is done, and the process exits, that custom memory is efficiently cleaned up by the OS. It is this feature that allowed me to finally get the best of both worlds... run all existing PHP code, that makes blocking I&#x2F;O requests all over the place to the database, filesystem, network etc. while at the same time being able to handle 100,000 requests in flight at the same time! Swoole and FrankenPHP can&#x27;t do that.</i>
    • tancop20 hours ago
      FastCGI sounds like a perfect fit for Tiger Style and Zig. You can avoid allocations completely if you set up a fixed size arena and reset it after each request.
    • iririririr21 hours ago
      what are the code paths in php you&#x27;re dropping for the actual speed improvement? just the parsing?<p>if not, you could have sent patches and have the best of both worlds
      • EGreg20 hours ago
        Patches? Explain<p>My goal for speed was to run all existing unmodified PHP code out there, but handle 10x as many requests and throughput<p>Well, and also a ton of other features too
  • rfgplk20 hours ago
    Decent, but a half measure. Meaning you still depend on a separate web server (httpd in this case) to actually push your sites over the wire. This limits you in terms of how expressive your web application can be (ie you cannot arbitrarily write HTTP headers or choose how to serve your clients), and in terms of performance.<p>A far better (and harder approach) is to actually write the whole stack yourself. Meaning the actual web application and web server are packaged from a single binary. You of course have a myriad options in how to actually implement this (the server loop can run as a separate coroutine&#x2F;thread&#x2F;process&#x2F;etc), but overall the performance and expressiveness flexibility is limitless. On top of that you can actually get blazing fast performance compared to classical approaches.<p>I&#x27;d also advise everyone to avoid CGI at all costs. It&#x27;s overhead is massive (new process every time, more or less) and _itself_ is a half measure since implementing a proper code hot loading&#x2F;module system for servers is too much of a hassle (and standardizing it is hard). Nowadays you want to inline your server and then handle HTTP generation separately (however you&#x27;d like).
    • zelcon12 hours ago
      There is a third option, which doesn’t involve making your small application responsible for reinventing the wheel.<p>Take whatever is pushing the site over the wire (nginx, Apache, lighthttpd) and use its public APIs to implement your web application.<p>You can make your nginx.conf list the routes along with the C functions for each route, which nginx looks up in your shared library.<p>You can host numerous web apps just by updating adding an .so and updating the nginx conf.<p>This is also structurally more efficient your hand rolled web server which in all likelihood has to reverse proxy via nginx anyway.
    • sophacles19 hours ago
      CGI does allow arbitrary HTTP headers.
  • marcelox8622 hours ago
    Another interesting looking blog post that I can&#x27;t bear to read without my eyes bleeding :(
    • nocman21 hours ago
      Interesting. It looks fine to me. What&#x27;s the part that bothers your eyes? (genuinely curious).
    • smhenderson21 hours ago
      It supports reader view just fine...
      • marcelox8620 hours ago
        I&#x27;m talking about all the claude-isms in the writing. i&#x27;ve seen a couple posts on linkedin that read just like this page
  • LoganDark18 hours ago
    &gt; marketyour.games<p>Visited this website out of curiosity, and... Please do not use Courier New as a monospace font, not even as part of a fallback. Its stem width for body text is often less than a pixel, which looks awful.
    • frou_dh17 hours ago
      Just the other day I thought it looked like the friggin official Python homepage is using Courier for the code example
      • LoganDark15 hours ago
        Looks that way to me too, but I wouldn&#x27;t look to Python for best practice.
  • caniload12 hours ago
    [flagged]
  • DobarDabar6 hours ago
    [dead]
  • afavour22 hours ago
    A shame to hand code a project in C and then use AI to write a blog post.<p>It’s a cool project to test yourself but most of the benefits outlined would also apply to Go, Rust, etc, and then you also get memory safety thrown into the mix as well.
    • skrrtww22 hours ago
      I don&#x27;t think the post was written by AI.<p>It has headers like AI blogposts, and features a lot of parallel structure like AI blogposts (&quot;there&#x27;s no &lt;blank&gt;. you &lt;blank&gt;&quot;), but if you actually read it none of it reads like slop. To me anyway.
      • jjackyzheng21 minutes ago
        This structurally seems like AI writing to me..<p>You can write a modern web application in C. I shipped one. One binary, a SQLite file, three dependencies and the entire thing fits in your head.
      • xd193621 hours ago
        Interestingly, Pangram says that exactly the first 50% is AI and the second half is not. ¯\_(ツ)_&#x2F;¯
        • Muhammad52321 hours ago
          Not that those tools are that accurate
        • CharlesW21 hours ago
          <a href="https:&#x2F;&#x2F;mitsloanedtech.mit.edu&#x2F;ai&#x2F;teach&#x2F;ai-detectors-dont-work&#x2F;" rel="nofollow">https:&#x2F;&#x2F;mitsloanedtech.mit.edu&#x2F;ai&#x2F;teach&#x2F;ai-detectors-dont-wo...</a>
        • exe3420 hours ago
          You could have saved milliseconds and used a pseudo random number generator.
      • exe3421 hours ago
        It reads like autism to me. The theme confirms that.
        • bowsamic8 hours ago
          That was my conclusion too
      • cnqso21 hours ago
        [flagged]
  • claiir14 hours ago
    Neat, though:<p>&gt; I&#x27;m a minimalist at heart. I use classic Vim with zero plugins. That means no LSP, no autocomplete, no code formatters, and no AI.<p>yet the author gives us an AI-written blog post :p