Slash Boxes

All the Perl that's Practical to Extract and Report

More | Login | Reply
Loading... please wait.
  • Perl's static type system cares more about containers than values. Ponder that for a while, if you really want to confuse the debate.

    • That's actually a point explicitly raised in the article. Dynamic systems focus tracking what kinds of data are used in a system, not on syntactic evaluation of expressions. See the "Problems with Common Definitions" section which begins with this:


      • That's not quite the same. Perl 5's built-in static types are scalar, array, and hash (and Maybe reference, if you pardon the Haskellish pun). You do get compile-time checks on using them appropriately.

        • The important point is that Perl's type system is still primarily dynamic in nature, though as the article points out, static languages all have dynamic elements and vice versa. Perl's compiler is incapable of arbitrary reasoning about the adding two scalars together. They might be overloaded. They might be overloaded at runtime. They might have strings, they might have numbers, etc.

          Perl's extremely limited type system in fact, must be explicitly requested:


          print "foo ($test[1]) bar";

        • While those three are what most people are aware of using, Perl 5 has more static types than that. For example typeglobs. Perl 5 also has a parallel static type system in its attribute system.

          That said, the article did not draw the usual simplistic divisions. And made a point of saying that many languages have both static and dynamic systems, but usually one is more fully developed. Meaning that there are classes of problems that can be solved either through a dynamic type system or a static type system

          • Inside interface boundaries, quite likely, but I suspect that the use of static types will be quite common for published APIs at least in certain kinds of domains. At the point where client code might lob parameters at you and you can’t be certain that you’ll be called correctly, you need checks on the values anyway, and it’s much easier to do that by declaring signatures than by hand-rolling validation code (or even writing validation profiles for Params::Validate or whatever). Even so I

          • However the complex things that you'd want from a type system are mostly done with dynamic typing in Perl.

            Wouldn't it be more fair to that that the things we think we want from a type system are done with dynamic typing in Perl? Since, as the author points out, you can capture and verify domain specific knowledge via a static type system (see the paper on using static types in Haskell to verify that a database is normalized), it appears that what people are typically doing with static types is rather generic, but their advanced expressiveness (such as catching infinite loops) is not possible with Perl 5, Pytho

            • I didn't say all, I said mostly.

              It is true that an advanced static typing system can do things you simply can't do within Perl 5. On the other hand duck typing allows things that can't be easily done within a static system. Think Test::MockObject and Test::MockObject::Extends.

              However the majority of the day to day utility that most people want from a type system can be delivered either way. It is possible that if more people knew what was possible then our wants could change and that would no longer be t

              • Actually, the paper appears to start with Portuguese for the introduction, but the paper itself is in English. That threw me off, too. Aside from that, your points are well taken.