Why I've grown to loathe C

Ever since I stopped using C as my primary / go-to language (currently erlang and perl, but including pascal, smalltalk, java, lisp, and eiffel at times) I've always had this vague hatred of it, but its always been hard to quantify, with any attempts to discuss this usually being met by responses that were inevitably fanyboish, both pro, and against.

Witness Damien Katz's recent - and unintentionally hilarious - Unreasonable Effectiveness of C, and its followup (no, I'm not going to fisk them - read them, preferably not while drinking anything to avoid spit-takes).  It pretty much sums up the fanboy position for any language, best summarized as
  1. Take everything that matters to the project you are currently working on
  2. Explain why your preferred language is the single best language to implement whatever it is
  3. Hint that pretty much everything else doesn't even come close
  4. Throw in a grab-bag of other random features that - of course - your language does best
  5. And for bonus points, pull a Karl Rove and claim that a few well known weak points are actually strengths (buffer overflows are useful! They help identify security threats! Also puppies! And kittens!)
Debating inane points being somewhat anathema to my existence, I've pretty much stayed far away from these discussions, and my C-uneasiness has stayed exactly that, a vague feeling of uneasiness apparently destined to remain unfulfilled.
All this, until Dr. Rustom Mody came to the rescue - his brilliant C in Education and Software Engineering is the definitive answer to the canker-sore that is C (to me at least...)
Just go read it - it sez everything that I want to say (but just a lot, lot better).
An excerpt from Section 5 - Consequences of C as a mother-tongue
The harm done by an overly early introduction to C is large although invisible. C-mother-tongue programmers are life long bound to find simple, elegant yet wonderfully rich ideas like Object Oriented Programming, functional programming, modularity, CSP etc. as difficult, unnatural and ‘advanced’. If these claims seem like exaggerations, it is only because of human beings’ ability to unlearn. The amount of stuff which a C programmer knows, but subsequently must be discarded as being operational, machines-pecific, implementation-specific, sequential-paradigm specific, contrary to robust software engineering etc., is incalculably large.

Just as a C programmer finds it difficult to grow upwards towards more high level languages, he finds it difficult to grow downwards as well. Experience with engineers (B.Techs) who are first trained on hardware, suggests that an assembly language programmer can learn C much faster than conversely. Surprisingly, an assembly language programmer can also learn higher level languages (eg. functional and object oriented) more easily than expert C programmers. The reasons seem to be that
  1. Assembly language programmers are acutely conscious about the drudgery that low level programming entails. C programmers however have a persistent illusion of working in a higher level language.
  2. The assembly language programmer has a firm foothold on computational processes even if his/her understanding is entirely operational.
 There is more, much more. Go read the whole paper - its worth your time...


Popular posts from this blog

Cannonball Tree!