The Artima Developer Community
Sponsored Link

Java 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
Chetan Sarva

Posts: 11
Nickname: csarva
Registered: Jun, 2003

Chetan Sarva is a developer for 2Deck Technologies
Making C Suck Less: One #define at a Time Posted: Jun 11, 2006 1:59 AM
Reply to this message Reply

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
Latest Java Buzz Posts
Latest Java Buzz Posts by Chetan Sarva
Latest Posts From dot plan

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: [Jun 1, 2006 18:55 PDT] 13 Links Previous Topic   Next Topic Topic: PeopleOverProcess.com: A Crack at Describing Successful, Distributed Agile Teams

Sponsored Links



Google
  Web Artima.com   

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