Rediscovering the delights of C

The last few months have been an interesting journey for me. Not only have I been having loads of fun (and quite a few late nights) with my Raspberry Pi experimentations, but I have also been spending my working days programming in C. It came as a bit of a surprise when I was first approached to do this work, as I my career had taken me out of C into C++ for several years, Java for over a decade, then a bit of Ruby for a while.

I must say, though, that I have been really enjoying working with C. It's a much simpler language, and does require some extra effort for things which might be relatively simple in a more modern language, but this simplicity has a lot of benefits. Once you get your head round the essential concepts and the small number of "gotchas", nothing is much more complex than any other. I have been working on a system which could be considered as half way between an embedded system and an enterprise component. The embedded nature of the project means that "build it yourself" is an acceptable (and often very wise) choice when compared with using a complex, general purpose, and potentially flaky, third part component. The enterprise nature creeps in with the use of networks and standard protocols to communicate with the many other parts of the overall system.

As a classic example of this, today I spent my time exploring the feasibility of adding a web server into the mix, but rather than treat it as a complex problem and reach for some existing software, I started from an empty C source file and built a basic web server from scratch. After a few hours I was happily talking to the fresh server using firefox and a simple client I had built, and progressing to add dynamic attachment of code to URL paths. All using only low-level system calls to configure, read, and write network sockets, no third-party components at all.

In practice this is just a proof of concept, and may never be incorporated into the system, but I think it goes a long way to show how C doesn't have to be the scary, complex, and dangerous low-level language it is sometimes painted as.

I see a strong analogy with the Raspberry Pi here. There have been small, relatively low cost development boards on the market for years, but none have caught the public imagination quite like the Raspberry Pi. It's a fascinating situation, and I have a feeling that it is something to do with the way that, although relatively simple, the raspberry Pi somehow does not seem scary, complex, or fragile. Just fun.

No related content found.

Leave a Reply

Your email address will not be published. Required fields are marked *