Get an improved navigation experience with a Chrominium based browser.
Dismiss
Ruby Video
Talks
Speakers
Events
Leaderboard
Sign in
Talks
Speakers
Events
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
Zeitwerk is the Ruby gem responsible for autoloading code in modern Rails applications. Rails Core member Xavier Noria walks you through how Zeitwerk works, from a conceptual overview down to implementation details and interface design. This talk is geared towards both seasoned Ruby developers looking to have a deep undertanding of Zeitwerk, as well as Rails beginners curious to know how this aspect of Rails works. Slides available at: https://www.slideshare.net/fxn/zeitwerk-internals Other links: https://rubyonrails.org/ https://rubyonrails.org/community https://github.com/rails https://hashref.com/ https://github.com/fxn/zeitwerk #RailsWorld #RubyonRails #rails #Rails7 #opensource #oss #community #RailsCore #Zeitwerk #rubygem
Date
Summary
Markdown supported
The video titled 'Zeitwerk Internals' presented by Xavier Noria at Rails World 2023 delves into the workings of Zeitwerk, a Ruby gem that manages autoloading, reloading, and eager loading in modern Rails applications. Xavier emphasizes the design goal of transparency; Zeitwerk operates behind the scenes without being visible in the user’s code. The talk is structured in two main sections: an overview of key Ruby concepts related to constants and an in-depth look at Zeitwerk's implementation. Key points discussed include: - **Definition and Purpose**: Zeitwerk serves as a code loader, technically functioning as a constant loader. It is designed to enhance development without being intrusive. - **Constants in Ruby**: Zeitwerk relies heavily on the concept of constants, as Ruby uses class and module keywords to create constants that hold class and module objects. - **Loading Mechanism**: The talk explains that constants belong to class and module objects, illustrating how Ruby's namespace emulation impacts how constants are accessed and stored. - **Autoloading Feature**: Zeitwerk utilizes Ruby's built-in `autoload` method, allowing classes and modules to be loaded on demand, facilitating a cleaner codebase by reducing the need for explicit requires. - **Implementation Details**: Zeitwerk operates by scanning specified directories and defining autoloads for files it encounters, organizing them into a registry that tracks which autoloads correspond to which paths. This mechanism supports efficient resource management by loading constants only when they're referenced. - **Customizability**: Although reloading is off by default in Zeitwerk, developers can enable it explicitly, granting further control over resource management in development environments. - **Eager Loading**: Zeitwerk also supports eager loading through an efficient traversal system that ensures necessary dependencies are preloaded without excessive calls. The overall conclusion of Xavier's presentation is that understanding the internal mechanisms of Zeitwerk can significantly enhance a developer's experience by better utilizing the autoloading system of Ruby in Rails applications, leading to improved efficiency and cleaner code organization.
Suggest modifications
Cancel