I find the static type analysis an interesting thing but I hate the idea of having it in a separate file.

I find the static type analysis an interesting thing but I hate the idea of having it in a separate file. I’d rather have all the information in the same file where I can see it.
 
 
You already invited:

Britt Maree - Britt Maree into mango

Upvotes from:

 I believe the type checking is for Ruby not the developer so it can pick up errors and apply optimisations. If you want type annotations then the Stripe thing, Sorbet, is what you want.

jack

Upvotes from:

@Britt Maree I get that bit. It’s just that if we are going to have the benefit of static type analysis/checking then I would also like to see annotations (optionally) in the code. It’s my number one problem with dynamically typed languages.

JavierPons

Upvotes from:

I think Ruby should borrow from what Elixir does here. Type annotations optional, but in-file above the function you define.

e.g.
@spec my_fun(String.t) :: nil | String.t
def my_fun(my_string) do
...
end
Or for rubyness
@spec my_fun(String) :: nil | String
def my_fun(my_string)
...
end

Michael

Upvotes from:

Ruby is optimised for Ruby happiness,doesn't have the same ring to it?can happiness ever be attained, anyway? 

Smurfin

Upvotes from:

Part of the tension is that Matz has said he likes type checking but not type annotation. I got the impression in the RubyKaigi write-up that this is an ongoing discussion.
I don’t know much about Flow, but I enjoyed TypeScript’s annotations.

Seb640

Upvotes from:

Working in JS a lot day to day I miss the tidiness of Ruby code and Flow type annotations just make that worse.
 
It’s not too bad, just a bit messy. I would expect TypeScript would be tidier as it can rewrite the parser.

If you wanna answer this question please Login or Register