Comment by dudeinjapan

1 month ago

Two reasons.

First, YJIT/ZJIT do much better when they know the type signatures of methods. You pay a performance penalty for implicit polymorphism, e.g. using a mix of types (Integer, Symbol, String) etc in the same method argument.

Second, from my experience with Typescript, as much as I naturally dislike type declarations, I find it does help LLMs. Having strongly typed libs/gems and being able to mix in untyped app code would be a nice balance.

> First, YJIT/ZJIT do much better when they know the type signatures of methods.

The running interpreter knows the type of objects. Ruby isn't untyped.

The annotations do nothing for the interpreter.

  • I meant to say: strict “ahead-of-time” static typing would help a theoretical successor to Y/ZJIT—not the current JITs in their as-is form.