Friday, April 14, 2017

Hack C

Work has been busy and eating up most of my "Copious Free Time", so most of my projects have been placed on hold.

However, one thing I am getting from the past 6 months "deep dive" back into C programming (I've been programming C on and off since 1985 -- yes over 30 years *gasp*), is that a lot of my code in LuaJIT, Perl, C++11, Clojure and Haskell (and others) could be rewritten pretty concisely in C (C99 or C11 in particular).

Now, hold on, you say -- that is crazy talk.

A lot of the types of applications/tools I write are "system level".  When not coding Cortex M4 ARMs (my day job) I do a fair bit of networking (ethernet/IP packet level) hacking.  Or, I use libraries such as OpenCV to do simple vision stuff. So, I am not really using the advantages of higher level programming languages.

What I am really benefiting from is those language's  REPL -- the interactivity.  

I recently rewrote an OpenCV based image detection application, I originally explored and coded in LuaJIT, in C99. It was almost a line by line translation (I even found a couple of bugs!).

Okay, so honestly, I wonder if I had some sort of C REPL (gdb on steroids?), all I am missing is a nice convenient hash table (i.e. associative array, dictionary, etc).  I don't like the baggage of bringing in whole toolkits/frameworks for that (I like to keep my C lightweight and avoid things like pseudo-OO), so I just need a nice fast, generic hashtable implementation.

I need to get back into hacking C (for a while at least) and avoid the drama associated with picking a programming language "tribe".