C you Dennis!

Francis Sedgemore, Thursday 13 October 2011 at 14:55 UTC

Dennis MacAlistair Ritchie (1941–2011)
Dennis Ritchie, inventor of C, the world’s best known computer programming language, is no more.

Despite being a highly experienced Fortran programmer, I once coded an entire upper atmosphere chemistry and physics model in C. Just for the hell of it. That model is the most elegant and efficient computer code I have ever written. Poetry in malloc

for(j=0;j<t_reactions ;j++)
  {
   if(reaction_table[j].species_1==UNITY_INDEX)
    s1=1.0;
   else
    s1=u[reaction_table[j].species_1];

   if(reaction_table[j].species_2==UNITY_INDEX)
    s2=1.0;
   else
    s2=u[reaction_table[j].species_2];

   r_rate=find_reaction_rate(reaction_table[j].rate,u,*x);

   reaction[j]=s1*s2*r_rate;
  }

RIP Dennis MacAlistair Ritchie (1941–2011)


  Feed the writer!   

Comments

  1. Dom

    Back before Java (or C-sharp), malloc was the major source of my bugs, since it’s unmanaged. It just sits there if you don’t dispose of it.

    BTW, always put the constant first in comparisons in any c-derived language. Eg,

    if (UNITY_INDEX == j)

    That way, the compiler will catch the most common error, typing “=” when you mean “==”.


  2. Francis Sedgemore

    But this model is, or was, mine, and I would never commit such a heinous error.