Ruby 3

Summarized using AI

An Introduction to Typed Ruby Programming

Soutaro Matsumoto • May 17, 2019 • Sofia, Bulgaria

The video titled 'An Introduction to Typed Ruby Programming' features Soutaro Matsumoto presenting at Balkan Ruby 2019. The talk focuses on the development of optional type checking in Ruby, particularly highlighting a type checker called Steep. Matsumoto starts with an interactive survey about the audience's familiarity with Ruby's type checker and the concept of duck typing, which emphasizes the flexibility of using types in Ruby programming.

Key points discussed in the presentation include:

  • Personal Introduction: Soutaro Matsumoto introduces himself and shares insights about Ruby meetups in Tokyo, which serve as a hub for Ruby developers.
  • Web Service Idea: He briefly describes a service he developed that analyzes code, using open-source linting tools to identify potential issues in code reviews.
  • Outline of Presentation: The talk is structured to cover the latest plans for Ruby 3, introduce the type checker Steep, and discuss the progress in type checking development.
  • Ruby 3 Developments: Emphasis is placed on the improvements in performance, concurrency, and static analysis, with a focus on how static analysis can aid in development.
  • Type Checkers: Various type checkers are being developed, including those by Professor Jeff Foster and Cayendo, highlighting the collaboration within the Ruby community.
  • Steep's Functionality: Matsumoto details the capabilities of Steep, which aims to detect type errors without executing Ruby code, enhancing code quality and navigability in IDEs.
  • Language for Type Signatures: A new signature language is being integrated into Ruby 3, allowing developers to define types for methods, instances, and constants.
  • Duck Typing and Flexibility: The importance of maintaining Ruby's dynamic programming flexibility while implementing static typing features is highlighted.
  • Current Development Status: Collaborations among different type checker projects are ongoing, with a shared goal of improving type checking for Ruby applications.

The presentation concludes with an invitation for audience engagement, encouraging questions and feedback on type checker implementations. Matsumoto expresses gratitude for the opportunity to present, emphasizing the collaborative nature of improving Ruby's type-checking ecosystem.

An Introduction to Typed Ruby Programming
Soutaro Matsumoto • May 17, 2019 • Sofia, Bulgaria

Balkan Ruby 2019

00:00:19.609 Okay, thank you. So, my joke is about type systems and type checkers.
00:00:24.840 Before starting my talk, I'd like to do a survey. I thought that you already know that Ruby will have an optional type checker. Do you know this?
00:00:31.500 Everyone knows, that's fine. Another question is about the big topic of the development of type checker for Ruby, which is about duck typing. Do you think that you write duck typing?
00:00:45.239 Okay, about recent developments, it's awesome. Let me introduce myself. I'm Soutaro Matsumoto. I live in Japan, and I'm from Tokyo.
00:01:03.210 This is my first time visiting European countries. So now, Europe is a wonderful place for me. I hope that you see this picture. This is a picture of a big gate from a famous temple in Tokyo. There is a famous meetup called the Ruby Meetup in Tokyo, which happens weekly every Tuesday.
00:01:29.490 It’s a really nice meetup because many notable Ruby developers, including Akira Matsuda and Yoshi Shibata, attend it. So when you come to Japan, if you have time, it would be really nice to visit the meetup.
00:01:58.290 I'm currently working as an outsider at a Tokyo-based startup, and I have also worked at two other startups as a technical advisor. I'd like to introduce you to an idea for a web service that helps you review your code. It provides various code analysis tools and some open-source linting tools, which run on pull requests to find problems and give suggestions.
00:02:36.860 We support the Black Hole, and many of our users love working with our tools. We had an interview with Vulture at last year’s RubyKaigi event. I also developed a type checker for Ruby, and it's available in my GitHub repository. You can see the project there.
00:03:05.180 As you know, this is the topic of my talk today. This is the outline of my talk: first, I will explain the latest plan for Ruby 3, and then I'd like to introduce my type checker called Steep. Finally, I will share the progress of the type checking development project.
00:03:46.160 This is a picture from the keynote from the RubyKaigi conference this year. It covers three significant improvements: performance, concurrency, and static analysis, and we are focusing on static analysis.
00:04:09.859 The team consists of Ruby core members such as Matt, Koichi Sasada, and Uske Endo, along with type checker developers from around the world. We have some participants from Sorbet, including Geometry and others working for Solargraph.
00:04:54.680 Currently, one of the most practical type checkers available for Ruby is being developed by Professor Jeff Foster, who is a researcher at a university. He develops another type checker for Ruby, and it is part of his research project. Additionally, Cayendo also has a type checker called Type Profiler, which is still experimental.
00:05:30.700 We have meetings regularly, almost every month, discussing the foundations of type checking for Ruby. We share progress on our developments and discuss challenges. The primary goal of this project is to develop a type checker that detects the type of each Ruby expression without executing the code.
00:06:46.080 The purpose of the type checker is to assist in the development of Ruby applications by finding bugs, such as normal errors or argument mismatch.
00:07:03.810 It will also help with code navigation features, like 'jump to definition' in your IDE, which requires type information. Moreover, the type checker will provide refactoring support, making it easier to rename constants, methods, or instance variables accurately.
00:07:37.320 However, performance improvements are not our primary goal. While performance may improve by skipping certain runtime checks due to precise analysis of Ruby code, achieving this is quite difficult.
00:08:23.000 The focus of our project is static analysis, not performance.
00:08:36.280 This image presented at the RubyKaigi explains key items like the signatures of libraries, application levels, type checking, and how they will impact our development.
00:09:19.030 Ruby 3 will introduce a language to define type signatures for Ruby programs, including standard libraries and protocols to share signatures for gems.
00:09:52.150 This is an example of the Ruby signature language that is still unnamed, but structurally resembles Ruby. We'll have class definitions, mixing declarations, and method signatures, though the syntax will differ from standard Ruby.
00:10:23.430 We will define types for methods, instances, globals, and constants within this language, which will support advanced features like generics, union types, and optionals.
00:10:39.540 Ruby 3 will ship with signature definitions for standard libraries, and we will require these definitions for any type checking to maximize effectiveness.
00:11:21.940 If a library doesn't have a signature, you will have to write it yourself, which can be exhausting.
00:11:33.740 Ruby 3 will come with built-in standard library signatures that include basic gems, and a protocol to share signature definitions will be established.
00:11:53.950 We've been discussing providing new syntax for Ruby code annotations. There will be no new syntax or standard type checker, and any proposed syntax will need to effectively assist the annotation without confusing developers.
00:12:19.000 While there was a hope for new syntax, we recognize that we require some type annotations, including comments for type explanations or using embedded DSL methods. We are looking for ways to achieve this without introducing additional runtime requirements.
00:13:14.100 There's a lot of discussion on implementing type checkers like Sorbet and Steep. The tools are independent, but they all contribute to evolving the Ruby type-checking ecosystem.
00:13:59.730 There's continuous improvement and discussion on type definitions. We aim to enhance type-checking processes, empower developers in Ruby applications, and help libraries by keeping runtime dependencies minimal.
00:14:45.270 I'd like to emphasize that Steep provides a language for defining signatures, and we're actively developing a type checker that quickly detects errors in Ruby applications.
00:15:04.230 This small example highlights how Steep will identify bugs by checking method calls. For instance, if an initializer expects keyword arguments, but receives positional arguments instead, Steep will detect mismatches promptly.
00:15:47.540 Furthermore, Steep checks the implementation accuracy of methods and can catch logical errors, such as using an array method incorrectly. This capability is crucial for maintaining code quality.
00:16:37.200 Duck typing is an essential concept in Ruby programming, requiring us to find robust ways to implement typing that enhances our code without compromising its flexibility.
00:17:05.730 The support for duck typing allows you to define interfaces more flexibly, ensuring type safety while utilizing Ruby's dynamic programming features effectively.
00:17:59.050 Steep is also designed to be agnostic to metaprogramming, meaning that it focuses primarily on static typing without being influenced by dynamic method definitions.
00:18:54.460 The approach allows developers to continue leveraging Ruby's metaprogramming practices while ensuring type errors are detected accurately.
00:19:34.610 There are ongoing discussions about defining a minimal set of runtime dependencies required for utilizing type annotations. We want to minimize additional dependencies that could complicate library use.
00:20:16.900 So, discussing the current status of the type checker development, we have four type checkers being built: Steep, Sorbet, RDL, and Type Profiler.
00:20:54.040 Each developer is independently working on their tools while sharing experiences and insights to push forward the Ruby type-system implementation.
00:21:30.390 We continue working on defining a signature language suitable for Ruby's features, improving type definitions and their implementation in the community.
00:21:59.680 Ideally, we aim for a standard approach to defining signatures not only to ensure code accuracy but also to enhance collaboration between Ruby-based libraries.
00:22:47.440 I encourage everyone to feel free to ask questions, provide feedback, or share experiences and suggestions concerning type checker tools and implementations.
00:23:30.310 Finally, thank you for your time and listen. Don't hesitate to contact me for any further discussion or demonstrations regarding Steep.
Explore all talks recorded at Balkan Ruby 2019
+4