In this lightning talk from Helvetic Ruby 2023, Josua Schmid introduces the concept of "conventionally-typed Ruby," exploring a new perspective on typing in Ruby programming. The discussion highlights the distinctions between statically typed and dynamically typed languages, while proposing that the emphasis should not solely be on type systems but rather on human understanding and interaction in coding.
Key Points Discussed:
- Dynamic Typing in Ruby:
- Ruby is inherently a dynamically typed language, meaning that type errors are caught at runtime rather than at compile time. For example, adding a float to a string will raise an error when the code runs.
- Recent Changes with Ruby 3:
- With the introduction of RBS files in Ruby 3, developers can now declare types externally, allowing for pre-runtime type checks and compile-time errors through tools like Steep or Sorbet. However, Josua expresses a preference against heavy configuration, indicating that this complexity can detract from the focus on solving business problems as a Rails developer.
- Critique of Type Annotations:
- Josua argues against the necessity of type annotations in Ruby, emphasizing that the language's design prioritizes simplicity and developer autonomy.
- Proposal for Conventional Typing:
- He proposes the idea of conventional typing, where understanding of types would derive from the context within the code rather than explicit annotations. This could be seen as a guessing game where developers infer types based on naming conventions and runtime observations.
- Avenues for Exploration:
- Several methods for implementing this conventional type system are discussed, such as:
- Analyzing variable names at runtime to develop a better understanding of data types used.
- Using existing tools like Rubocop or language models to develop a dictionary of type conventions.
- Future considerations include how to integrate nullable types effectively.
- There's potential for extending current typing tools like Sorbet or Steep to infer types from naming alone, instead of relying on explicit annotations.
Conclusions:
- Josua notes that while there are many questions that remain unanswered regarding conventional typing, this approach seeks to bridge the gap between human understanding and technical constraints within Ruby.
- He invites feedback on his ideas and references a blog article he wrote four years ago on this topic, encouraging further discussion among attendees.
In summary, the talk encourages exploring the human element of programming and suggests that embracing conventions in Ruby's dynamic typing can lead to more intuitive code practices, fostering a stronger connection between developers and their code.