in reply to Re^2: compiling perl scripts aka why is perl not as fast as C
in thread compiling perl scripts aka why is perl not as fast as C

C is a much simpler language than Perl and much easier to learn.

That vastly depends on what you mean by learning a language, and how familiar the potential programmer is with low level concepts like computer memory.

If she is an experienced assembler programmer, C is probably easier to learn than Perl. If she has no clue about memory, pointers, segmentation faults and the like, Perl is easier to learn.

Also it depends on how you count: it might be easier to learn 90% of the features of the C programming language than learning 90% of the features of Perl. But the difference is that with 20% of Perl features you can already achieve a whole lot of stuff - but not with C.

So if you count "learn enough of a language to get stuff done", I disagree that C is easier to learn than Perl.

Perl 6 - links to (nearly) everything that is Perl 6.
  • Comment on Re^3: compiling perl scripts aka why is perl not as fast as C

Replies are listed 'Best First'.
Re^4: compiling perl scripts aka why is perl not as fast as C
by Marshall (Canon) on Mar 23, 2010 at 00:52 UTC
    So if you count "learn enough of a language to get stuff done", I disagree that C is easier to learn than Perl.

    I definitely agree with this. C is a "short" language, but it takes a lot of training to learn how to use it effectively and well. Just because there aren't that many functions in the base language, doesn't mean that it is easy.

    Perl helps immensely on two main 'C' problems: "off-by-one" and use of unallocated or un-initialized memory! The Perl foreach(@ayx){} is magic - so much better than C for(i=0,...). Also for example, I helped a student a couple of weeks ago with an array of struct problem. Due to a defect in his malloc algorithm, sometimes one element of this array of struct wasn't being initialized. The student actually had a setup where "hey my program works on this computer A and it doesn't work on this computer B". The difference was that the "garbage" left in memory on computer A from some previous thing happened to be "0's" while on the other machine B there was something different. Perl has fewer of these "hey it worked on Tuesday, but doesn't "work" on Thursday problems.

    I read some comment in this thread about assembly vs C. As it turns out modern "C super compilers" are very, very good. I am just guessing, but maybe 10% of asm coders could beat one of these things cranked up it its highest optimization level. ASM is way harder than C or Perl and "average ASM" is likely to run slower than well written C using a good optimizing compiler! Now, I do like ASM and there is a place for this to be used!

    Anyway back to Perl and C, my experience is that coding efficiency is like 5 or 10 to one vs C. Perl runs like 1/3 speed (assuming both "smart" C code and Perl code). Whether this mix is what you see depends upon what tasks you are coding.

    I am currently tutoring some Perl, C and ASM classes. Perl is not a good beginner language. The folks who do well in Perl have good C skills (and by that I mean going way past "hello world!". In the "old days" folks started with ASM, but now the good starting place is 'C'. The folks who do well in ASM also have good C skills.