Delphi against the crazy C world

One thing drives me crazy. Why in the today world the ugly C-style syntax became so popular and widespread while beautiful pascal syntax is one on the latest places of popularity. Moreover today many new programming languages appear, and it seems to me the authors of those languages are competing with each other for the price in the category who figures out the most weird way of coding.

Let’s do some math about the SprutCAM project. Today the sources base of SprutCAM is about one and a half million lines of code, and it took 10 years to develop. As I know the effective development team never exceeded 5 men. 1’500’000 lines of code divided by 10 years of 50 weeks with 40 work hours multiplied at 5 men equals to 15 lines of code an hour.

What it looks like:

  result := false;
  at := self.GetArcType;
  case at of
    atL_L: begin
        Result := CalcArcLine_Line(ln1.p, ln1.tt, ln2.p, ln2.tt, s1, s2, fInitRc,
          ap1, ap2, ac, aR);
        if not result and
          IsEqD(1, abs(Vec_mul_Vec(ln1.tt, ln2.tt)), Increment)
        then begin
          result := true;
          ap1 := ProjectPointRay(self.pc, ln1.p, ln1.tt);
          ap2 := ProjectPointRay(self.pc, ln2.p, ln2.tt);
          ac := 0.5*(ap1+ap2);
          aR := VecLen(ap1, ac);
        end;

You can see there are a lot of spaces in each line. Your grandma can type 15 lines of code an hour! This example makes obvious one simple thing. Programming is not about typing. I can approve that programming is much more about reading a code and debugging it than typing it. However the authors of C-style languages think different! They think that by replacing human language words begin, end by curly braces {} and omitting then in the if statement they save hours of programmers lives. Here is an example of a C code.

   stbtt_uint16 format = ttUSHORT(data + index_map + 0);
   if (format == 0) { // apple byte encoding
      stbtt_int32 bytes = ttUSHORT(data + index_map + 2);
      if (unicode_codepoint < bytes-6)
         return ttBYTE(data + index_map + 6 + unicode_codepoint);
      return 0;
   } else if (format == 6) {
      stbtt_uint32 first = ttUSHORT(data + index_map + 6);
      stbtt_uint32 count = ttUSHORT(data + index_map + 8);
      if ((stbtt_uint32) unicode_codepoint >= first && (stbtt_uint32) unicode_codepoint < first+count)
         return ttUSHORT(data + index_map + 10 + (unicode_codepoint - first)*2);
      return 0;
   } else if (format == 2) {
      STBTT_assert(0); // @TODO: high-byte mapping for japanese/chinese/korean
      return 0;
   } else if (format == 4) { // standard mapping for windows fonts: binary search collection of ranges

Just look at those two code snippets! Which one do you prefer?

Advertisements
Delphi against the crazy C world