RubyKaigi 2019: A speaker’s report

RubyKaigi remains one of the best Ruby events in the world—with insightful talks, fantastic organization, and tons of top-notch attendees. And if you still think that “Ruby is dead” then “you’re just not paying attention.”
Adding typing to Ruby and a keynote by Matz
This year the central topic for the whole conference was adding static type checking to the language. Is it necessary? How do we make it better? It seems that Ruby 3 will contain type annotations, but it is still hard to say which implementation will become the most popular. You can learn more from the following three RubyKaigi talks to compare different approaches:
- Yusuke Endoh from Cookpad is working on an automatic type profiler for analyzing non-annotated code: slideshare.net/mametter/a-typelevel-ruby-interpreter-for-testing-and-understanding
- Soutaro Matsumoto is working on Steep, which allows writing annotations in separate
.rbifiles. Here is his talk about challenges in adding typing to Ruby—duck typing, metaprogramming, and more: speakerdeck.com/soutaro/the-challenges-behind-ruby-type-checking - Engineers from Stripe are continuing to work on Sorbet, which allows adding signatures to method calls right in the Ruby code. This approach also allows to add runtime type checking when the code is running, as annotations itself are just method calls that replace declared method with wrapper performing type checks for arguments and return a value (much like Python decorators): sorbet.run/talks/RubyKaigi2019/
Also, Shopify, GitLab, and Coinbase are supporting and beta-testing Sorbet, so a lot of hype and momentum are guaranteed when Sorbet is finally available to the general public. Stripe wants to make Sorbet open source later this summer.
Sure, larger companies want to add type checking to the language not because they’re hoping to increase performance, but because they want to improve the maintainability of large code bases. Static checks reduce the number of errors in runtime (especially the notorious undefined method foo for nil:NilClass), enhance code completion in IDEs, and simplify onboarding of new engineers to the mature project.
Wonder what Matz himself thinks about that? Watch this video—it doesn’t differ much from the RubyKaigi opening keynote, at which Matz trolled everyone:
Ruby is bad
I hate tests
I hate type annotationsIt seems that Ruby itself is heading more towards the Steep and ruby-signature approach, but time will tell.
Love for mruby
There was also a lot of attention to mruby at the conference, not only in talks (“Practical mruby/c firmware development”, “Non-volatile mruby”, and a lightning talk about using mruby in satellites!), but also because of the mruby exhibit on the 4th floor of the congress center.
It seems that at least in Japan, mruby is not only actively used—but is quite widespread! Try to search Twitter for #rubykaigi mruby to see for yourself.
“Determining Ruby process counts” from Nate Berkopec
This was a talk with a lot of pretty uncomplicated math about how to estimate how many worker processes and servers you need to serve all incoming requests during low and peak times. One key thought in this talk was that you need to watch on how long requests waiting for a free worker to understand when you need to scale your application up or down.
Slides: Determining Ruby process counts.
“Cleaning up a huge ruby application” from Cookpad
Review of available tools that can help in searching for “dead code” (like oneshot_coverage and coverband), as well as a presentation of the (not yet released) cookpad_all gem that allows to track which iseq-instructions were executed on production and which weren’t to reliably tell which code is actually isn’t used. It is still Ruby with metaprogramming and all this stuff, remember?
Slides: Cleaning up a huge ruby application.
Two talks about writing API client gems
The “How to use OpenAPI3 for API developer” talk by @ota42y explains what OpenAPI (ex. Swagger) is. From it you can learn about two gems: the committee gem for validating OpenAPI requests and responses for your API, and the openapi_parser gem that can help in the development of your own client for OpenAPI-compatible API.
The “Best practices in web API client development” talk by Go Sueyoshi was about guidelines that everyone should follow when writing yet another client for some API. Namely:
- A client should convert params/response from/to Ruby types;
- A client should refresh access tokens and retry;
- A client should raise relevant exceptions on various API errors;
- A client should not cache (it is an application-specific responsibility);
- A client should not validate params because it’s hard to keep in sync with API (the validation should be done by API);
- Use keyword args wherever possible for simplicity of further extending;
- Use faraday (it can convert types in simple cases, e.g., when API returns only the
truestring). Also, it has several middlewares included: for instance, to log requests as curl copy and paste commands (which is great for reporting bugs to the original API maintainers).
Also, we’re thrilled that our own evil-client gem for creating API clients (the ebay_api gem, for example) encourages the developer to follow most of these guidelines—that means that we’re on the right track.
