News for hackers. Stuff that matters.
Re:Adopting Ruby 3 types with RBS by richard_todd on Saturday December 26, 2020 @12:32AM (#25541641)
I'm seeing comments asking "why a separate file?" I watched a video last night from the creator of the language (at https://www.youtube.com/watch?v=IhTXDklRLME) where he addresses it.

At 12:20 minute mark he basically says he doesn't like annotations, and calls the separate file a compromise several times. At 19:46, he admits it's hard to maintain separate files. At 20:57 he says annotations are not DRY, would change the language, and aren't necessary for performance (points to V8/Chrome). At 23:10 he says no to annotations because he thinks one day the tools will be smart enough to give you the same guarantees/diagnostics without them, so at 24:50 he concludes that he doesn't want to have to remove annotations when that comes to pass.

(don't shoot the messenger! I don't necessarily agree with these conclusions...)

(edit: tried to make the summary clearer)

Re:Adopting Ruby 3 types with RBS by jolux on Saturday December 26, 2020 @12:47AM (#25541708)
That's a pretty appalling set of justifications. I don't know of any type systems with perfect type inference that are still useful for fully exploiting types.
Re:Adopting Ruby 3 types with RBS by Trasmatta on Saturday December 26, 2020 @03:37AM (#25542181)
Crystal is the closest I've seen to match that. It's type inference is the most robust I've seen, you can write it almost like Ruby and still get full static type checking. I prefer to still use annotations fairly often with it though.

The trade off for that powerful type inference is a slow compiler.

Re:Adopting Ruby 3 types with RBS by Rochus on Monday January 04, 2021 @01:14PM (#25635499)
> Crystal is the closest I've seen to match that

And it's 20 times faster than MRI Ruby JIT 3.0, see http://software.rochus-keller.ch/are-we-fast-yet_crystal_rub.... It's a pity Ruby typing went in another direction.

> The trade off for that powerful type inference is a slow compiler.

When run in the default (i.e. no release, debug) mode, build time is ok, especially for rebuilds when only one file has changed which is less than a second. Release builds are slow (see my PDF).

Re:Adopting Ruby 3 types with RBS by tinco on Saturday December 26, 2020 @08:14AM (#25543248)
You can go really far in Haskell without specifying a single type. I haven't done so in a long while, but I'm pretty sure explicit types in Haskell are only necessary when you're trying to lock down an API or are outputting to something generic.

And how are the justifications appalling? He thinks annotations are a detriment to the expressiveness of the language, and Ruby prides itself on being expressive.

Re:Adopting Ruby 3 types with RBS by jolux on Saturday December 26, 2020 @12:08PM (#25544696)
Locking down an API is a critical feature of a type system, though, and beyond that, there are absolutely language extensions in Haskell that are not inferrable, in addition to polymorphic recursion. OCaml is the same way: the inference is very good, but not total.

As for being a reduction to the expressiveness of the language, I think Haskell is proof that you can have annotations without reducing the expressiveness of the language. Type annotations in Haskell and Idris don’t even interfere with value-level syntax!

Re:Adopting Ruby 3 types with RBS by syspec on Saturday December 26, 2020 @04:59AM (#25542444)
Interesting, and great video find!