news.volyx.in

RBS, Ruby’s new type signature language (developer.squareup.com)

511 points by mootrichard · 2257 days ago · 334 comments on HN

Article summary

The article introduces RBS, a new language for type signatures in Ruby 3, which allows developers to write type definitions for their Ruby code in separate .rbs files. This approach enables incremental addition of typing to existing codebases without modifying the underlying code. RBS provides a foundation for type checkers and tools to improve the development experience. The goal is to make type definitions portable between type checkers and encourage the community to write types for their gems and apps.

Main themes

  • Ruby 3 type signatures
  • RBS language
  • Type checking and tools
  • Static vs dynamic typing
  • Code analysis and IDE support
  • Language design and trade-offs
  • Crystal and alternative languages

What commenters say

  • The decision to use separate files for type signatures may lead to divergence between the type definitions and the actual code, potentially causing issues at runtime.
  • The approach of using separate files for type signatures is beneficial for large existing codebases, as it allows for incremental addition of typing without disrupting the workflow.
  • Some commenters argue that inline type annotations, like those in TypeScript, would be more effective in preventing type-related errors at runtime.
  • The use of separate files for type signatures may not be the best approach, as it may not provide the same level of protection against type-related errors as inline annotations or compiled languages.
  • The development of RBS and its integration with tools like Sorbet and Steep may improve the overall development experience for Ruby developers, particularly in terms of IDE support and code analysis.
  • Some commenters question the value of adding type signatures to Ruby, suggesting that other languages, like Crystal, may be more suitable for certain use cases.
  • The trade-offs between static and dynamic typing, as well as the potential benefits and drawbacks of adding type signatures to Ruby, are debated among commenters.
  • The relationship between RBS and existing type checkers like Sorbet is discussed, with some commenters noting that Sorbet's approach may be more effective or convenient for certain use cases.