Show HN: Ruby static type checker – proof of concept
github.com
github.com
> Crystal’s syntax is heavily inspired by Ruby’s, so it feels natural to read and easy to write, and has the added benefit of a lower learning curve for experienced Ruby devs.
> Crystal is statically type checked, so any type errors will be caught early by the compiler rather than fail on runtime. Moreover, and to keep the language clean, Crystal has built-in type inference, so most type annotations are unneeded.
Imagine you have a big ruby project in production and you want to add static type checking. You won't be able to use Crystal for it, while the idea behind Diamondback Ruby is to be able to integrate it gradually.
It's not a static type checker for Ruby, though.
Both Diamondback and RDL come out of UMD. I'm curious what drives this research there. From what I can tell, Ruby is barely touched otherwise by academia.
Was a really interesting and well-done talk, IMO. I am not a type system geek, but thought it was fascinating to hear all of the tradeoffs that go into designing a system like this.
There’s a tiny bit more Ruby in academia but not much http://rubybib.org/
I don't know what motivates Ruby research particularly, but those two languages make up a large chunk of our PL classes.
I guess that the number of Ruby developers knowing about the two drubies is more or less the same, but maybe DRuby is not the most fortunate choice for a name.
[1] https://ruby-doc.org/stdlib-2.4.2/libdoc/drb/rdoc/DRb.html
I'm not seeing why this is needed, other than people who find comfort in static typing think Ruby is broken without it.
I've been programming with Ruby every day for 5+ years, and it performs and debugs just fine without static typing.
My summary opinion is if static typing makes you happy go for it. Please don't try to force it into Ruby as a feature of the language, however, as it's current model of dynamic typing is one of it's best features.
This is a good thing for dynamic language adoption, because it means that organizations that evolve to where static typing is more important (larger teams and code bases, basically) don't have to either do a ground up rewrite or forgo it's benefits.
If you call a three-arg function with only two-args, it is more helpful to see a diagnostic than not to see a diagnostic, all else being equal.
1) use guards 2) add tests which check types 3) use error reporting software, like Sentry, and cath errors in production
Is there any reason you do not want not catch type errors without additional code and useless tests before you deployed it to production?
https://blog.acolyer.org/2017/09/19/to-type-or-not-to-type-q...
Yes, it is because this is a fork of a project started in 2009 (and not maintained afterward). I spent a couple of evenings trying to resurrect it and see what this thing is capable of. There is a lot of things to do to make this really usable. But I was able to get it to the point to run examples (those examples are the same in ruby 2.4).
After all, Crystal is already quite good as a Ruby+static typing solution
> we might never get static typing for Ruby anytime soon
Yes we will not get type declarations as a part of Ruby syntax anytime soon, but this doesn't mean we can not have static type checking right now