ChillerDragon / teeworlds_network

A teeworlds 0.7 network protocol library written in ruby
5 stars 0 forks source link

Add type annotations with sorbet #18

Open ChillerDragon opened 10 months ago

ChillerDragon commented 10 months ago

https://sorbet.org/docs/overview

ChillerDragon commented 9 months ago

There is also steep https://github.com/soutaro/steep

ChillerDragon commented 9 months ago

Okay it seems there is something brand new that is official. That is rbs. Some dude on stackoverflow said that ruby standard lib tries to move to that. It is not a type checker. It is additional files in your code base describing the types. And we can then use steep as type checker on those rbs types.

ChillerDragon commented 9 months ago

About the author: Soutaro is a lead Ruby engineer at Square working on Steep, RBS, and static typing. He is a core Ruby committer working with Matz and other core committers on the RBS specification that will ship with Ruby 3.

https://developer.squareup.com/blog/the-state-of-ruby-3-typing/

ChillerDragon commented 9 months ago

Okay sorbet seems to use rbi for type annotations which is their thing and its not compatible. Why official ruby in 2020 started supporting rbs type annotations and their official checker for that is steep. So lets go with that!

ChillerDragon commented 9 months ago

Having types not in the code feels weird. But at least they do not pollute runtime. Sorbet has its types in the code directly. But it also does type checking at runtime which sounds like a performance hit to me.

ChillerDragon commented 9 months ago

rbs can and should be generated using https://github.com/ruby/typeprof