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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||