Loading…
Topic
Static Typing
8 posts about Static Typing. Every summary links to the original.
- 8 posts
- 4 companies
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
Newest first
Posts
Why Go is an Ideal Language for AI-Assisted Software Engineering
AI-assisted software development shifts the human bottleneck from writing code to reviewing, verifying, and maintaining generated code, while people still define architecture, service boundaries, safety, and reliability. The post presents Go as a language designed for software engineering and argues that its end-to-end platform—built-in formatting, testing, dependency management, security tooling, and a comprehensive standard library—gives teams and AI agents a consistent foundation. Go’s readability, explicitness, standardized syntax through gofmt, static typing, and single-binary portability are described as guardrails that make generated code easier to inspect, validate, and operate. It also identifies gopls, the rebuilt go fix with modernizers, profiling, execution tracing, and profile-guided optimization as tools for maintaining and tuning systems over time. The conclusion is that Go’s consistency and production-oriented tooling can help humans absorb high-volume AI output without sacrificing reliability, maintainability, or system integrity.
NilAway: Practical Nil Panic Detection for Go
NilAway is Uber’s static analyzer for detecting potential nil pointer dereferences in Go before they reach production, where nil panics have caused incorrect behavior, outages, and denial-of-service risks. It models nilability flows as global typing constraints over struct fields, function parameters, and return values, builds an implication graph, and uses 2-SAT-style reasoning with forward nilness and backward nonnil propagation to identify contradictions. The analysis is interprocedural, requires no developer annotations, and reports detailed flows, while acknowledging false positives when runtime invariants are not captured. In one Uber service logging more than 3,000 nil panics daily, NilAway identified a receive-from-closed-channel path; adding a nilness check reduced the reported panics to zero, and the tool was released as open source with comprehensive and changed-code onboarding options.
The State of Ruby Static Typing at Shopify
Shopify’s Ruby monolith receives about 400 commits and 40 deployments daily, spanning 37,000 files, 622,000 methods, and over 2,000,000 calls, making correctness difficult despite rigorous review and 150,000 automated tests. Since 2018, Shopify’s Ruby Infrastructure team has pursued static typing and adopted Sorbet, discussed in a 2020 Shipit! event. The post describes Sorbet’s handling of simple collections such as T::Array[Integer], nested types using T.untyped, and dedicated classes for complex structures, while noting obstacles involving ActiveSupport::Concern, implicit inclusion requirements, metaprogramming, and dynamic GraphQL resolvers. For Rails projects, guidance is to begin with typed: false, generate RBI files using Tapioca or sorbet-rails, then move suitable files toward typed: true based on reuse, errors, collaboration, or churn, checking generated files into the repository.
Static Typing for Ruby
Shopify’s Ruby monolith spans 37,000 files, 622,000 methods, and more than 2,000,000 calls, making fast feedback and stability difficult despite rigorous reviews and 150,000 automated tests. Sorbet was selected after the team evaluated requirements for gradual typing, speed, and support for Ruby and Rails features including metaprogramming, overloading, and class reopening. Its RBI files represent constructs it cannot infer, while per-file sigils allow adoption to progress without blocking development, and SorbetMetrics tracks sigils, typed calls, and method signatures. Shopify treats typing as a product, combining CI enforcement, developer support, surveys, and interviews to guide rollout and measure sentiment. The excerpt reports 80% of monolith files, including tests, at typed: true or higher, with almost half of calls and methods covered and type checking under 15 seconds on developer machines.
Adopting Sorbet at Scale
Shopify describes its adoption of Sorbet static typing across a Ruby monolith containing 37,000 files, 622,000 methods, and more than 2,000,000 calls. At the time of writing, Sorbet ran on every pull request, 80% of files were typed: true or higher, almost half of calls were typed, and half of methods had signatures. To handle Ruby and Rails idioms, the team built RuboCop Sorbet for compatibility rules, Tapioca for gem and DSL RBI generation, and Spoom for programmatic tooling, metrics, and LSP access. A controlled experiment found fewer production NoMethodErrors in files typed: true after typing about 20% of the application, although the results were preliminary and signatures had not yet been added. Shopify planned to reach typed: true across all files, improve Rails support, and continue collaboration around Sorbet and RBS.
Migrating Large TypeScript Codebases To Project References
Shopify’s merchant admin UI grew from a Ruby on Rails ERB-based front-end into a TypeScript, React, and GraphQL codebase, and its size eventually made VSCode’s TypeScript language tooling take roughly two to three minutes to initialize. The team investigated the bottleneck with TypeScript’s performance diagnostics, VSCode TSServer logs, and support from the TypeScript team, which recommended splitting the monolithic configuration with project references. They built the TypeTrack VSCode plugin to measure initialization time, then migrated dependency-graph leaf nodes such as packages and tests, creating project-level tsconfig.json files and references incrementally. The migration reduced initialization times for sampled files from about 155 seconds to 8–13 seconds. The post explains how to resolve missing module errors, respect project-reference restrictions, and continue upward through the dependency graph while distributing migration work across teams.
Writing Better, Type-safe Code with Sorbet
Ruby repositories can hide unsafe method calls and ambiguous data shapes when types are inferred from variable names alone. Sorbet static type checking addresses these risks with method signatures, typed structs, enums, and interfaces. It can flag a potentially nil return before a chained call, distinguish database output fields from input fields, and enforce contracts for synchronous and asynchronous indexers in a dependency-injected hexagonal structure. The article also describes Sorbet’s gradual typing, including five strictness levels and namespace-by-namespace adoption using the minimum typed level of true. The stated conclusion is that enforced type safety catches errors unit tests may miss and helps prevent unsafe code from reaching production.
Static Typing in Ruby with a Side of Sorbet
An experiment introduced Sorbet into a greenfield Ruby codebase with four developers to test whether static typing could catch bugs earlier, ease refactoring, and improve code design. Sorbet combines static linting with runtime checks that verify method parameters and return values against signatures, while RBI files describe methods from gems and Rails models. Setup required sorbet init, running sorbet tc, and adding that command to CI; however, Rails metaprogramming required model signatures, and sorbet-rails could miss or mistype fields. Sorbet immediately exposed issues including repeated method calls, unintended nullable database columns, and unnecessary explicit returns or guard clauses. The team reports a very positive short-term experience, while noting that the project’s young age caused most of the bugs encountered and that long-term value remains uncertain.
Related topics
All topics →Weekly digest
The best engineering reads, once a week.