Moving up and down the technology stack

Programming is a crazy field. One day you fire up a Python interpreter, connect to some PostgreSQL database, retrieve a few records, and print out a Gnuplot script so you can include a nice plot in your LaTeX document. The next day, you connect a scope to that damn 515C controller to find out why the CAN interface timing is botched. Throw in a few Excel macros, a Node.js based web service and some work on the Scheme interpreter written in C#, and you have a typical week at my employer’s.

And that’s exactly how I like it.

Doing the same stuff every day gets boring pretty quickly. Working on something else every other day keeps things interesting. There is so much stuff out there to learn! Lots of high level libraries and tools that let you create fully automated reports typeset in the highest quality, juggle with enormous amounts of data with a near-English “natural” language or detect diodes soldered onto a board with the wrong polarity in an image. It’s incredible how much work has been done for us already. Some days, programming feels like sticking together some Lego pieces.

Then again, sometimes you have to get down to the dirty little details. Be it to find out how stuff works at a lower level, or to make sure things run as fast as possible on tiny systems with an amount of memory that was considered to small to be documented as a “free” range on the Commodore 64.

And then there is learning and teaching. When I walked “my” student employee through writing his first ring buffer in pure C, providing him with a small test suite and Git along the way, there it was again — that sweet, sweet nostalgia. Code::Blocks is a pretty decent IDE, and within half a day the code was “done”. Only it wasn’t, because I’m a bastard and gave him a crippled test suite that omitted a few corner cases, so he could learn to watch out for incomplete or faulty test suites along the way. So far he’s learnt how to use source control, C and C# command line compilers, several IDEs, played with Android programming in Java and C#, and debugged a serial comm line with a digital scope. And I’ve learnt a lot in the process, too: Teaching changes your view about pretty much any technology you touch, making you remember those days when you learnt something yourself, what pitfalls there were, how to get around them — and suddenly you notice corner cases you always just shoved aside, never really thought about, and bingo, another interesting thought to follow.

It’s been a fun week.

Want to go on a nostalgia trip yourself? Implement this:
/** @brief Initializes a ring buffer. 
  * @param buffer The byte array to use for the ring buffer.
  * @param size The size of the array in bytes.
  * @return The number of bytes that can be stored in the buffer, or -1 if
  *         the array is too small to make a ring buffer.
  */
int16_t ring_init(uint8_t *buffer, uint16_t size);
 
/** @brief Gets the next byte from a ring buffer.
  * @param buffer The byte array used for the ring buffer.
  * @return The value read, or -1 on buffer underrun.
  */
int16_t ring_get(uint8_t *buffer);
 
/** @brief Stores a byte in a ring buffer.
  * @param buffer The byte array used for the ring buffer.
  * @param value The value to store.
  * @return 1 if successful, or -1 on buffer overflow.
  */
int16_t ring_put(uint8_t *buffer, uint8_t value);

Set up a git repo, your favorite IDE, a fresh C project, maybe go crazy and set up a Trac instance, and write a few test cases. Implement and test. Then think really hard: Did you handle this “project” with the same care you always use at work? What would you do differently on a “real” project? Why? What could be done better? Could you change something to your usual approach to become better? Interesting thoughts ahead.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s