Don't ask to ask, just ask | |
PerlMonks |
Re (tilly) 1: Efficiency and overhead of subsby tilly (Archbishop) |
on Nov 16, 2001 at 19:18 UTC ( [id://125828]=note: print w/replies, xml ) | Need Help?? |
If you are into tight code that doesn't waste memory, then
Perl is the wrong language for you. Perl code routinely takes of several times the space and runs at a small fraction of the speed of an equivalent C program. There is nothing you can do about that other than to take up a language whose philosophy on life more closely matches your own. And if you are programming a CGI, the overhead of starting Perl itself is likely to dwarf the puny effects of your modularizing your code (which is unfortunately not free, though it is pretty cheap). But that said, I strongly recommend that you read the chapter from Code Complete on Optimization. As he says there at length, when it comes to optimization, don't lose the forest for the trees. Concentrate on sane, understandable code. Don't worry about efficiency. And then in the time you save with good development practices, profile and optimize what needs to be optimized. Unless you are working on simple, fast code which has to work in embedded chips, and admittedly some do, this advice results in a better development balance, and on real projects is ironically likely to wind up with faster code than people who micro-optimize from the start. So if you have a real programming problem and Perl is a fit, then don't worry about overhead. Program sanely, try not to be stupid, pick decent algorithms, and when you are done, take Devel::DProf out for a spin if need be.
In Section
Seekers of Perl Wisdom
|
|