The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Making C Suck Less: One #define at a Time

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Steven Baker

Posts: 34
Nickname: srbaker
Registered: Jan, 2006

Steven Baker is a Ruby geek currently living in Parksville, British Columbia, Canada.
Making C Suck Less: One #define at a Time Posted: Jan 27, 2006 1:26 PM
Reply to this message Reply

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.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Steven Baker
Latest Posts From conaltradh

Advertisement

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:

#define unless(x) if (!(x))

unless(container == NULL) { GeoIP_delete(container->geoip); }

1 Indeed, my tests are written in Ruby. I make them pass with C code. And I have a big wad of Rake love gluing it all together.

Read: Making C Suck Less: One #define at a Time

Topic: Better code coverage for Ruby: rcov 0.1.0 prerelease Previous Topic   Next Topic Topic: Rough RESTing on Rails

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use