This post originated from an RSS feed registered with Ruby Buzz
by Steven Baker.
Original Post: Making C Suck Less: One #define at a Time
Feed Title: conaltradh
Feed URL: http://blog.lavalamp.ca/xml/rss20/feed.xml
Feed Description: Musings of Steven R. Baker, Ruby geek, and general nut.
I used to write a lot of C. My variable names were rarely more than 3 characters in length. My functions were long and contained wild switch statements; I always made sure to free() what I malloc()ed; I tuned my code so that not only was it an unreadable mess, it was a fast unreadable mess.
I’m better now.
I’m writing a Ruby extension, Net::GeoIP, for work (they let me MIT it, so go nuts). Because I keep flipping back between Ruby and C during the development of this extension1 (obviously) I have a constant reminder of the hoops I have to jump through in languages that aren’t as expressive as Ruby.
I’ve decided to just add some of these features myself, by abusing the pre-processor. Here’s a bit I thought I’d share: