Live data from Hacker News

T-Ruby is Ruby with syntax for types

type-ruby.github.io

51–60 of 155 posts

Re: T-Ruby is Ruby with syntax for types

#51

Honest question: I like typescript and I think it makes sense:, the web makes you married to JavaScript, so it’s the reasonable path forward if you want types in that context. But what is the point of the recent wave of types for python, Ruby, and similar languages? If it’s type safety you want there, there’s a bajillion other languages you can use right?

> what is the point of the recent wave of types for python, Ruby, and similar languages?

Code that doesn't integrate directly with wires (controllers, active record, websocket, etc)

IMO This is for complex, well refactored, testable code that provides a business layer. Coding larger projects like depot management, shipment, order management, middle frequency trading, customs all benefit from types and IDE help. Types basically scale the language beyond just filling in the blanks in your framework. You can get pretty far doing that, but not far enough. That's why all ruby based companies push for type systems. They know the pain of not knowing what to pass, or refactoring code that allows a parameter to be multiple types.

Re: T-Ruby is Ruby with syntax for types

#52
post #49

Worth mentioning is Crystal lang: Ruby, with types!

How alike actually are Ruby and Crystal? I’ve heard the similarity is only skin-deep: similar syntax but quite different semantics. In other words, isn’t describing Crystal as “Ruby with types” similar to describing C++ as “JavaScript with types”?

Yes, Crystal is not a superset of Ruby with all of its behaviors and semantics. And thus, it is great if you are starting fresh and don't mind foregoing the Ruby gem ecosystem and the popular frameworks like Rails proper.

But it's not a migration path for Ruby codebases to add types, like the new initiatives for type annotations are. It's just that the syntax used by the available options has been somewhere between bad and downright terrifying until now.

Re: T-Ruby is Ruby with syntax for types

#55

Earlier quoted context omitted.

A bunch of companies started a decade or two ago and became very successful using the dynamic language du jour back then, and now they're facing issues with said dynamism, so they introduce types to fix those issues, see Meta with Hack over PHP and Stripe with Sorbet over Ruby. The point is not for new users, it's for existing users to improve their development environments.

Are they _solving_ these issues of dynamism with typing? What other issues does it introduce?

whole lotta companies moving from ruby monoliths to ts distributed systems

Re: T-Ruby is Ruby with syntax for types

#56
> Requires learning sig block's unique DSL syntax.

This is an interesting proposal. But for posterity I am going to critique the critique on the website about Sorbet:

Sorbet is Ruby and while it has a DSL that is no different than any other gem providing methods or objects to use. For example you can define a type and assign it to a Ruby constant. Because Sorbet is Ruby.

In general I would say any type system has its own syntax when you go deep into it and need more than this param has this simple primitive type and the method returns this simple primitive type. So you have to learn a DSL and the syntax of a type system.

Re: T-Ruby is Ruby with syntax for types

#57

I don't programme much any more but the whole beauty of Ruby that it pretty much heavily relies on #respond_to? / duck typing and thus you don't rely on types or class checking at all.

Structural typing like this is completely compatible with the concept of duck typing. Indeed, it's basically doing static checking of duck typing.

Re: T-Ruby is Ruby with syntax for types

#58

Honest question: I like typescript and I think it makes sense:, the web makes you married to JavaScript, so it’s the reasonable path forward if you want types in that context. But what is the point of the recent wave of types for python, Ruby, and similar languages? If it’s type safety you want there, there’s a bajillion other languages you can use right?

[deleted]

Re: T-Ruby is Ruby with syntax for types

#60

Wait, what happens if you want keyword arguments?

keyword arguments are, internally, syntactic sugar over a hash. It probably doesn't easily work with typing the explicit values of a raw hash

This hasn’t been true since Ruby 3.0. Keyword arguments are a core language feature with their own semantics.
Post reply on HN