Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^4: "strong typing" is potentially ambiguous

by hardburn (Abbot)
on Dec 14, 2004 at 22:10 UTC ( [id://414877]=note: print w/replies, xml ) Need Help??


in reply to Re^3: "strong typing" is potentially ambiguous
in thread (Completely OT) - Hero(i)n programming language on Slashdot

A lot of the "strong typeing is good!" comes out from people who use (by choice) langauges that are more acurately called "static" (i.e., the types are determined at compile time), not "strong". Any language with a type system like Pascal's falls into this category (including C and Java).

However, most of these people don't realize what a real strong type system looks like (for starters, real type systems don't need int/float/etc. declarations). There are languages with weaker type systems (like TCL, where everything is a string weather you like it or not), but C and Java are actually pretty far down on the list in regards to the strength of their type system.

You are correct to say that the strength of the type system is not a binary proposition, but rather a ranking. I assert that Perl's type system is overall stronger than C's or Java's, even if it's limited in the number of types it has. OTOH, it's significantly weaker than OCaml or Haskell.

"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.

Replies are listed 'Best First'.
Re^5: "strong typing" is potentially ambiguous
by sleepingsquirrel (Chaplain) on Dec 14, 2004 at 23:10 UTC
    I assert that Perl's type system is overall stronger than C's or Java's, even if it's limited in the number of types it has.
    Ah, here's where we part company. C and Java have many types (unlimited in fact, go ahead make your own structs, unions, etc.). And they also do their type checking at compile time. Sure, if you want you can subvert the type system in a way that you couldn't with an ML or Haskell, but its much harder to do it accidently. Fewer types is synonymous with having fewer proofs of the programs behavior. I like perl as much as the next guy (heck, counting just now, I've got 6 books on my bookshelf with "perl" in the title), but all else being equal (i.e. same quality programmers, etc.), if I had to choose between being hooked up to a heart/lung machine running Java, and one running Perl, I'd pick Java. I wonder what they really use? If we knew the answer we'd probably all shudder. Now the question becomes, if I was going to design the heart/lung machine I'd be using on myself, what language would I use? I'd probably want to create some sort of very minimal strongly-typed hybrid lisp/haskell, in which I'd proven the compiler correct with some sort of computer algebra system.

    If you want more typing theory discussion than you can shake a stick at, I'd recommend some of these threads...

    Why type systems are interesting
    Why type systems are interesting - part II
    Why type systems are interesting - part III: latent types


    -- All code is 100% tested and functional unless otherwise noted.

      Sure, if you want you can subvert the type system in a way that you couldn't with an ML or Haskell, but its much harder to do it accidently.

      If you can subvert the system, then it's not strong. It's pretty much impossible to subvert Perl's type system, except using operations that are valid in any programming language (as I demonstrated eariler in the thread). The fact that Perl has a limited number of types is irrelevent to any argument over its strength.

      You could say that C/Java/etc. has a more useful type system. However, because of its lack of strength, I don't think Pascal-derived type systems are useful for showing program correctness. They are only good for providing hints to the compiler. Which is really all they were designed for.

      I lurk on Lambda, and have read parts of the flame war^H^H^H^H threads you mention. There's a lot of material there to go through.

      "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.

        If you can subvert the system, then it's not strong.

        Please go back and read MJD on Strong Typing again. As he says, there is no universally agreed-upon definition of "strong typing". One of the several de facto definitions he cites is the one you're reflecting, above. But there are others. Given that, it would be wise (IMHO) to stop trying to argue whether/how Perl's type system is "strong". Thanks.

        (Update: "more typing goodness from MJD", as sleepingsquirrel put it.)

Log In?
Username:
Password:

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

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

    No recent polls found