Summarized using AI

Ruby Archaeology

Nick Schwaderer • November 08, 2021 • Denver, CO • Talk

The video titled "Ruby Archaeology" features Nick Schwaderer discussing the historical aspects of Ruby programming language during RubyConf 2021. The main theme revolves around revisiting old Ruby code to explore how the language and its ecosystem have evolved over the years. Schwaderer emphasizes the importance of understanding historical Ruby code, particularly from around 2008-2009, and provides practical insights on how to run such legacy code on modern systems.

Key points covered in the talk include:

- Introduction to Ruby Archaeology: Schwaderer defines Ruby Archaeology as the exploration of Ruby's past through its code and the significance of keeping an eye on older patterns and styles in programming.

- Setting Up the Environment: He explains the steps to create a 2008 Ruby environment on modern machines using Vagrant, detailing commands to set up an appropriate operating system and to install Ruby 1.8.7, addressing the challenges faced during this process.

- Exploration of Legacy Gems: Schwaderer shares insights about older Ruby gems such as Hpricot, an HTML parser, and Nokogiri, which was introduced later as a more efficient alternative. He highlights how to run and work with these gems, illustrating this with coding demonstrations.

- The Importance of Code History: By looking at the past, developers can learn different idioms and practices that, while perhaps out of favor now, shaped the Ruby language's evolution. He also discusses programming styles formerly used, such as method calling conventions and the use of certain structures.

- Building a Full Stack Application: Schwaderer demonstrates how to build a micro web application using Camping, a lightweight Ruby web framework from that era, discussing its components and functionality in a hands-on manner.

- Conclusions and Future Directions: He concludes by encouraging developers to explore the wealth of Ruby code available and to embrace the whimsical nature of programming that Ruby often embodies. He promotes an openness to different coding styles and the learning opportunities they present.

- Resources Provided: Schwaderer shares access to a Vagrant box containing Ruby 1.8.7 and an example application to facilitate further exploration of Ruby’s past.

In summary, the talk invites viewers to appreciate the historical depth of the Ruby programming language and inspires them to dive into legacy code as a means of understanding and enhancing their programming skills today.

Ruby Archaeology
Nick Schwaderer • November 08, 2021 • Denver, CO • Talk

IN 2009 _WHY TWEETED: "PROGRAMMING IS RATHER THANKLESS. YOU SEE YOUR WORKS BECOME REPLACED BY SUPERIOR WORKS IN A YEAR. UNABLE TO RUN AT ALL IN A FEW MORE."
I take this as a call to action to run old code. In this talk we dig, together, through historical Ruby. We will have fun excavating interesting gems from the past.

Further, I will answer the following questions:

What code greater than 12 years old still runs in Ruby 3.0?
What idioms have changed?
And for the brave: how can you set up an environment to run Ruby 1.8 code from ~2008 on a modern machine?

RubyConf 2021

00:00:10 Hi everybody, my name is Nick Schwaderer. Today I'll be talking to you about Ruby archaeology. I am a production engineer at Shopify. You've probably heard of them, especially at this conference. I can say there's never been a better time to work at Shopify, and I'm a huge fan of the work they do.
00:00:18 Seeing the work that their engineers have done over the years at RubyConf attracted me there. Please feel free to slide into my DMs or just tap me on the shoulder with any questions you have; I'm happy to talk about that. However, I'm not talking about Shopify today. I'm discussing a little project that I'm interested in, and it's kind of fun.
00:00:32 When you find yourself doing a deep dive at one in the morning on a subject, you might consider throwing it out as a CFP (Call for Papers). If someone accepts it for a talk, you can dedicate even more hours looking into this strange subject that probably no one would pay you to explore. Well, maybe.
00:01:02 The first thing I'd like to say is thank you to the organizers, staff, and everyone who put this whole conference together. These last couple of days felt like a big chunk of healing over the past few years, especially since many of us have been primarily at home working on our computers and not socializing. Honestly, I think a few people felt a bit overwhelmed, and it’s one of the hardest times to make a conference happen. I really appreciate that, and thank you to all of you for taking 30 minutes out of your day to listen to what I have to say.
00:01:29 You might be asking yourself, what is Ruby archaeology? Well, it’s a term that I came up with for this talk, covering applied exploration of Ruby history through code and events from the past. I'll share some snippets about what I’ve been interested in that relate to this.
00:01:36 The first is that I occasionally put out the Past Ruby's newsletter, so you can go to pastries.live if you want to subscribe—just a little plug there. This newsletter does a kind of link list, not dissimilar from a simpler version of Ruby Weekly, but focused on this week in Ruby history. It includes releases, cool talks from all the way back to 2003, blog posts, articles, and much more. I love doing this so much that I have my own private code to assist with this research, which allows me to input a date and receive articles and posts from this week in history.
00:01:54 This code parses all sorts of resources and runs a single command, opening 500 tabs filled with links for the newsletter. I’ve also written Portalgun, a Ruby gem that lets you create a Gemfile by inferring one or supplying it yourself. If you're in a situation where, say, a Gemfile.lock is corrupted, or you’re exploring old code and know when it worked, say, March 5th, 2011, running the Portalgun executable provides a full Gemfile pointing to stable versions of every gem from that date in history.
00:02:24 Many of my experiences with Ruby and my reading in the past have been heavily influenced by Why the Lucky Stiff. Why was, and I think still is, the epitome of whimsy in programming. I believe whimsy is core to Ruby, emphasizing care in building, art, and sharing what you create. He represented a time when you could give major conference talks without revealing your real name, job, or location.
00:02:52 It's surreal for me to think that I’m in a room, at the same conference, with people who have interacted with Why, whether physically or online. Although we never overlapped—I wrote my first line of Ruby in 2014—his impact on me remains. Why wrote a tweet a few weeks before he disappeared in 2009, declaring: "Programming is rather thankless. You see your works become replaced by superior works in a year, unable to run at all in a few more." This thought has haunted me for years, and segues into my interest for this talk.
00:03:21 I propose that we run some old code! The first challenge in tackling this issue, at least for me, was setting up a 2009 coding environment on a 2021 machine. I lost several days attempting this. You can't simply use RVM to switch to Ruby 1.8; that's not the best path forward.
00:03:28 Ruby 1.8 and 1.9 are long past; in fact, Ruby 1.8 reached its end of life seven years ago, and it hasn't been the latest release for over 14 years. So, while this isn't ideal, I believe looking back at our past is crucial. We now have a mature language with a feature-rich, robust ecosystem that is well-supported globally.
00:03:50 There was a time when you couldn’t even get paid to do Ruby. To advance the language, we must keep an eye on old code, patterns, styles, and debates. A recurring motif I’ll highlight in this talk is that as we work with Ruby to earn our living, we often narrow down our focus to one way to use this versatile tool.
00:04:02 So, let’s get started! How did I tackle this, and spoiler alert, there are multiple ways to approach this problem. This may not be the only right way, but it's the method I managed to use successfully.
00:04:19 The first step I took was to set up a Vagrant box with an operating system relevant to 2008. Again, I'm primarily focused on the year 2008 and bleeding into 2009 for parts of this. If you’re unfamiliar with Vagrant, it's a tool that allows you to set up a virtual machine on your machine. Just run the command: 'brew install vagrant,' create a Vagrantfile, and with a bit of setup, you’ll be good to go.
00:04:40 With the operating system in place, we aren't fully back to the past yet, as modern packages will still interfere if you're trying to install them. If you're trying to apt-get packages, you’ll be pointing to 2021, which will lead to all sorts of headaches. So, I adjusted the sources.list to point to old releases instead.
00:05:01 There’s a website that maintains old releases. You just need to configure your operating system to retrieve them by replacing the 'us.archive' and 'security' sources with those for old releases. You don’t have to get fancy with sed arguments; you can simply use vim or nano to edit the file. And a key aspect to remember: while adopting an old setup, act as if you’re truly in 2008.
00:05:24 To get our environment set both for development and social media, you should modify your search engine flags to filter results by the date. This could be incredibly useful for limiting what you see to only what's available before a certain date.
00:05:52 Once we’re are able to retrieve packages from 2008, we need to install Ruby. Surprisingly, I was able to run 'apt-get install ruby-dev' and instantly obtain Ruby 1.8.7. This is perfect since I now have the version of Ruby I want to solidify my sandbox for sharing with you today.
00:06:06 I was also able to install RubyGems, which had been around for about four years back then. However, challenges arise if you're using Git to clone from modern infrastructure; it will often complicate things due to discrepancies in communication.
00:06:30 For situations where your tools are limited, I found that I could download the gem directly from RubyGems, meaning I just needed to run the gem install command locally. This way, I could operate without hitting roadblocks because of modern protocols.
00:06:46 Now that everything is in place, I’ll demonstrate a couple of gems I fetched and run them to show you real-life examples from 2008. The first is 'hpricot'—raise your hand if you've heard of it! I’m thrilled to see so many hands! Hpricot was once the industry standard for HTML parsing until the emergence of alternatives.
00:07:08 I'm not going to conduct a live coding demo; I pre-recorded a session at a slower speed so I can easily showcase the process. Looking at hpricot in my box and terminal, you’ll see that its API is designed for reader-friendliness, requiring no complex instantiation—just pass your HTML file into its function.
00:07:38 While exploring, you'll find the beauty of this approach is its clarity; you iterate over rows and cells without extra syntax that might confuse the fundamentals of how Ruby uses arrays. For example, when searching for specific cell values, it feels clean and intuitive.
00:08:00 Yet, I faced challenges running it in Ruby 1.8.7 due to array incompatibilities, even while grappling with excitement of seeing this gem at work. I thoroughly enjoyed this part of the exploration.
00:08:27 Next up is Nokogiri, the other gem I will highlight. Most of you are probably familiar with it, developed by Aaron Patterson in 2008 as a drop-in replacement for hpricot. It's marketed as being faster, less buggy, and more efficient, and I believe that it lives up to that.
00:08:56 I also want to thank Mike D'Alessio who has been the core maintainer of Nokogiri for a decade or more. Nokogiri offers an intuitive DSL, making it an industry standard for HTML parsing since its inception.
00:09:17 Nokogiri retains many traits from its predecessor, allowing for straightforward installation and workability without needing extensive setup or learning curves. While running examples, adopting a clean pattern allows for efficient parsing using familiar methods.
00:09:48 Introducing 2008-code dependencies raises reflections on how Ruby has evolved, where constructing web applications emphasized simplicity and accessibility. I briefly remark on an example of creating a simple web app using Ruby's Camping, a micro-framework that embodies the design philosophy of keeping it light.
00:10:14 Camping lets you write entire applications in a single Ruby file, encouraging minimalist enhancement of traditional MVC frameworks. The architecture inspired micro-frameworks like Sinatra and Flask, promoting quick and easy setups for web applications.
00:10:40 Specific Vagrant settings need to be enabled to allow for web traffic and access configuration. The simple act of uncommenting lines in your Vagrantfile gives your private network the access it needs to receive HTML requests.
00:11:10 After ensuring that everything is synchronized through the Vagrant setup, I was able to create a Camping application from an old Ruby file. Migrations and models are set up as you wish, keeping the designs straightforward.
00:11:30 While building a small application for the talk, I was impressed by how writing HTML in Ruby can look almost like Haml, reflecting clarity and efficiency in writing similar markup. This adaptability demonstrated how versatile Ruby was in web development.
00:11:54 The beauty of the Camping framework and the coding style at the time allowed clean integration of various scripts, showcasing why this past Ruby craft is worth exploring. Often, finding older code can reveal gems of wisdom laid bare in the past.
00:12:15 As I delve deeper into the codebase, I noted unique practices that contrast today's standards. For instance, the utilization of 'self' inside modules reflects a more flexible design approach back then, allowing for creative expression in code structures.
00:12:35 The nuances of method calls and how the ecosystem has evolved illustrate the richness of Ruby's evolution. From using variations of method calling through symbol syntax to adapting multi-line definitions, the discussions surrounding code methods signify a difference reflective of evolving programming paradigms.
00:12:58 As we transition into the present, many of us have become accustomed to newer forms of syntax and structure, but revisiting older frameworks and practices can often yield enlightening perspectives. This voyage through Ruby's past serves as both a reminder and a revelation of optimal paths for modern coding.
00:13:25 The consistent exploration of idioms and styles allows us to reflect on how efficiency and readability remain timeless concepts in programming. Throughout this exploration, I've rekindled appreciation for the decisions that were made from years ago and how they have shaped modern practices.
00:13:46 As I prepare to conclude this talk, remember the bones of Ruby history—thousands if not millions of lines of valid, open-source code are available, which you can access today. Our Ruby community is filled with diverse code expressions we don't always recognize.
00:14:10 This moment invites us to leverage what's available and remind ourselves that beneath and beyond standards, there's much indicative of innovation and exploration waiting to be uncovered. Becoming a Ruby archaeologist opens new avenues for understanding programming today in light of the past.
00:14:35 Before wrapping up, I want to announce the release of my Vagrant box, 'Schwadz Ruby Archaeologist.' The current version is 0.3.0, and by running 'vagrant init schwad ruby archaeologist' and 'vagrant up', you can explore what's inside.
00:14:50 This box enables Ruby 1.8.7 along with an example Camping application and all the dependencies needed for you to experiment with. I invite you to explore the past of Ruby, and share with me your discoveries.
00:15:13 Let’s continue championing Ruby culture with whimsy and fun while learning from our past. I appreciate your time; it’s been a pleasure being here at RubyConf and connecting with you all.
00:15:36 Please feel free to connect with me online, and know that it’s been an honor to speak at this incredible conference. Thank you so much!
Explore all talks recorded at RubyConf 2021
+95