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

Re: Griping about Typing

by maverick (Curate)
on Apr 19, 2002 at 14:47 UTC ( #160564=note: print w/ replies, xml ) Need Help??


in reply to Griping about Typing

Perhaps all things can peacefully co-exist when you apply the rule of 'right tool for the job'...

Pro - "Gimme my $foo!!!!"

How much memory is consumed by the standard $foo? Let's assume it's 20bytes (since I really don't know), so for my little

for (my $i=0; $i < 10; $i++) {
I'm wasting 19 bytes...assuming that $i could be a short.

Ram is cheap; processors are powerful. For my Perl app on a server, who cares that $foo took up 20 bytes? That trade is worth my time to not have to go through the reasoning process for a strong typed variable...

  • what am I gonna store? and integer.
  • only positives? ya.
  • what's the biggest value? 10
ah! unsigned short foo;

And those 19 wasted bytes are worth it to be able to stay focused on the larger goal.

Here's another problem with strong typing...what is the maximum value you can put in an unsigned int?

The correct answer is: depends. Depends on what kind of hardware you're using. ick! On a x86 and int is 4 bytes, or is it 2? I forget. It could be 3.5 on a SPARC for all I know...and that leads to major portability issues.

Con -- "Hey, where's the SIMM slot on this Palm III?"

Consider this scenerio. I've got my (slightly dusty) Palm III or some other such hand held device. Even if there is a Perl intepreter for it, I would be very hesitant to use it. Why? My Palm has 8meg of memory, for apps and run time execution. If I have $foo,$baz,$bar,$qux and they are all unsigned short counters of some sort, I've wasted 76 bytes. Can I afford to do that on a Palm that has 2 meg of free space? I don't think that I can.

I guess you can sum it up by saying, that your choice of tool must be driven by your requirements and environment. Sometimes strong typing is a must...sometimes it isn't and just gets in the way.

All things have their place. :)
/me sits in lotus position; "Ohhhhmmmmm...."

/\/\averick
OmG! They killed tilly! You *bleep*!!


Comment on Re: Griping about Typing
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://160564]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2014-09-18 00:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (101 votes), past polls