Usually one chooses to interface to C rather than C++ because two different object virtualities can cause unexpected results.

C is a descendant of BCPL, which was almost an assembler in its design. The { } in C (and Perl) is a simplification of $( $)in BCPL. But BCPL also had $[ and $]to denote a section of machine assembler being inserted directly in the code for co-assembly/compilation into object code.

There is an opportunity to link object code created by compiled languages into the Perl interpreter, though this tends to be avoided for practical reasons such as ease of distribution.

Generally speaking the descent into C (or even assembler/MACRO-32 in the case of DOS and VMS), tends to be justifiable only by the need to use low level features such as:

- direct access to virtual memory instead of Perl's symbolic memory - this is not usually motivated by performance, in spite of that being a popular knee-jerk argument - but more likely being driven by needing to use a direct virtual memory interface to an external service or a device - in regard to performance, Perl's symbolic memory is a good enough interface to virtual memory anyway.

- interfacing to object modules, device drivers or shared libraries that are created from a compiled language or sometimes assembler as described above.

So it's more a question of using programming opportunities than solving programming problems.

One world, one people


In reply to Re: Combine Perl with C++ or C by anonymized user 468275
in thread Combine Perl with C++ or C by maverick_anew

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.