I think your question depends largely on what you need to do with your program. C is great for times when you need to be close to the bare metal, but it's difficult to use and can get you into a world of trouble fairly easily. Pointers can be fun and powerful, but they really give you a whole lot of rope with which to hang yourself. You should see my poor neck ;-)

To my understanding, C would be faster to run for most uses. It compiles to machine code, as opposed to Perl compiling to byte code. This won't matter if you're waiting for a keypress, but in graphics and heavy math, the difference may be crucial.

The thing is, it takes much longer to develop working code in C. Imagine what is involved in creating, filling, and sorting a hash. A competent Perl programmer could knock it out in a few minutes. A Perl wizard could probably write a one-liner. A good C programmer would probably need an hour or more to accomplish the same thing.

In general, I'd use Perl for just about everything, because it is so easy to use (and fun). And because if I get stuck, I can always come here to Perl Monks and get an answer within minutes (usually). If I were trying to do something with heavy graphics use, hairy math (matrices, for example), any sort of time-consuming stuff, and if there were going to be large iterations of things, I'd probably bite the bullet and write at least those parts in C. So far, I haven't found anything that has required me to do this. Perl has worked just fine for everything I've needed, even digesting megabytes of text and spewing it out all neatly organized. I'm glad C is available, "just in case", but I hope I'll never need it.


In reply to Re: (OT) perl cmp c by spiritway
in thread (OT) perl cmp c by leocharre

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.