• openasocket 2 hours ago

    Cool! Looks like is used dynamic loading. Which is certainly workable. One downside is that while dynamic loading is well-supported, dynamic unloading is generally not. Meaning if you are using dynamic loading and re-loading for hot updates the server process will start to accumulate memory. Not a huge issue of the server process is periodically restarted, but can potentially cause weird bugs.

    You might be able to make something more robust by forking and loading the modules in a separate process. Then do something fancy with shared memory between the main process and the module processes. But I haven’t looked into this much

    • warothia an hour ago

      Oh really interesting, will look into it! Was afraid it would leak memory.

    • warothia 4 hours ago

      This hobby project is inspired by kernel modules and AWS Lambda. It lets you write raw C modules, upload them, and have the server compile and run only the module itself at runtime—no need to recompile the entire application or restart the server.

      You can update routes and modules dynamically. Even WebSocket handlers can be updated without dropping existing connections.

      • revskill 2 hours ago

        How ti integrate with extermal library ?

        • warothia an hour ago

          If you would want to link with external libraries, you would need to modify to server and make sure it has access to them when compiling the modules.

        • gwbas1c 3 hours ago

          Important question: Why would anyone develop a web application in C? Typically web applications lean heavily on garbage collection and memory safety, because their bottlenecks are very rarely CPU/memory issues. The ROI on manually managing memory just isn't there for a typical web application.

          • _gabe_ 14 minutes ago

            I’m all for using C for native development (and because I find it fun to work in occasionally), but I agree with your sentiment here. Not only do you have to manage memory manually, but you also have to do a lot more work for basic string manipulation which is the vast majority of web work. I would much rather work with a language with built in support for string manipulation and well known 3rd party libraries with good ergonomics for working with JSON, which a lot of your APIs will most likely be using.

            • williamcotton 44 minutes ago

              > The ROI on manually managing memory just isn't there for a typical web application.

              You can use a per-request memory arena built with a simple bump allocator and then free the entire block when the request has been handled.

              • SvenL 2 hours ago

                On the other hand memory management in web applications is quite easy. Most of the stuff is only required for the lifetime of a request. Some stuff needs to be available the whole application life time.

                • warothia 2 hours ago

                  I could say speed, but the main reason for me is because it is fun. And I like to see what I can make C do. :D

                  • koito17 an hour ago

                    Back then, C was one of a few viable choices. The original implementation of the 2ch BBS was written in C.[0] Later revisions used Perl. Between 1998 and 2001, the site was a widely-used BBS and written in C.

                    [0] https://github.com/nekoruri/readcgi

                    • Aurornis 2 hours ago

                      Lightweight web frameworks are great for embedded applications.