Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Griping about Typing

by FoxtrotUniform (Prior)
on Apr 18, 2002 at 16:29 UTC ( #160252=note: print w/ replies, xml ) Need Help??


in reply to Griping about Typing

    What on Earth is so great about strong typing that I have to have it?

I've usually been told "strong typing: good!" with no rationale. Occasionally, I'm told "strong typing helps prevent programmer error", with no explanation of how it prevents errors. (Okay, so it stops me from adding a string and an int. If I was adding strings and ints and expecting to get something useful, I have deeper problems than weak typing.)

It occurs to me that a C-like "suggested typing" system encodes some information about a variable's domain. For instance, declaring int foo; says some things about foo: it measures a discrete value, for one. Chances are, the more information you give the person reading your code, the better; on the other hand, I can't think of any situation where this would be more useful than a proper variable name (my $line_count;).

About the only advantage I can see in a stronger typing system than Perl's is the ability to align data in memory very precisely, which is useful when you're talking directly to hardware. I don't know of anyone doing that in Perl, though, and it doesn't require a strongly typed language: C does it rather well.

--
:wq


Comment on Re: Griping about Typing
Select or Download Code
Re: (FoxUni) Re: Griping about Typing
by kappa (Chaplain) on Apr 19, 2002 at 08:23 UTC
    You wrote:
    Occasionally, I'm told "strong typing helps prevent programmer error", with no explanation of how it prevents errors. (Okay, so it stops me from adding a string and an int. If I was adding strings and ints and expecting to get something useful, I have deeper problems than weak typing.)
    Please consider this C code:
    char name[] = "miguel"; int st_len = 0, namel; namel = strlen(name); st_len += name;
    See my error (actually a typo)? See how gcc warnings (which are kinda weak strong typing) save my time?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2014-11-27 19:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (187 votes), past polls