In Perl it is easier to share code between code-bases. C's verbosity and macro support tends to encourage the development of large complex bodies of macros. Code can't be compiled without the header file defining the macros, and more importantly, the C code often makes no sense unless you are an initiate in that code-base's macro "jargon".

Perl also lets one define language constructs and change the compilation process in seemingly hidden ways, but there is less incentive to use these tricks because Perl is a reasonably succinct language to begin with. Furthermore, doing this kind of magic requires some fairly advanced knowledge of Perl (e.g. understanding symbol tables or the difference between BEGIN and CHECK blocks and the contexts in which they are evaluated). As a result, customized "extensions" to the Perl language tend to be fewer, more well thought out, and better documented than your average C macro header file. (ok, I can see some disagreeing here :-) -- Perl has its own share of horrible code)

Compilation and execution are integrated in Perl whereas C is normally compiled in one phase and executed in another. This makes Perl an ideal tool for solutions where (a) things might need to be patched on the spot (b) bootstrap sequences where tool A1 generates code for tool A2 which then automates the build of tools B1,B2,B3.

In truth any scripting language could play this role. However, I find Perl is a particularly good scripting language choice because it cleanly supports a wide variety of data structures and its support for OOP allows close integration of data and action. When strictures are turned on it also does a reasonably good job of identifying misnamed variables and code that might not behave as intended. This makes it possible for one to maintain even complex scripted solutions with relative ease.

Best, beth


In reply to Re: Perl vs C by ELISHEVA
in thread Perl vs C by santhosh_89

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.