Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

"strong typing" is a meaningless phrase

by chromatic (Archbishop)
on Dec 14, 2004 at 17:54 UTC ( [id://414791]=note: print w/replies, xml ) Need Help??


in reply to strong typing
in thread (Completely OT) - Hero(i)n programming language on Slashdot

Consider the difference between value typing and container typing. Then consider that you've told perl not to check for type violations. Why would you expect it to complain about type system violations?

  • Comment on "strong typing" is a meaningless phrase

Replies are listed 'Best First'.
Re: "strong typing" is a meaningless phrase
by sleepingsquirrel (Chaplain) on Dec 14, 2004 at 18:18 UTC
    Then consider that you've told perl not to check for type violations.
    Hmm. Honest question: how do you tell perl to turn on type checking?


    -- All code is 100% tested and functional unless otherwise noted.
      What do you consider "type-checking"? That's also an honest question - it means different things to different people.

      Being right, does not endow the right to be rude; politeness costs nothing.
      Being unknowing, is not the same as being stupid.
      Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
      Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

        In the litature, types systems are well-defined. In essence, a type system limits what operations you can do with a given piece of data.

        Note that "types" come out of formal logic, and predate computer science.

        "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

        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.
      types.pm is an effort in that direction.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-16 16:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found