Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
We can write Ruby code in any number of styles, but the community has some accepted norms. For example, almost nobody uses `for` loops any more. We've decided that some styles are "better" than others. And we can keep finding "better" styles. In this talk, we'll dig into a more functional "lazy" style. Instead of setting up variables ahead of time, we'll call methods as needed. Instead of thinking about how to compute things, we'll think about properties of objects. This style has improved the readability of my code, and it will help you too.
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 presentation titled "Laziness is a Virtue: Lazy, Functional, Immutable Ruby," Craig Buchek explores the integration of lazy and functional programming principles in Ruby. He argues for a shift away from traditional procedural coding practices to a style that prioritizes laziness—deferring computation until it is absolutely necessary. This approach not only enhances code readability but also aligns with the principles of functional programming. Key points discussed in the talk include: - **Definition of Laziness**: Laziness in programming is defined as delaying computation until the results are needed. Buchek criticizes the common practice of pre-computing values, suggesting that it often stems from a procedural mindset. - **Readability and Maintenance**: Emphasizing that better coding styles emphasize maintainability and comprehensibility, he argues for naming conventions and short methods to enhance code clarity. - **Memoization**: The concept of memoization is introduced as a technique to cache results of computations to avoid unnecessary recalculations, stressing its importance in improving performance. - **Data Classes**: Buchek discusses Ruby 3.0's introduction of data classes and their immutability. This promotes a functional approach to programming where objects do not change state over time, thus simplifying reasoning about code behavior. - **Active Record and Laziness**: He highlights how ActiveRecord in Rails employs laziness through ActiveRelations, emphasizing that queries are constructed but not executed until required. - **Functional Programming Practices**: Key concepts from functional programming are elaborated, including purity of functions and the avoidance of side effects. Buchek references the "Functional Core, Imperative Shell" concept by Gary Bernhardt, advocating for composing predominantly functional code with limited imperative interactions. He concludes by underlining the importance of making changes easy, prioritizing effective outcomes over mere productivity, and adopting principles in development that focus on quality over quantity. The talk advocates for embracing a lazy mindset in programming that ultimately leads to better development practices.
Suggest modifications
Cancel