Chad Clark's Open Journal : 2007-10-15

Historical Entries   Recent Entries   About The Author   RSS  

October 15, 2007 :
1) The language C.

I have said I love C.  It is a wonderful machine control language.  
I have also said it is a not a wonderful problem solving language.
Read the last sentence again if you missed the "not".

In 2005 I wrote a network server program in Perl and in C.  My comments
from the top of the perl script are:

  # This file is here because I was practicing some C programming and I
  # wanted to compare my development time and lines-of-code to what I
  # can do in Perl.  The result is this file took a few minutes (under 10) 
  # to copy a previous program I had written (the random quote daemon)
  # and modify it.  The C program took me a couple hours.  Part of that
  # difference in time can be explained by the fact that it has been
  # a while since I have worked with socket code , programmed in C ,
  # used emacs and, worked with forking code.  No significant problems
  # were encountered but I am a bit rusty.
  # 
  # I have to qualify this by saying that this program uses a CPAN module
  # to deal with being a server.  The C program does that manually with
  # socket code.  Also the C program required I write code to duplicate
  # file descriptors and fork a child to execute the "uptime" command.
  #
  # Finally even with this big block of comments at the top of this file
  # the perl version is half as many lines of code (that I had to write
  # and debug) than the C version.

I copied and edited the Perl program and wrote the C program from scratch.
I want to point out without the comment block the Perl code is only 11
lines of code.

The copy and edit did not save much time.  You can get as much code from
the example at the top of the documentation for the Net::Server module.

Someone wrote a bit of a rant about people who insist on using C.  You can
read it at http://freeshells.ch/~revence/no-c.txt .



Historical Entries   Recent Entries   About The Author   RSS