Demystifying DSLs for better analysis and understanding, by Ufuk Kayserilioglu

Abstract

The ability to create DSLs is one of the biggest strengths of Ruby. They allow us to write easy to use interfaces and reduce the need for boilerplate code. On the flip side, DSLs encapsulate complex logic which makes it hard for developers to understand what's happening under the covers.

Surfacing DSLs as static artifacts makes working with them much easier. Generating RBI/RBS files that declare the methods which are dynamically created at runtime, allows static analyzers like Sorbet or Steep to work with DSLs. This also allows for better developers tooling and as some kind of "DSL linter".

For Review Committee

Details

The intended audience for this talk is Ruby developers who are novice or above.

The talk will follow the following general outline:

  • Introduction to DSLs
    • Introduce the general idea
    • Build a small DSL to solidify the concept
  • Examples of DSLs from different frameworks
    • Active Record
    • Simple Properties
    • Protocol Buffers
  • How to make DSLs accessible to static analysis
  • How to use the same information for better dev tooling
    • How do DSLs make it hard to understand code?
    • Sorbet LSP extension
    • Steep LSP extension
    • "Go to definition" for dynamic methods
    • Method comments give more context
  • How to use it for "DSL linting"
    • What can go wrong with DSLs
    • How can we catch them early?
    • Examples of errors we caught in various projects

The expected outcome from this talk is for the viewers to be better acquainted with writing, reading and understanding DSLs, and for them to be aware of the state of static analysis with respect to DSLs.

Pitch

The proposed speaker is the primary architect and lead author of the DSL RBI generation framework built inside of the Tapioca RBI generator and has a deep understanding of how many popular DSLs operate and how they can be analyzed to surface information for static analysis. The experience of working in this problem space for over a year now has given him a new perspective on the opportunities that are available to us for DSL analysis.

He is also an experienced speaker at various Ruby conferences, including a previous RubyKaigi talk.

Edit proposal

Submissions

RubyKaigi 2021 - Accepted [Edit]

RubyConf 2021 - Rejected [Edit]

Add submission