Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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*!!


In reply to Re: Griping about Typing by maverick
in thread Griping about Typing by Ovid

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 chanting in the Monastery: (2)
As of 2024-04-26 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found