Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I use C every day, and I wrote a whole framework for writing websites in C (no longer maintained because I'm no longer that interested in writing websites):

http://web.archive.org/web/*/http://www.annexia.org/freeware...

What was amazing was that you could write pretty complex dynamic websites that fit into a few K of RAM and could trivially handle huge load.

I originally wrote that framework for a chat service. It ran for years on a single 32-bit CPU box with 128 MB of RAM, handling the chat requirements of dozens of English schools.



Unexpectedly popular comment :-) A bit more background:

- It used a scheme for cooperative threading that is similar to coroutines. This meant you could write straightforward code and all the event driven stuff was done automatically behind the scenes.

- Parallelism wasn't so important back in 2001 but you could also do that by forking N reactors (one for each core).

- There was a C string library modelled on Perl. It had lots of string management, vectors and hashes. Buffer overflows were effectively made impossible by the string handling library.

- UTF-8 was used throughout and it was fully i18n-able (using getttext).

- Template library.

- There was a pool-based memory allocator library (similar to Apache's APR / Samba's talloc). Effectively you didn't have to worry about memory allocation at all except in some rare corner cases, mainly when you wanted to store something in a global cache.

- All persistence done through PostgreSQL using a Perl DBI-like library. SQL injection was impossible because it used prepared statements.

- There was a rather experimental system built on top of this that allowed you to embed widgets in webpages so you could write very interactive stuff without using Javascript (something of a concern back in 2001, not so much now). It maintained the widget state transparently across page reloads. AFAIK no one has every done anything like this before or since.

It was, to some extent, a bit crazy that I wrote all of the above in about 6 months, but I was being paid a lot of money, working at a very disfunctional company that was on the verge of going out of business, and didn't have much else to do.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: