I look at a lot more than just speed when picking the necessary language.

Most of the time speed is not absolutely critical. Most of the time it is not more important than a) doing the job *right*, b) being maintainable, c) being a bit portable, and other such priorities.

I might use C out of memory concerns. Perl uses a *lot* of memory in its data types.

I might use C because I want a finer level of control. A lot of byte-by-byte or bit-by-bit work is very straightforward in C, while I wouldn't want to do so much packing in Perl. There are things about C that are syntactically very convenient, like its structs, its pointers, and doing bitwise operations in C.

Perl is a heavy layer of abstraction over C. Most of the time this is a very nice thing. But sometimes you want to work under that abstraction, and you simply would rather not have it the way. In that case, I choose C over Perl. C is very simple, and really puts very little in your way. The standard library is very simple and concise, and the language is standardized. Sometimes less is more.

I also tend to use C when I want to have a close connection with my operating system or with my processor, in the way that Dennis Ritchie referred to C as a "portable assembly language". C is just more convenient than Perl in these cases. Perl is nice at making things the same (and easy) across OSes or processors, not at being really particular to them when you want to be.

I guess I didn't really explain any of that very well. I just felt I could explain why I use C about as much as I use Perl, and how speed isn't usually the reason.


In reply to Re: when to c, when to perl by zshzn
in thread when to c, when to perl by stabu

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.