A Ruby YAML parser
Recently I built the psych-pure gem, a pure-Ruby implementation of a YAML 1.2 parser and emitter. It fully conforms to the YAML 1.2 specification, passes the entire YAML test suite, and allows you to preserve comments when loading and dumping YAML documents. This post explains how and why.
Prism: Ruby 3.3's new error-tolerant parser
Prism is a new library shipping as a default gem in Ruby 3.3.0 that provides access to the Prism parser, a new parser for the Ruby programming language. Prism is designed to be error tolerant, portable, maintainable, fast, and efficient.
Advent of Prism: Part 24 - Error tolerance
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about error tolerance.
Advent of Prism: Part 23 - Pattern matching (part 2)
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about pattern matching.
Advent of Prism: Part 22 - Pattern matching (part 1)
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about pattern matching.
Advent of Prism: Part 21 - Throws and jumps
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about throws and jumps.
Advent of Prism: Part 20 - Alias and undef
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about the alias and undef keywords.
Advent of Prism: Part 19 - Blocks
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about blocks and lambdas.
Advent of Prism: Part 18 - Parameters
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about parameters.
Advent of Prism: Part 17 - Scopes
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about nodes that introduce a new scope.
Advent of Prism: Part 16 - Control-flow calls
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about control-flow calls.
Advent of Prism: Part 15 - Call arguments
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about call arguments.
Advent of Prism: Part 14 - Calls (part 2)
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about call nodes.
Advent of Prism: Part 13 - Calls (part 1)
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about call nodes.
Advent of Prism: Part 12 - Program structure
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about program structure.
Advent of Prism: Part 11 - Defined
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about the defined? keyword.
Advent of Prism: Part 10 - Regular expressions
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about regular expressions.
Advent of Prism: Part 9 - Strings
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about strings.
Advent of Prism: Part 8 - Target writes
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about target writes.
Advent of Prism: Part 7 - Control-flow
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about control-flow.
Advent of Prism: Part 6 - Control-flow writes
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about control-flow writes.
Advent of Prism: Part 5 - Operator writes
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about operator writes.
Advent of Prism: Part 4 - Writes
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about writes.
Advent of Prism: Part 3 - Reads
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is about reads.
Advent of Prism: Part 2 - Data structures
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is data structures.
Advent of Prism: Part 1 - Literals
This blog series is about how the prism Ruby parser works. If you’re new to the series, I recommend starting from the beginning. This post is literals, and their variations.
Advent of Prism: Part 0 - Introduction
Two and a half years ago, I began working on what is today known as the prism Ruby parser. This is a new Ruby parser that is now being integrated into runtimes and tooling alike. This includes CRuby, JRuby, TruffleRuby, Natalie, Syntax Tree, RuboCop, and many others.
ActiveRecord::UnionRelation
I wrote a gem back in 2020 called active_record-union_relation, and I’m finally writing a blog post describing it. This is a very small gem that provides the ability to define Active Record relations from UNION queries. The resulting records that are returned when the queries are executed are polymorphic (i.e. they can be instances of different classes). I’ll show how this works and why you might want to use it.
Ruby operators
Ruby’s grammar has a ton of operators. Overtimes, they can mean more than one thing, depending on their context. This blog post enumerates each operator and its meaning.
Rewriting the Ruby parser
At Shopify, we have spent the last year writing a new Ruby parser, which we’ve called YARP (Yet Another Ruby Parser). As of the date of this post, YARP can parse a semantically equivalent syntax tree to Ruby 3.3 on every Ruby file in Shopify’s main codebase, GitHub’s main codebase, CRuby, and the 100 most popular gems downloaded from rubygems.org. We recently got approval to merge this work into CRuby, and are very excited to share our work with the community. This post will take you through the motivations behind this work, the way it was developed, and the path forward.
2023 Resolutions
In the back of my head, I’ve always had a bunch of open-source projects that I wanted to build if I had the time. This has led to me sporadically working on a wide variety of projects without any real clear direction. This coming year I have decided to try to focus on specific goals in the hopes that it will help me stay more on track and actually complete a project for once. In an effort to be more transparent and maybe incentive others to help me reach them, I’m sharing them here. Without further ado, here are my 2023 open-source resolutions, in their order of priority.
Advent of YARV: Part 24 - Wrap up
This blog series is about how the CRuby virtual machine works. If you’re new to the series, I recommend starting from the beginning. This is the last post in the series.
Advent of YARV: Part 23 - Primitive
This blog series is about how the CRuby virtual machine works. If you’re new to the series, I recommend starting from the beginning. This post is about the Primitive module and the invokebuiltin instruction.
Advent of YARV: Part 22 - Pattern matching
This blog series is about how the CRuby virtual machine works. If you’re new to the series, I recommend starting from the beginning. This post is about pattern matching.
Advent of YARV: Part 21 - Once
This blog series is about how the CRuby virtual machine works. If you’re new to the series, I recommend starting from the beginning. This post is about the once instruction.
Advent of YARV: Part 20 - Catch tables
This blog series is about how the CRuby virtual machine works. If you’re new to the series, I recommend starting from the beginning. This post is about catch tables.
Advent of YARV: Part 19 - Defined
This blog series is about how the CRuby virtual machine works. If you’re new to the series, I recommend starting from the beginning. This post is about the defined? keyword.
Advent of YARV: Part 18 - Super methods
This blog series is about how the CRuby virtual machine works. If you’re new to the series, I recommend starting from the beginning. This post is about super methods.
Advent of YARV: Part 17 - Method parameters
This blog series is about how the CRuby virtual machine works. If you’re new to the series, I recommend starting from the beginning. This post is about method parameters.
Advent of YARV: Part 16 - Defining methods
This blog series is about how the CRuby virtual machine works. If you’re new to the series, I recommend starting from the beginning. This post is about defining methods.
Advent of YARV: Part 15 - Defining classes and modules
This blog series is about how the CRuby virtual machine works. If you’re new to the series, I recommend starting from the beginning. This post is about defining classes and modules.
Advent of YARV: Part 14 - Branching
This blog series is about how the CRuby virtual machine works. If you’re new to the series, I recommend starting from