Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Over the past month, there've been at least two separate meditations on whether Perl is more (or less) efficient than other languages. C/C++ seem to be the most common comparison, with Java a close second. Yet, I'm noticing that very few people are talking about what "efficient" means. I see that there is more than one "efficiency" measure.
  1. CPU-efficient: executing statements faster
  2. RAM-efficient: taking less RAM for the same stuff
  3. development-efficient: taking less programmer time to write a program to accomplish the same task
  4. maintainence-efficient: given a program that is already written, modify it to accomplish a new task
Having my primary experience with C/C++, Perl, and BASIC (especially Excel's VBA), I'll only speak to those three languages. Also, I'm going to assume a decent professional programmer, but not a guru-level expert.

C/C++ is faster in terms of CPU. Why? Because C is Perl's machine language. Perl is tokenized to some assembler (soon-to-be Parrot), then each token is converted to some "machine language" which is implemented in (extremely optimized) C. If equally-optimized C is used without the Perl tokenization, it will necessarily be faster. Plus, C's data structures aren't stuffed with Perl's information-tracking additions.

So, C/C++ is more efficient in terms of the computer.

Writing a program in Perl, however, is generally quicker - in terms of programmer time - than in C/C++. I have a richer set of nouns (primitives) and verbs (operations) than in C/C++. More complex operations are supported in the language and there are operations in Perl than would require hundreds of lines in C/C++ to accomplish. This is especially true in string processing.

In addition, because C programs tend to be more complex than Perl programs, maintenance on them is more complex and error-prone. A 500 line Perl program is often equivalent to a 2500 line C/C++ program. That's five times the places an error can be hiding and five times the places you can inadvertantly add an error. I'm not keen on working with that kind of situation.

So, Perl is more efficient in terms of the developer.

Unless you need the computer efficiencies, I'd go with Perl.

(The astute observer notes that I didn't mention VBA. That's cause it's more of a fungus and not a computer language.)

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.


In reply to What does "efficient" mean?!? by dragonchild

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-24 10:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found