Talks

Writing Ruby Like it's 2018

GORUCO 2018: Writing Ruby Like it's 2018 by Joe Leo

GoRuCo 2018

00:00:14.389 Hello everybody, my name is Joe, and I am speaking at GoRuCo. This is a dream come true, but I don't have a lot of time, so I have to get right to it. First, I run a company that's sponsoring the conference, GoRuCo. If you are great at what you do, then we’re hiring. I'm also writing this book called "The Well-Grounded Rubyist, Third Edition" with my good friend and mentor, David Black.
00:00:27.720 I started writing Ruby a long time ago back in 2007 when we were all still arguing about whether or not Tony died at the end of "The Sopranos." Programming was different back then. I was being paid to write Ruby, which was amazing, as not many people were. Version 1.8.6 was hot off the presses, and we loved it, which was fortunate because we almost didn't get any more after that.
00:01:13.520 Everybody I knew, including myself, had our hopes riding on a company called Twitter because it was being written in Ruby. We didn’t totally know what it was, but we all felt like our own career trajectories hinged on the success or failure of Twitter, and I think we were probably right. This is what Twitter looked like when I signed up; nobody had come and tried to redefine the word 'cloud.' Heroku wouldn't be out until 2009, so we all just wrote our own deployment.
00:01:41.250 Every Rubyist wrote their own authentication. There was no such thing as Warden; there was no such thing as Devise. Melissa Wan talked about encryption in a great talk that could not have been spoken in 2007. We just did it ourselves until finally, Chad Fowler brought some sanity to the world by writing "Rails Recipes," which every Rubyist bought because it had a chapter about how to authenticate users right underneath that was a chapter on authorizing users. Ruby's future was uncertain, and this was really exciting.
00:02:23.420 We anticipated a big release, a big Ruby 2, in the sky that was coming someday, but we had a lot more people involved. It was not just a Japanese language or an American language; there were contributors from all over the world. We couldn’t quite decide where we were going or how we were going to get there, and we couldn’t agree on anything from UTF-8 to concurrency.
00:03:00.180 Ruby 1.8.6 was released on Christmas Day of 2007, 1.9.0 came out, and it felt like a lump of coal in everybody's stockings. It wasn't production-ready; we knew it wasn't production-ready. What we didn't know was that it would be 14 months before a new point release of 1.9 would come out. In the meantime, we had 1.8.7. I talked to Mike D'Alessio about this, and he said 1.8.7 felt like a warm hug. It was a nice way to put it, and certainly, it was shipped with Macs, so this was big news and cool.
00:03:49.180 Unfortunately, it did not work with Rails 2 or Rails 2.1, which were the only ones available, so if you were using Rails, you couldn't use 1.8.7 until Ruby Enterprise Edition came along. Ruby Enterprise Edition was awesome; it had green threads, it was highly optimized, and it ran way faster than 1.8.6. However, it had an unfortunate name; anyone coming from the Java world with experience of J2EE did not want to see the words 'Enterprise Edition' after Ruby, but it was a great step in the right direction.
00:04:29.080 Finally, in 2009, we got Ruby 1.9.1, and things started to get back on track. 1.9.2 and 1.9.3 followed, but oh, this was a long time coming—six years. It took us from the end of "The Sopranos" to the start of "Rick and Morty" to go from 1.8.6 to Ruby 2.0, but we didn’t care because we made it. Twitter, LinkedIn, and GitHub were the darlings of the tech community, and they were all written in Ruby. Airbnb, SoundCloud, Groupon, and numerous other companies were hot on their tail, all written in Ruby.
00:05:05.690 We felt like we had made it. We had speed, features, community, and we had metaprogramming techniques as first-class citizens. We had better garbage collection, and we had a totally rewritten VM by Koichi Sasada. We had Ruby Quiz, which was incredibly cool. Our heroes in the Ruby community would get together to solve Ruby quizzes and post their answers online for all of us to see how they write code.
00:05:24.580 Ryan Bates was giving us Railscasts every week, and you could talk to the people who were implementing Ruby every day on Ruby Talk. Yet somehow, we went from that unbridled excitement to sheer boredom. I don’t know when it happened, but it did. I think part of it was that we all looked at Ruby as this shooting star that was going to topple the big boys; no more Java, no more Python.
00:06:06.620 We had our pride wrapped up in that; if Ruby was so much better than Java and Python, then why were all these people still writing Java and Python? But the fact is, Ruby made it. Ruby has its place in the world; it’s not going anywhere. The real question is, where do you stand with Ruby? When I ask that question, I get a lot of answers back. The most popular is, 'Well, I really don’t like Rails.' Well then, stop writing Rails; just stop doing it.
00:06:42.480 Ruby is not Rails, and you are not at a Rails conference. David H. Hansen will shed zero tears if you leave the Rails community today. The next thing I hear frequently is, 'Well, I think that object-oriented programming could be a little bit dangerous, with oversharing and mutated state, and I think functional programming is the way to go.' And oh my god, is that a boring argument! Look, object-oriented programming has been around since the 1960s, and it's not going anywhere. Functional programming has been around even longer and isn’t going anywhere either.
00:07:26.720 But by all means, you should go learn some functional languages. Dave Thomas told us to go learn a new language every single year. The point is that you should go learn some languages and then bring what you’ve learned back to your home language. Start writing Ruby like it’s 2018, which starts with realizing that some of the things have been around since at least 2013: higher-order functions, referential transparency, continuations—this has been around for at least five years, and you should be doing it.
00:08:04.060 People are doing it. If you look at everything that has come along since Ruby 2.5 was released at Christmas last year, there's so much. We have yield self, which is about to be renamed; we have currying of Procs and methods; we have myriad improvements to threads and concurrency. This is writing Ruby like it’s 2018. It’s taking advantage of what’s actually happening in the Ruby community today.
00:08:37.390 There are whole bunch of projects writing cutting-edge Ruby code. These are founded by people who came into the Ruby community, saw Ruby, and liked what they saw, recognizing how most people were using Ruby and said, 'I think we can do better.' And they’re doing it right now. You need to check these projects out. They’re employing better practices, writing code against boundaries, isolating views from templates, with class-based controller actions for easier testing.
00:09:12.120 The Celluloid project has fault-tolerant concurrency; almost all of these projects are making things better and easier to test, which is really important. Strict data types and static typing are here. So, why are all these things happening? Why am I urging you to write Ruby like it’s 2018? Because we have this big, great Ruby release in the sky coming; it’s called Ruby 3, and it's coming soon.
00:09:53.060 It was announced two years ago, and we’re halfway to when we think it might be released. It’s starting to feel a whole lot like 2007 again, and there are some big promises coming with it. Static typing is one of them, but guess what? That’s already here! Dry RB has dry types, and you can check it out right now. On June first, Stripe released a beta version of Sorbet; go to sorbet.run as soon as I’m done with this talk and check it out for yourself.
00:10:34.080 Another thing that’s here is Ruby running three times faster, thanks to frozen string literals. Now, everybody I've talked to thinks that frozen string literals are boring, but it's only boring because they work fine in your app. What they care about is the fact that every gem ever written since the beginning of time, that's still being used by any project, is going to break when we make frozen string literals default. We’re going to blow up the entire world of Ruby! Nobody has an answer for how to roll this out; nobody—not you, not Hoo-To, not Matz, but you can.
00:11:24.640 You could suggest; you can get involved. The really big thing, the really big news, is Ruby guilds. Koichi Sasada, to whom we owe our Ruby lives, is writing Ruby guilds. He’s going to tackle the global interpreter lock.
00:11:38.880 Those are my words, but he’s going to conquer this and abstract it away, or conquer it so that we can not just write concurrent Ruby but actually run parallel Ruby with multi-core processing. We’ll have mutation-safe concurrency. These are things we couldn't even imagine could be done in 1.8.6 and are now being promised today.
00:11:49.640 That’s why when you see things like method currying and all of these advances in functional programming paradigms, it’s because of what's coming. If you're going to be ready for what's coming, then you need to start using these techniques today, and you don’t need to go to another language to do them; you can do them right here in Ruby.
00:12:16.370 To me, it feels like we’re back in 2007 with our iPod shuffles. We have this great big release in the sky, and we are the underdogs again. There's a lot of doubt over whether we will get to those great big features that I just mentioned, but here we are, chugging along.
00:12:47.950 The fact is that it’s exciting; without the threat of utter failure, none of this would be exciting. We don't know if we’re going to get there, we don’t know if there will be a Ruby 3, and when we get there, we don’t know if anybody’s going to use it, just like we were back then. I suggest getting excited about that. I suggest getting yourself involved.
00:13:31.050 Get yourself involved in the conversation, relearning, learning new languages, bringing them back—and strap in! This is a great time to be a Rubyist. Thank you all.