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

Re^2: compiling perl scripts aka why is perl not as fast as C

by nikosv (Chaplain)
on Mar 22, 2010 at 09:51 UTC ( #830053=note: print w/replies, xml ) Need Help??


in reply to Re: compiling perl scripts aka why is perl not as fast as C
in thread compiling perl scripts aka why is perl not as fast as C

I totally agree.

I don't think that there is a reason to write in C nowadays except in embedded systems where real time speed is crucial.C was being used because its structures map closely to the hardware.

Perl uses references which disallow pointer arithmetic or pointer de-referencing which of course are slower in operation than pointers, but at the same time you don't get involved with allocating and de-allocating memory or playing directly with the hardware generating sigfaults easily.

Other issues that arise from C's non-restriction and flexibility are security oriented such as buffer overflows and string formatting and that is a reason why "plug-ins" libraries like The Safe C Library were designed to patch/correct.

Actually quoting the Safe C String Library overt security goals "The API should be capable of tracking whether strings are "trusted", a la Perl's taint mode.";even they recognize Perl's value!

This kind of quest for speed would us lead back to assembly which is faster than C. The question is would you like to deal with assembly? as C is a higher level that assembly, Perl is higher level than C.

It' more a question of what you want to TRADE for speed. The industry is constantly trading speed for flexibility and safety. That is why the trend is oriented on Virtual Machines like Java Virtual Machine or the .NET CLR which are layers on top of the OS and protect you from those kind of issues.

But if one wanted to find out what could be done to bring Perl closer to C he could take a look at Why Not Translate Perl to C? by Mark-Jason Dominus.

  • Comment on Re^2: compiling perl scripts aka why is perl not as fast as C

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://830053]
help
Chatterbox?
[atcroft]: .oO(It is a well-known, well-tried module that has probably encountered more corner-cases and oddities than the average mortal programmer can imagine when trying to roll their own...)
[atcroft]: .oO(*Blah* It, I meant....)
[james28909]: omg
[james28909]: im just finding out that july and august have 31 days?
[atcroft]: stevieb: Apparently it was contagious....
[atcroft]: james28909: Make both hands into fists, place them together (with thumbs concealed), and every knuckle is a month (starting with Jan.) has 31 days, every dip (between knuckles) does not....
[atcroft]: (And Feb. is the odd case, because it is 28, unless it is a year divisible by 4, or if it is divisible by both 100 and 400 (at which point it is 29).)
[james28909]: i know but scroll through your calendar on your computer.

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2017-04-29 04:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (531 votes). Check out past polls.