Alright,
jdporter from below has a good pointer to a message about typing my MJD, where Mr. Dominus lays out some of the crucial issues. Here's my view on the issue of typing. First, I'll tackle my definition of typing. A type system is a meta-program which examines other programs in order to prevent meaningless ones from executing. Take the set of ASCII files. Only a small number of those are valid perl programs which will pass a
perl -c check. Now take the set of perl programs. A type checker would disallow certain syntatically correct programs that didn't conform to the type system. The classical example (forgetting perl for the moment) is a statement like
3.14 + "dog". If we assume that 3.14 is a floating point number, "+" is the addition operator, and "dog" is a string, most people might agree that the statement is meaningless. So the people creating your type system might say, "Arrrgh! That's garbage, let's outlaw the programmer from using statements like that." Or the less controversial statement, "That statement has little meaning, we'll add more value (through program clarity, cleaner semantics, fewer typos, etc.) by banning such statements." Of course the other camp says, "We don't like meaningless programs either." So they solve it by decreeing that every syntatically valid program has meaning. And you get (well documented) behaviors like,
$a = $b + @c; where the array @c in that statement refers to the length of the array, instead of the actual array.
Now, I'm going to submit to the jury that the "strong" part of "strong typing" is currently potentially ambiguous. I say currently, because eventually, I think enough people will start to agree on one definition (here's to hoping they pick a version close to mine). Different people will see things differently. Just like the word "hot". Some might say that the sahara desert can get hot. Residents of Venus might disagree. But most of us will agree that the surface of the sun is hotter than the surface of Pluto. So I'll try to outline some of the things that I think make a type system "stronger".
- A larger number of types make the type system stronger. If you only have one universal type, you can't have type errors and won't reject any programs.
- Fewer number of implict conversions makes the type system stronger. If the system automatically converts between all types (regardless of how well documented) you're no better off than the system with one type.
- Catching type errors earlier makes the type system stronger. Catching errors at compile time is better than at run time. And catching type errors at run time is better than not catching them at all (i.e. core dump).
Questions? Comments? Suggestions?
-- All code is 100% tested and functional unless otherwise noted.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
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:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.