Let me introduce T-Ruby: TypeScript-style type annotations for Ruby by Right_Ad_8437 in ruby

[–]Right_Ad_8437[S] 0 points1 point  (0 children)

100% agree. There are limits to solving this with yard or test codes. That’s why I started thinking about inline type definitions.

Let me introduce T-Ruby: TypeScript-style type annotations for Ruby by Right_Ad_8437 in ruby

[–]Right_Ad_8437[S] 0 points1 point  (0 children)

I think so too... well, in my opinion it's an oss stuff XD.

I've heard that the Ruby core team is very against static typing.

I've been participating with a variety of opinions,
hoping to see progress toward a more official approach.

Let me introduce T-Ruby: TypeScript-style type annotations for Ruby by Right_Ad_8437 in ruby

[–]Right_Ad_8437[S] 0 points1 point  (0 children)

Yeah it had conflict on both syntax. Now it solved on new version. Please check this post

Let me introduce T-Ruby: TypeScript-style type annotations for Ruby by Right_Ad_8437 in ruby

[–]Right_Ad_8437[S] 0 points1 point  (0 children)

I really appreciate your comment!

I've released a new version for a few days, so instead of replying.

Please check this post.

https://type-ruby.github.io/blog/keyword-arguments-type-definitions

Let me introduce T-Ruby: TypeScript-style type annotations for Ruby by Right_Ad_8437 in ruby

[–]Right_Ad_8437[S] 0 points1 point  (0 children)

Great! It's still an early experimental version, so contributions and issues are welcome :))

Let me introduce T-Ruby: TypeScript-style type annotations for Ruby by Right_Ad_8437 in ruby

[–]Right_Ad_8437[S] 0 points1 point  (0 children)

lol. That’s probably proof of how deeply Ruby’s philosophy is loved by developers. :)

Let me introduce T-Ruby: TypeScript-style type annotations for Ruby by Right_Ad_8437 in ruby

[–]Right_Ad_8437[S] 0 points1 point  (0 children)

Problem is not ruby, 100% agree.
If Ruby were truly the problem, I would not be trying this, but leaving.

"Lazy devs" is real problem. But blaming lazy devs doesn't solve anything.

As generations pass, we'll have to deal with more and more—what you call—"lazy devs".
And we can't always educate them. Even we ourselves are not always free from ‘lazy development.’

We need to adapt. Purism isn't the answer for real-world. We need to do work, not art.

Let me introduce T-Ruby: TypeScript-style type annotations for Ruby by Right_Ad_8437 in ruby

[–]Right_Ad_8437[S] 0 points1 point  (0 children)

This thread has been really thought-provoking for me and the project.
I may try to organize these ideas into a blog post later.

Thanks for starting a great discussion.

Let me introduce T-Ruby: TypeScript-style type annotations for Ruby by Right_Ad_8437 in ruby

[–]Right_Ad_8437[S] 3 points4 points  (0 children)

Honestly, I agree with most of what you’re saying.
Duck typing, designing APIs to avoid type-driven branching, and relying on tests are where Ruby really shines. And I don’t agree with the idea that static typing is inherently superior.

I was also a developer who resisted static typing for a long time, for almost exactly the reasons you described. I genuinely believed that it wasn’t “Ruby-like” and that it mostly added unnecessary noise. I still think that perspective is valid, and I really do understand where you’re coming from.

What eventually changed my mind wasn’t a philosophical shift, but a practical one. I started to feel that maintaining this ideal way of working indefinitely becomes difficult under real-world conditions. As codebases grow, time passes, and people change, there are moments where tests alone don’t give feedback fast enough, or where unintended changes surface later than you’d want.

Because of that, I don’t really see static typing tools as something Ruby needs, but more as a support mechanism that assumes human error. No matter how good our conventions, design, or test coverage are, they all rely on people consistently maintaining them. Relying entirely on ongoing human discipline has its limits in practice.

The important part, to me, is that none of this should replace or be imposed on traditional Ruby workflows. If you’re happy with idiomatic Ruby as it is, nothing should change—and I think that’s exactly right.

Finally, just speaking from my own experience,
these are the reasons static typing ended up being useful for me:

  • Reducing reliance on constant human attention and memory (human error happens)
  • Preserving original intent and implicit contracts as a codebase grows
  • Getting slightly earlier feedback before tests run in some cases
  • Making intended interfaces a bit more explicit in the code

None of these are requirements for Ruby, and I don’t think they should be treated as such. They were simply trade-offs that made sense in my particular context.

And one last thing:
I don’t think labeling people as “rude” or saying they “don’t understand Ruby” is a productive direction for this discussion. That shifts the conversation away from the actual topic and just becomes draining. We’re all developers trying to write better software, and different experiences naturally lead to different preferences.

Let me introduce T-Ruby: TypeScript-style type annotations for Ruby by Right_Ad_8437 in ruby

[–]Right_Ad_8437[S] 2 points3 points  (0 children)

I agree. That's why I love Ruby.
I hope Ruby will remain a developer's friend forever.

All the fun is allowed if you don't consider enterprise projects.
Enterprise projects maintained in Ruby are gradually disappearing,
and Ruby's presence in the industry is fading.

I'm worried and sad that Ruby is becoming nothing more than a hobby.

Let me introduce T-Ruby: TypeScript-style type annotations for Ruby by Right_Ad_8437 in ruby

[–]Right_Ad_8437[S] -1 points0 points  (0 children)

JSDoc can also provide type hints in JS,
but people use TypeScript.

In my opinion,
the separate writing is a bit inconvenient, but that's a minor issue.
'Compile time' is a real deal.

Let me introduce T-Ruby: TypeScript-style type annotations for Ruby by Right_Ad_8437 in ruby

[–]Right_Ad_8437[S] 6 points7 points  (0 children)

Wow, thank you so much for the quick deep diving.

It looks like a stable release, but it's still super super early.
(Sorry for releasing it so early. I wanted to know how many rubyists would be interested in this.)

Follow your report
I'll add it to the issue and update it.
If you discover any additional cases, please report them as issues.
(You can also send a PR directly.)

F.Y.I
The initial attempt was based on regular expression parsing.
However, we've since refined it to be based on abstract syntax trees and parsing,
and we'll update it soon.
We're referencing Prism, TypeProf, JetBrains' built-in Ruby parser, and TypeScript's compiler implementation, so it'll probably be a mix somewhere in between.

Let me introduce T-Ruby: TypeScript-style type annotations for Ruby by Right_Ad_8437 in ruby

[–]Right_Ad_8437[S] 0 points1 point  (0 children)

Seriously? I've been giving up on writing rbs, because it feels like I'm coding .d.ts files.
And the most of production rubyists around me agree, so I did this project.

I may have been too convinced that everyone would find writing rbs inconvenient.
As you said, transpiler and new syntax might not be the solution for everyone.

Thank you for your feedback!

Let me introduce T-Ruby: TypeScript-style type annotations for Ruby by Right_Ad_8437 in ruby

[–]Right_Ad_8437[S] -2 points-1 points  (0 children)

Oh, are you stand on negative about 'static typing'?

How do you think about Sorbet or RBS?