Gradual type checking for Ruby
github.com
Gradual type checking for Ruby
1–10 of 43 posts
Re: Gradual type checking for Ruby
#2I'm fairly sure it changes the performance characteristics of code it is applied on. I'd recommend adding benchmarks to the README so prospective users might be aware of this beforehand.
Re: Gradual type checking for Ruby
#3This is certainly useful sometimes, as it gives programs the desirable "fail fast" property. But it isn't "typechecking" as most engineers understand it. Or at least, it should be clarified that this is run-time typechecking. As such, it negatively impacts runtime performance, unlike compile-time typechecking.
This project also seems to miss the primary opportunity of run-time type checking: checking properties that are difficult to prove statically! For example, checking that a number is even, that a string is lowercase, that an index is within the bounds of an array, etc. These exotic types require a dependent type system to be checked statically, but in a dynamic environment they are trivial to verify.
Two suggestions for improvement: 1) add "sum" types (i.e., discriminated unions), and 2) let the user define their own types via lambdas, such as PrimeNumber.
Re: Gradual type checking for Ruby
#4Re: Gradual type checking for Ruby
#5Re: Gradual type checking for Ruby
#6> This gem brings you advantage of type without changing existing code's behavior. I'm fairly sure it changes the performance characteristics of code it is applied on. I'd recommend adding benchmarks to the README so prospective users might be aware of this beforehand.
Re: Gradual type checking for Ruby
#7Recently I've had to pickup Hack for work, and if there's one thing I really like about it is the type hinting. The best part is that it helps you handle nullable types (not sure if it's done here).
When I switch back to Ruby from Hack, I find it harder to reason about my program.
Re: Gradual type checking for Ruby
#8Disclosure: this may be a Bad Idea (TM)
Re: Gradual type checking for Ruby
#9I like the aproach Perl 6 took on gradual typing. You can read about it in this article which computes fibonnaci's number:http://blogs.perl.org/users/ovid/2015/02/avoid-a-common-soft...
The only reason I wait for the next winter to come is because Perl6 will be production ready by then as Larry Wall announced at FOSDEM this year.
Re: Gradual type checking for Ruby
#10* It would be better if this didn't pollute the global namespace by defining `#typesig` in `Module` [0] -- perhaps consider refactoring that method into a module which the user may extend. Doing so would also get you out of needing to define `Module#prepend` for older versions of Ruby.
* Perhaps allow the user to enable/disable type checking at a global/class level. For example, then users could only enable type checking during specs if they wanted.
* Instead of using class-level variables, try using class level instance variables. They have less odd behavior when dealing with subclasses [1].
[0] https://github.com/gogotanaka/Rubype/blob/develop/lib/rubype...
[1] http://www.sitepoint.com/class-variables-a-ruby-gotcha/
Edit: Whitespace