Michael Hartl

Summarized using AI

Ten Years of Rails Tutorials

Michael Hartl • May 17, 2018 • Pittsburgh, PA

In this presentation titled "Ten Years of Rails Tutorials," Michael Hartl reflects on the evolution of Ruby on Rails and its introductory tutorials over the past decade. He shares his personal journey into web development, starting with his experience in graduate school and early encounters with various programming languages like PHP and Python.

Throughout the talk, Hartl discusses:
- The primitive state of web development in the early 2000s and the emergence of Rails as a transformative framework.
- Key milestones in Rails' development, highlighting features that were ahead of their time, such as project generation and the Model View Controller architecture.
- The evolution of testing methods within Rails tutorials, showcasing how testing has matured from simple assertions to integrated testing suites.
- Significant shifts in the framework, including the introduction of RESTful routing and the asset pipeline, illustrating how Rails has consistently led industry standards.
- The impact of Rails on tools and practices, such as simplifying deployment processes with services like Heroku and the rise of Git as a version control system.
- Hartl concludes with optimism about the future of Rails, emphasizing its adaptability and ongoing relevance in modern web development contexts. He envisions an exciting future for Rails tutorials continuing for at least another decade, integrating new technologies and practices like React and Webpack.

Through the lens of his tutorials, Hartl sheds light on the innovative spirit of Rails and its role in shaping contemporary web development.

Ten Years of Rails Tutorials
Michael Hartl • May 17, 2018 • Pittsburgh, PA

RailsConf 2018: Ten Years of Rails Tutorials by Michael Hartl

Come see how Rails has evolved over the years through the lens of introductory Rails tutorials. Marvel at Rails pre-REST, survive the merger with Merb, feel the joy & pain of the then-new asset pipeline, and watch testing techniques grow, evolve, and simplify. Leave with a deeper appreciation for where Rails came from and where it is today.

RailsConf 2018

00:00:11 Good morning everyone! How's everyone doing? Having a good time? All right. My name is Michael Hartl, and I am the author of the Ruby on Rails tutorial. How many people here have read some or all of the Rails tutorial? All right, we've got a packed house! Awesome! Thanks! Send your checks later to compensate you for filling it out here.
00:00:30 So, I'm here to talk about ten years of Rails tutorials. What that means is we're going to look at the development of Rails itself through the lens of introductory tutorials. The story begins when I was in graduate school at Caltech in Pasadena, California.
00:00:51 At Caltech, I taught the physics core curriculum for five years and had a lot of success as a teacher. However, while I was there, I became interested in entrepreneurship. As preparation for becoming an entrepreneur, I decided to learn how to make web applications. I figured that would be a useful skill to know.
00:01:08 Little did I suspect at the time that my first successful company, after two failed startups, would be to teach people web development. Those were primitive days, though, so I dug up a picture of what web application development looked like back then.
00:01:31 In the early 2000s, web development involved spreading some HTML in your text editor, pressing it into the web browser, and then sending it back to the user. Seriously, it was quite primitive. My first web development language was PHP, and you would do stuff like echo strings to the browser.
00:01:53 You would input SQL, and that was it—these were the early days. So, I learned PHP, built a couple of projects with it, and then started looking for something a little more structured. I found something called Zope—a framework written in Python, a lovely language similar to Ruby in many ways.
00:02:13 Zope was good for creating content management systems, but by this time, I was working on my own startup and needed to build general-purpose web applications. I felt like there was a gap; everything out there was working at the wrong level of abstraction.
00:02:33 At that time, there weren't any Ruby frameworks—there were only a few that were suitable for outputting strings. It was obvious that there needed to be a way of making database-backed web applications that rendered HTML to the user and took care of annoying details like sessions, cookies, and redirects.
00:02:54 So, I built my own half-baked web framework in Python on top of Zope. It worked for the startup, even though the company didn't survive. However, the experience of making my own web framework helped me appreciate all of the problems that Rails was solving.
00:03:18 When Rails came out and the original 15-minute blog demo was released, I was ready for it. I understood the problems Rails was addressing and how difficult it was to put everything together. I immediately recognized that this was something special.
00:03:39 It's easy to forget how groundbreaking Rails was at the time. When you look at some of the things Rails does today, it all seems obvious, but many of those concepts were popularized by Rails first. Its success helped to disseminate those design patterns throughout the industry.
00:03:59 At that point, it was pretty obvious to me that Rails was a good bet. My first company had failed, so I had the time to learn a new web framework. I took a course from Dave Thomas and Mike Clark, and I read a programming book named after this course.
00:04:16 The course was super compressed—only three days long. You can't learn web development in three days or even three weeks, maybe not even three months! But it did give me a nice overview. Afterward, I was ready to read what was then the only Rails book, Agile Web Development with Rails, by Dave Thomas and David Heinemeier Hansson.
00:04:35 While preparing this talk, I wanted to include a copy of this book in my presentation. I actually had a second edition, but I tracked down a first edition. I'd like to thank Dave Thomas for graciously answering my email and sending me a PDF copy of this book.
00:05:03 The PDF didn't include the cover, so I went onto Amazon to find the original cover. Interestingly, I found that you could still purchase the first edition of this book, presumably as a collector's item.
00:05:24 As I read the only book available at the time, a couple of years later, a friend of mine from Caltech and I wrote my first real tutorial book, titled RailsSpace. This was about building a social networking website using Ruby on Rails. To give you some context, RailsSpace is a reference to MySpace, which was still quite popular at that time.
00:05:51 Now, this subtitle may make it sound like it's about building social networks, but it was really just a Ruby on Rails tutorial that utilized a social network as the sample application. The publisher wanted to call the book Ruby on Rails Tutorial, but I thought that was a boring title.
00:06:13 I saved that title for myself for a later edition. In this fourth section of the talk, we'll discuss how ahead of the curve Rails was in its development.
00:06:28 It's easy to overlook just how groundbreaking Rails was because it has continuously pushed the whole industry forward. Starting right at the beginning, with the command to create a new Rails project.
00:06:44 You would type a command at the command line, which would automatically generate a full project skeleton. This was a big deal! It wasn't standard practice for developers at that time.
00:07:05 Rails provided a standard set of directories and files, giving developers a place to start. If you looked at a project created by someone else, you were already familiar with its basic structure.
00:07:24 Rails also addressed standard problems associated with web development, which weren't standard practices before.
00:07:40 It effectively facilitated interaction with a database, something that was crucial in web applications. This is what a data center looked like in the early 2000s.
00:07:57 You would start by creating a table—the process for which is still integral in modern applications.
00:08:13 You could inherit from ActiveRecord and interact with the database easily using Ruby. By 2007, Rails was already enabling amazing functionalities, allowing users to dynamically generate HTML content.
00:08:34 It also empowered developers to render dynamic content and generate forms. At that time, using user screen names as inputs was common in web applications.
00:09:02 Rails allowed for partial rendering, allowing for the reuse of HTML elements effectively, and generating user input dynamically along the way.
00:09:18 In terms of structure, everything was organized into the Model-View-Controller architecture right from the start—this was revolutionary.
00:09:36 Knowing where to place components was new for many developers who were accustomed to writing scripts with everything mashed together.
00:09:59 Once you created your app, you wanted to launch it and put it in front of an audience. However, deployment at that time was quite challenging.
00:10:17 With RailsSpace, my co-author and I punted on deployment. It was simply too hard; we could only suggest running your app locally in a production environment.
00:10:35 We realized that deployment was a major hurdle, and during this talk, I’d like to bridge our early experiences with where we are today with Rails.
00:10:55 Many of these examples will draw from my own series of books starting with RailsSpace and including the Ruby on Rails Tutorial, originally the Ruby on Rails 3 Tutorial, which has now gone through four editions.
00:11:22 We'll also look at the evolution of testing in the Rails tutorial, starting with early examples from RailsSpace itself.
00:11:40 This is an example of a test for login success from 2007. I have to emphasize again that this was a revelation at the time.
00:11:59 In my first company, I spent a lot of time debugging forms by manually making changes and testing code paths, which was a nightmare. Being able to write tests that checked everything before deploying was incredible.
00:12:26 We had a way to populate a test database case using fixtures.
00:12:38 The Rails tutorial evolved and I began to incorporate Factory Girl to define users and serve populate them in tests, whereas my first edition utilized a describe block.
00:12:55 Many of you may recognize this as RSpec. For the second edition, I added Cucumber, which allowed writing plain-text tests.
00:13:16 The goal was to allow business folks to write tests understood by developers, but I realized that this was quite challenging to accomplish.
00:13:33 After exploring different testing techniques, I found that many of them didn't work as reliably as expected, especially when upgrading versions of Rails.
00:13:55 Realizing I had fallen into a pattern of following trends, I decided to return to basics.
00:14:10 The fourth editions reflect a focus on having a reliable testing suite, emphasizing that having something is better than having nothing.
00:14:25 I also began making integration tests, as they are crucial given the tightly coupled nature of web applications, focusing on ensuring comprehensibility in processes.
00:14:49 This meant even returning to using fixtures, but incorporating updates from my past experiences.
00:15:01 Having demonstrated where Rails has landed today, let’s take a step back and explore how Rails has continuously pushed the envelope in web development.
00:15:21 I want to show contrasts between outdated methods and the modern approaches that Rails now supports, such as proper interaction with databases.
00:15:41 Early web development involved raw SQL queries, which were not ideal. However, Rails facilitated using Active Record, which transformed how developers engage with databases.
00:15:59 The introduction of migrations standardized how developers change their databases. By using Rails 1.2, one could simply create migration scripts in Ruby, allowing development to move swiftly.
00:16:28 This innovation led to seamless database change management and made maintaining projects easier.
00:16:43 Rails also introduced a framework called the Asset Pipeline. This allowed developers to bundle images, JavaScript files, and stylesheets efficiently, so they didn’t have to clutter their public directories.
00:16:59 The Asset Pipeline revolutionized how projects managed dependencies, notably simplifying the process of enhancing browser experience.
00:17:17 Transitioning into security, Rails has continuously adapted and enhanced its practices to meet advanced needs. In early Rails applications, security concerns such as mass assignment weaknesses existed.
00:17:39 Developers have since learned to define user parameter methods for better security, ensuring that issues like unwarranted admin flags are effectively mitigated.
00:17:59 Safe HTML escaping is now standard practice in Rails, eliminating significant potential vulnerabilities like cross-site scripting for end-users.
00:18:15 RESTful design principles have influenced Rails' evolution as well, creating a foundation for developers to create applications structured around resources.
00:18:32 Implementing REST practices has allowed Rails to remain relevant while providing developers with structured methods for managing resources.
00:18:45 As we reach the end of our exploration, it is worth noting the remarkable support from various tools, community, and ecosystem to embrace Rails.
00:19:02 Opportunities have continuously arisen for developers to build innovative solutions using Rails that adapt to current trends in web development.
00:19:18 Rails has always led in adopting new ideas and integrating them into its ecosystem, and I foresee it continuing to progress. The future of Rails remains incredibly bright.
00:19:35 With potential for growth and evolution, we can anticipate many more innovations ahead over the next decade. Thank you!
Explore all talks recorded at RailsConf 2018
+98