Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
RubyConf 2019 - In the beginning, there was "require"... by Adam McCrea Almost every Ruby program begins with the "require" method, but many of us don't pause to think about what it's doing until it fails us. What happens when we call "require"? How does Ruby find what we're looking for? Is Bundler somehow involved? What about "requirerelative" and "requiredependency", and what the heck is a "binstub"? This talk will guide beginner and intermediate Rubyists through these foundational concepts that power our Ruby programs, from single-file script to a behemoth Rails 6 app. #confreaks #rubyconf2019
Date
Summarized using AI?
If this talk's summary was generated by AI, please check this box. A "Summarized using AI" badge will be displayed in the summary tab to indicate that the summary was generated using AI.
Show "Summarized using AI" badge on summary page
Summary
Markdown supported
In this RubyConf 2019 talk titled "In the beginning, there was 'require'..." Adam McCrea explores the fundamental concepts surrounding the 'require' method in Ruby, illustrating its critical role in managing dependencies within Ruby applications. McCrea shares his personal journey of discovery, highlighting his initial confusion over various 'require'-like methods, particularly 'require_dependency', which led him to present this talk aimed at beginner and intermediate Ruby developers. Key points discussed include: - **Understanding Dependencies**: McCrea categorizes dependencies into three types: standard library code, Ruby gems, and internal project code. Each of these requires different management techniques. - **The Role of 'require'**: He explains how 'require' serves as the foundational method for loading dependencies, pointing out its functionality, return value, and the mechanism behind the load path. - **Eager vs. Lazy Loading**: McCrea discusses the difference between eagerly-loaded and lazy-loaded dependencies, positioning 'require' as an eager loading method while providing a matrix to better understand these concepts. - **Requiring Gems and Local Files**: The speaker describes how requiring gems (e.g., 'MiniTest') involves gem activation, where RubyGems manages the load path. He also outlines the nuances of requiring local project files, emphasizing proper load paths. - **Alternatives**: Methods like 'require_relative' are introduced for managing file requirements without relying on the current working directory, eliminating potential pitfalls. - **The 'load' Method**: McCrea contrasts 'load' with 'require', explaining that 'load' requires the file extension and reloads files each time it's called. - **Bundler**: The significance of Bundler is highlighted, particularly its role in managing gem versions through the 'Gemfile' and 'Gemfile.lock', ensuring consistency across different environments. - **'require_dependency' in Rails**: He addresses how 'require_dependency' enforces eager loading of dependencies within Rails applications to prevent conflicts with auto-loading. In conclusion, McCrea encourages developers to understand the mechanics behind these methods to fill knowledge gaps that many may encounter, regardless of experience. He underscores the importance of managing dependencies efficiently to avoid common pitfalls and enhance coding practices in Ruby programming. McCrea invites attendees to reach out for discussions or questions, emphasizing continual learning in the Ruby community.
Suggest modifications
Cancel