3 ms·
Perl 6 has gradual typing that is used for optimizations at run-time. So, it's possible to use optional types for optimization (even if this particular implemen
by SwellJoe 11y ago
Perl 6 has gradual typing that is used for optimizations at run-time. So, it's possible to use optional types for optimization (even if this particular implementation doesn't do it yet). And, it sounds like that's actually the purpose of this project from the description. It doesn't even seem like it's trying to add types as a method of avoiding errors.
And, the benefits of typed languages aren't necessarily all or nothing, and they aren't all performance-related. There are many kinds of error that can be revealed by adding type checks to a program, and just like adding more unit tests to an existing program can reveal existing bugs, adding type information could do the same (with arguably less tedium than writing basic unit tests just to confirm something is behaving correctly with a variety of input).
If I can choose to add types to my function rather than writing unit tests that test a bunch of different data inputs, I would definitely prefer to add types. (Now, in the case of some type systems, like Perl 6, you can go crazy with bounds and other things within the type system itself...so you can not only say a function receives an Int, it can also say it receives an Int in the range of -1...43, and nothing else is acceptable). Types are certainly more fun than fuzz testing everything.
None of those benefits require a program to be all-in on having typed data.
- chenglou 11y agoHow does Perl's bound check work? If it's compile time then wouldn't you need some form of dependent types?