Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^5: "strong typing" is potentially ambiguous

by sleepingsquirrel (Chaplain)
on Dec 14, 2004 at 23:10 UTC ( [id://414887]=note: print w/replies, xml ) Need Help??


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

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.
  • Comment on Re^5: "strong typing" is potentially ambiguous

Replies are listed 'Best First'.
Re^6: "strong typing" is potentially ambiguous
by hardburn (Abbot) on Dec 15, 2004 at 14:23 UTC

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

        There is a good definition of what a type system is. As I noted earilier in the thread, a type system limits the operations you can perform on a given peice of data (this definition is a bit informal, but will do for now). Further, type systems come out of formal logic, and predate CS.

        From that, the definition of "strong type system" comes quite naturally. If you can perform operations that the type system should have forbid, it's a weak type system. Otherwise, it's strong.

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-19 14:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found