|No such thing as a small change|
What does "efficient" mean?!?by dragonchild (Archbishop)
|on Jan 15, 2002 at 19:31 UTC||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.
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.)
Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.