Balde: a microframework to develop web applications in C
balde.rgm.io
balde.rgm.io
This is why most of the documentation is marked as TODO, but the API docs are reasonably up-to-date.
If someone has interest on it or is willing to help, please let me know :)
EDIT:
simple url shortener example, using redis: https://gist.github.com/rafaelmartins/9f8392a8909e62820ae0
"complete" app, with templates and stuff: https://github.com/rafaelmartins/bluster
You might find this set of benchmarks inspirational [https://github.com/nanoant/WebFrameworkBenchmark]. The Java web server seam faster because it returns less data. kore is faster in fact.
Note: vibe.d has improved its performance with more recent versions. The author of the benchmarks ignore requests to update the benchmarks.
Excellent name, especially if one or more of the above questions are true!
If I imagine myself using your framework, well, I would be very angry at you if I had to stop writing code, leave my editor and go read your shilly-shally.
I would focus on:
1) Topics like "Application structure", "Application Deployment", "Application command-line interface" (which at the moment of writing are all just a "TODO").
2) Sample code. A 30 lines example is worth a thousand word blog post
3) More sample code. Ideally, one for every crucial part (cookies? session? middlewares?)
By the way: I see there are some examples, great! But add some more comments to your examples.
4) Blog post on internals.
I'd delay the blog post upon internals because I guess that since you'll be receiving a lot of feedback you might want to change things in the internals thus "invalidating" your blog posts.
P.s: congratulations on using doxygen so well! I wish more project had such a well done documentation!
p.p.s: I hope you won't find my comment rude or anything, I actually like this project.
blog posts were never the focus, they are mostly for myself, to remember how things work, as I don't work on the framework for some time, and need to have it fresh in mind to write proper docs. it may also help other people willing to help writing docs. also, whoever published balde website here in HN found it due to these blog posts, then they were worth already. :) and to be honest, I'd not publish the framework here in hacker news right now, I'd wait for documentation to be ready, but someone else couldn't wait, so...
but you're right. the focus now is writing documentation.
thanks
Basically, if you like the framework and there is no doc, Make a pain to yourself and contribute.
p.p.s: I hope you won't find my comment rude or anything
My go to solution for this is libwebsockets. Balde seems to have some nice features, but SCGI + external webserver requirement makes it difficult to embed. I'd also question whether GLib is a reasonable dependency for HTTP microframework.
The canonical genome browser is written in C: http://genome.ucsc.edu/cgi-bin/hgTracks?db=hg19 ... for pure speed.
Other than that I guess it's useful if you want to display data from a C / C++ program without going through any bindings. When it comes to that, maybe it would be great to get some automatic HTML display helpers for data structures common in C, like Arrays of numerical values or pointers to sequences of structs. For example in Python it's really fun to just use something like [1] together with Flask and get interfaces to your data without doing any template programming.
For comparison, ribs2 ( https://github.com/Adaptv/ribs2 ) is a framework in C that handles garbage collection for you. But it's not really a comparison because Balde doesn't have the documentation, unfortunately.
if you have some specific question, feel free to ask
Internally used memory should be free'd manually with the balde_app_free function. it encapsulates most of it for you.
However, C is one of those "double-edged sword" kinds of languages. What kind of trade offs between performance and "safety" would one be making here? Are they worth it?
FWIW, everyone I know who moved web-serving things to C did so primarily because of latency, and then secondarily to avoid GC time delays. Higher transactions per server was a bonus, but no one did it for that.
Also, if you have to hit a database, then any efficiency you get from switching to C will probably be swallowed up by that.
I can only think of one case where that is pretty much always true - CRUD with a network connected db backend, several cases where it is debatable, and a bunch of cases where that is wrong. See sqlite3, situations where you can use unix sockets, dynamically loaded modules, etc.
I'm finishing up a project that basically builds state models from log events, automatically, and robustly enough that hopefully the end users wouldn't notice if I were run down by a bus. With the massive amount of data and high dimensionality of the problem, I have a hard time seeing how to pull it off but with C and statically compiled sqlite... or a big bag of money to throw at IBM.
That sounds really cool, but I'm not quite sure what it means.
[0] https://en.wikipedia.org/wiki/Business_process_modeling [1] https://en.wikipedia.org/wiki/Directed_acyclic_graph
The choice of programming language affects performance much less than the quality of the architecture, algorithms, data structures and just plain coding skills.
> "With balde you can serve hundreds of requests per second"
A simple Netty-based Java web server can do tens of thousand requests per second easily on a laptop (I'm taking these numbers from our current project, and we didn't spend any time on any real optimizations for speed yet).
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).
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).
Do you have a favorite platform independent C project that handles iOS deployment well that you can direct me to?
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. !
What fears? Care to elaborate? I'd love to hear!
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).
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!
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 know, shock and horror, wailing, gnashing of teeth. /s
Is it just me, or has HN gotten really bitchy towards people's projects lately (and by "lately", I mean "the last year")? There are real people behind these projects. They did a thing and it might not be your cup of tea or anything in your experience bubble, but that doesn't make it stupid or misguided.
:)
You just need to be fully compatible with one kind of Unicode (UTF-8) and use it consistently. And null-terminated UTF-8 is no more or less safe than null-terminated ASCII, because the only UTF-8 codepoint that uses 0x00 is the same one as in ASCII.
You don't need to go down different paths of how you read those bytes based on the codepoint lengths until you're actually doing something with codepoints.