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.


In reply to Re^4: compiling perl scripts aka why is perl not as fast as C by Marshall
in thread compiling perl scripts aka why is perl not as fast as C by punkish

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.