back

by eatonphil·10y ago·view on hn ↗
I've been looking into web frameworks in C recently. The offerings aren't awesome. It's hard to find a good BSD-like-licensed library.

Frontrunners included Kore and Crow (another microframework). I went with Kore for a while but it has a pretty terrible API for actually writing web applications. I couldn't take Crow seriously. I ended up going with fastcgi because it was the simplest to wrap using the Scheme FFI.

Others included Lwan (gpl) and Mongoose (gpl).

3 comments
https://libwebsockets.org - LGPL though. There would be a bunch of dead code if you had no intention of using WS, but the commitment to being valgrind-clean is pretty nice, multiple event library options, multiple ssl backend options... lots of flexibility with what I find to be a sane api. Oh and this might matter to some more than others, but the developer is very active - I've had pull requests accepted within minutes for the obviously correct patches.
building libwebsockets on iOS can be quite a chore for many, however, and the authors of the library are not shy to express their distaste for Apple products, which I find inappropriate.
I can't speak to the appropriateness of publicly expressing distaste, but I'd expect building any nontrivial C library for iOS to be a chore - because Objective-C isn't C.
Objective-C has nothing to do with it, actually (despite that Objective-C technically is C with a superset of features -- all C is compatible Objective-C).

The issue is the build/compilation process for the different platform architecture via cross-compilation. Tends to be rather tricky, regardless of the actual language you choose to write your app with (this build process is entirely separate from any code you write yourself in any supported iOS language).

I'll have to defer to your expertise in Objective-C and iOS, because it was my understanding that C was not a first class citizen in the iOS world. Like with Windows, Microsoft has treated C like a redheaded stepchild. Yes C++ is a superset of C, but it is still a huge pain to get working in Windows.

Do you have a favorite platform independent C project that handles iOS deployment well that you can direct me to?

I hope you didn't put much effort into tracking that down for me, because that isn't what I would call a "favorite platform independent C project". I guess it could be someone's favorite something, but I think it would make most programmers sad. Thanks for trying though.
Hey, I'm on a phone without my last pass. I've spent a fair amount of time trying to find a happy web c++ framework.

Implementing fastcgi seemed too daunting to me... hello world was crushingly painful to set up (using Apache)

lwan and mongoose are GPL.I

I feared kores API as well, but I never got around to actually using it, so I'll just use your Menton of it as confirmation of my fears .

I'd looked at crow, and it didn't look so bad, but now I'm not so sure. What did you like about it? What didn't you like about it? What made fcgi less painful / more fun?

Basically, I'd love any notes on your attempt / experiences / etc. !

Fastcgi was incredibly simple to get hello world running - both in C and through the Chicken Scheme FFI. However, "all" it provides is the backend for a web server so you'd still need to handle things like routes and templates and responses yourself. Still, I don't find those to be the challenging part.

The issue that I'm having with fastcgi is the random scarcity of API documentation. I can't believe it's so hard to find - googling for "fcgx accept_r api documentation" just yields nothing.

Anyway, it was very cool to get it running in Scheme so I'll definitely write a post on that soon. I'll post it on this thread when I do.

I'd read a (hopefully scheme agnostic, or at least, scheme-decoupled) tutorial on how you got fastcgi up and running painlessly. I really struggled with the lack of documentation as well.
Author of Kore here.

What fears? Care to elaborate? I'd love to hear!

For me, too much was tied into using the Kore CLI to build and manage the actually application. Plus configs for routing is the only (apparent) option.

I think Kore would be an awesome framework if it weren't built with the assumption that you want to use its configs and its CLI. And although these could be useful too, I don't think it's too much to ask that the actual functionality there be exposed nicely and well-documented.

In particular, I'd just like to be able to wrote my own main and start Kore from there with high-level calls (including building routes).

I understand.

You're not forced to use the CLI create/build/run commands for anything. They just make it easier, but you are in no way tied to this.

Building the module itself can be done on your own for example, as it is just a normal dynamic library you can use whatever build system you want.

I've considered time and time again to turn kore into a "library" that you can link against and include into your own applications but every time I decided against it as it didn't give me any real benefits. It would make certain things considerable harder, who takes care of the worker processes? Who takes care of the logging and the internal message relaying? Having this abstracted away in a library is probably possible but adds tons of expectations on your own application.

Having Kore as the platform your code runs under makes this easier.

Thanks for explaining however, very insightful!

Well there is civetweb (BSD) which was forked from an earlier BSD release of mongoose but has now diverged a little on its own.
I'd love to make balde BSD-licensed ( see https://github.com/balde/balde/wiki/Converting-from-LGPL-to-... ) but unfortunately I have to deal with GLib for now... :/