This post originated from an RSS feed registered with Java Buzz
by Chetan Sarva.
Original Post: Making C Suck Less: One #define at a Time
Feed Title: dot plan
Feed URL: http://www.fw2.net/blojsom/blog/java/?flavor=rss2
Feed Description: there be dragons here
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: