Talks
Polyglot: When Ruby isn't enough or even sane

Summarized using AI

Polyglot: When Ruby isn't enough or even sane

Blake Mizerany • September 17, 2010 • Earth

The video titled "Polyglot: When Ruby isn't enough or even sane" features speaker Blake Mizerany at the GoGaRuCo 2010 event. The main topic revolves around the importance of being a polyglot developer and not restricting oneself to a single programming language, particularly Ruby. Mizerany emphasizes that while Ruby is a versatile and powerful language, it has limitations and is not the perfect tool for every problem.

Key points discussed include:
- Definition of a Polyglot: Mizerany redefines the term to include anyone proficient in multiple programming languages, highlighting the necessity of thinking beyond just one language.
- Limitations of Ruby: He outlines various areas where Ruby struggles, such as CPU concurrency, systems programming, and complex data tasks, suggesting that overreliance on Ruby can lead to inefficient solutions.
- Diverse Programming Languages: Mizerany discusses several other languages like Erlang, Go, C++, Node.js, and Perl, comparing their strengths and weaknesses relative to Ruby in metrics such as concurrency, agility, and task suitability.
- Learning from Other Languages: Mizerany stresses the value of learning from different programming communities and languages. Engaging with various programming paradigms can provide new perspectives and solutions to problems.
- Practical Strategies: He advocates for practical engagement by experimenting with different languages, such as porting existing Ruby code to another language to understand its idioms and features thoughtfully.
- Community Engagement: Mizerany highlights the importance of staying connected with the programming community through platforms like IRC, mailing lists, and meetups to continuously learn and share knowledge.

In conclusion, Mizerany's message is clear: developers should embrace a polyglot mindset, continually expand their toolset, and recognize the appropriate use cases for different languages. By doing so, they can remain effective and innovative in their programming practices, avoiding the pitfalls of sticking solely to Ruby or any single programming language.

Polyglot: When Ruby isn't enough or even sane
Blake Mizerany • September 17, 2010 • Earth

You're so polyglot and you don't even know it. You may be using Ruby for too much. It's not the holy grail. This talk will pull from my experience at Heroku where I use much more than Ruby everyday; and I'm not just talking JavaScript. Technologies are designed to take on problems of a specific nature. There are those that are great for systems work and those that are not. Some make generating reports a cinch. A few are remarkable at digging through data. Networking can be a nightmare in some. I'll start with a swift but gentle introduction to Ruby's good but not great suits and move us into what to replace them with.

Help us caption & translate this video!

http://amara.org/v/GZSn/

GoGaRuCo 2010

00:00:10.519 This is a bit of an interactive presentation, so I'm going to ask for some of your help. But we'll get to that in a minute. I am here to talk about polyglot.
00:00:17.279 How many of you have heard this term before? All right, cool. Sweet. Jim gave away half of my presentation during his keynote, so I'd like to extend a thank you to him. This means I can cut this a little bit shorter.
00:00:23.680 Can you guys hear me okay? This is not the right... you know what, boom.
00:00:30.640 So, polyglot. I am going to hurt some of your feelings. There will be a lot of "what is this guy talking about?" as I go on.
00:00:38.280 But anyway, you can follow me on Twitter; I'm B Mizerany, and I'm on GitHub under the same username.
00:00:43.520 As Josh mentioned, I work at Heroku. How many of you know who Heroku is? How many of you have A/B deployed on Heroku? Yes, all right, and yes, we have a read-only file system.
00:00:54.800 So, I'm here to talk about how to be a polyglot. How many of you know what the definition of a polyglot is?
00:01:01.239 Okay, cool. As for the term, a polyglot is a person who speaks several languages, so you can kind of get a sense of what I'm about to talk about.
00:01:09.720 But I'm going to elaborate on this definition just a little bit more. Since we are all engineers here, the term needs to be changed to include 'a person or machine who speaks several languages.' I also want to focus on the word 'several' because I've struggled with the difference between 'a few' and 'several' in definitions. I looked it up, and 'several' means 'more than two or three.' Let me give you a real-world example.
00:01:29.200 As you can see this fine specimen, it's part Ewok, part Great Dane, and part Jedi.
00:01:35.960 Ladies and gentlemen, I give you the rare and elusive Jadena Walk. That's polyglot!
00:01:43.520 Okay, this is the interactive session. Every time you see this slide, I need everyone to yell 'polyglot.' All right, that was lame.
00:01:54.800 So, Unix itself... how many of you use Unix, or are on Macs or FreeBSD, whatever? Unix is polyglot.
00:02:06.560 You are all in this audience, except for you in the back with the Java one polo. Polyglot!
00:02:14.879 Let me give you a more complete example. How many languages do you see here?
00:02:23.880 Three. All right, I'm going to break it down for you; there are actually four.
00:02:29.000 Let's take a look. First, we have an interactive Bash. Most people don't realize or remember that when you're in a console, you're programming; you're doing it interactively.
00:02:39.519 Then we have Perl. For those of you who don't know about it, Perl is amazing. If you don't know about it, go to bettergre.org, and it will blow your mind.
00:02:48.480 This is Ruby meta. I'm using a Perl script in Bash to look for Ruby code.
00:02:56.720 And VI. I use VI. VI is written in C and runs Vim script. So, we have five languages here that are running together to produce a result and work out a problem.
00:03:05.960 Let's take that, flip it, and reverse it, going from the inside out. If you're going to do polyglot, a very simple, basic example is something like Ruby.
00:03:13.680 With Ruby, I can take input from a stream, massage it, manipulate it, run calculations, and print it back out.
00:03:20.400 On the business end of my application, something can take that, massage it, and move it back out again until it's complete.
00:03:28.320 It typically ends up somewhere, usually on standard output or on a web server.
00:03:36.200 With all that being said, this isn't hard. So, why am I talking to you? Because everybody takes their favorite language and turns it into one big hammer, and everything becomes a nail.
00:03:45.880 They decide, 'Oh, I've learned Ruby; it does everything. It's a general-purpose programming language, so why would I ever want to do anything else?' I'll let the other guys use Perl; I don't have to learn it.
00:03:56.920 That's fine; I'll just use their code. But it's a very romantic view, hiding it in their code base and never having to see it.
00:04:06.960 But the problem is, when you get these hammers, you start to feel like this with any language. At some point, as you mature, you realize that every great tool has a dark side.
00:04:16.720 What you really want is many hammers; you need a lot of them. Going back to the definition of 'several,' it isn't that you want many; you just need more than two or three.
00:04:24.640 A lot of us in the Ruby community do Ruby and JavaScript because we are writing a Rails app, and then on the client side, we're using JavaScript. That's about as far as we get.
00:04:35.919 But it is important to go out and learn new things. My message to you is: don't do everything in Ruby.
00:04:45.000 I'm sorry if this upsets you, but let me give you some reasons.
00:04:54.000 I can already hear you in IRC right now, making fun of me and calling me silly names, so let me get through the reasons.
00:05:03.680 The first reason is that you want to learn how others think. When you're in Ruby, we all tend to think alike.
00:05:13.600 For instance, you hear people say, 'Oh, go use RSpec, go use test development.' Yes, of course, that's a great thing. But other languages may implement things differently.
00:05:23.680 Some might say, 'I'll make a function for that instead.' This can be interesting because it exposes you to different paradigms.
00:05:32.119 When you start learning how others think, you see their paradigms, views of the world, and how they tackle problems.
00:05:40.760 Sometimes they are solving the same problem you are trying to solve, but in a different way. This new perspective can be enlightening.
00:05:49.000 From talking with people in different languages, the words they use are significant. When they start using terms you're unfamiliar with, it can completely change your understanding of a problem.
00:05:58.600 This is one of the biggest benefits of engaging with different programming communities. No language is a perfect ten across the board.
00:06:08.560 Let's break this down into a chart, which I'm trying to fit into a big enough font for everyone. Here we go.
00:06:17.279 The first cell is language, followed by CPU concurrency, IO concurrency, agility, IMHO systems, web, and text mining.
00:06:26.920 In my opinion, Ruby scores as follows: CPU concurrency gets a low score.
00:06:34.080 I am talking very low here; maybe a one out of ten. For IO concurrency, I give it a four.
00:06:42.360 Ruby does have good IO concurrency if you're using threads or if you use an event machine, which I give a seven.
00:06:51.679 How many of you have used EventMachine? Yeah, EventMachine is awesome!
00:07:00.640 But it provides a very nice form of concurrency where we're not blocking on IO anymore. We can start doing CPU-based tasks instead.
00:07:06.919 As for agility, Ruby scores a nine. I love how quickly I can crank things out with Ruby. However, sometimes it can get in the way.
00:07:14.640 At Heroku, I work with systems programming. I need to communicate with the system and do things that Ruby does not support well.
00:07:24.639 How many of you have dealt with pipes, PIDs, or any system calls in Ruby? It starts to get really gnarly and complicated.
00:07:31.739 Eventually, I have to start moving away from Ruby in those areas and switch to something else.
00:07:40.160 As for web development, Ruby gets an eight. We have Sinatra. Can I get a big round of applause for Ryan too back there, who made Sinatra happen?
00:07:49.760 Doing command line work with Ruby is generally pleasurable. Op-parser is great.
00:07:57.720 If I need anything more than that, we have plenty of libraries available. Ruby has pretty good CLI support.
00:08:05.000 But for text mining, I would rate it a seven. How many of you have done text mining or tried to dig through logs?
00:08:12.120 If you have millions of hits, you might as well start a screen session and prepare for a long haul.
00:08:20.760 Now, let's move on to Erlang. How many of you have used Erlang?
00:08:28.840 We have a few hands. Erlang scores an eight for CPU concurrency.
00:08:34.680 Although some might want to give it a nine, it can be exhausting on the CPU and doing a lot of unnecessary copying.
00:08:40.360 The IO concurrency in Erlang is fairly high.
00:08:48.120 But agility? I'm giving it a five. I don't know if any of you have ever tried to crank something out within an hour in Erlang.
00:08:54.319 It's not easy. There's a lot of setup and overhead to get started.
00:09:02.000 As for systems work, Erlang has none. It’s worse than Java. It’s horrible—there's no POSIX system support.
00:09:11.240 I can't use Erlang for most of the tasks I handle at Heroku, although I sometimes wish I could.
00:09:19.320 For web development, if you're doing API stuff or creating a basic web service, it's much better than a four.
00:09:26.240 But for overall web development, it's quite low due to issues with templating and basic business logic.
00:09:34.720 The CLI is horrible, and text mining is pretty bad in Erlang.
00:09:43.560 Now, how many of you have been using Go? I hope to see more hands next year!
00:09:51.760 Go is pretty amazing! I would rate it a nine on CPU.
00:09:59.240 IO concurrency is fantastic; it has an asynchronous feel where it acts like it's blocking but isn't.
00:10:07.440 System support is quite high, doing great things for POSIX system support.
00:10:14.840 However, as a web language, it isn't very mature. There isn't much built into the core packages yet.
00:10:22.480 The CLI is quite nice, but for text mining, I would rate it a four.
00:10:30.880 Now, let's move on to C++. I'm giving it a similar score but slightly higher on agility. The agility in C++ is better due to the presence of garbage collection.
00:10:39.000 Node.js... how many of you are doing Node.js? Right on!
00:10:47.440 Node.js is high for IO concurrency but low for CPU since it runs single-threaded.
00:10:54.040 The agility is quite high because, after all, it is JavaScript.
00:11:02.560 System support is really high, however it falls low in the web category.
00:11:10.040 For text mining, it actually performs great.
00:11:17.680 Next, let's talk about the JVM. It's been a while since I've worked with it, but I recall it being low across a lot of metrics.
00:11:25.840 The system support is pretty low, and it can be bulky.
00:11:33.440 As for Perl, it's my go-to for heavy data mining and text files. I love how well-suited it is for these tasks.
00:11:41.760 Yes, you can write very beautiful Perl! I've seen some amazing examples.
00:11:49.320 Let’s talk about being a polyglot. It’s pretty straightforward: you are capable and knowledgeable.
00:11:55.040 A seasoned polyglot speaks the native language and keeps up with its culture.
00:12:01.840 Just because you learned a couple of languages quickly doesn’t mean you can stop paying attention.
00:12:08.040 To keep that fresh in your mind, you want to remain engaged in communities.
00:12:16.080 You can do this in IRC, mailing lists, documentation, or bars with others.
00:12:24.120 For those interested in functional programming, there's a group called 'Functioning Alcoholics' in San Francisco.
00:12:32.760 They meet once a month and do many interesting things, making it valuable to be around them.
00:12:41.560 Be sure to borrow from different religions of programming but stick to your own.
00:12:48.360 You need to embrace the community norms without losing your own identity.
00:12:56.360 By maintaining more tools in your toolbox and keeping up with them, you can code effectively under limited resources.
00:13:05.120 You may only have VI and a C compiler, but you have the skills to get something done quickly.
00:13:11.960 Sometimes you may only have Perl installed, and you need to adapt.
00:13:18.760 So, what does this look like? It means you need to know the best and simplest tools for the job.
00:13:26.040 You seek knowledge about new ideas and old ideas. I’ve found myself often flipping through an O’Reilly book out of boredom.
00:13:34.960 Then I remember something I had forgotten while relying on big libraries.
00:13:41.680 Seeking out knowledge of new programming languages, I often share my enthusiasm with others.
00:13:48.760 I often hear people say they read the docs but don’t see a problem that needs solving.
00:13:55.840 In reality, most of the problems you solve in Ruby can also be handled in another language.
00:14:03.440 The first step I take in learning a new language is to port something I already know into that language.
00:14:10.080 You see this a lot when Node.js came up; many tried to clone Sinatra.
00:14:17.440 It’s simple and provides basic principles that are easy to understand.
00:14:25.280 For instance, have any of you ever written a Redis client just for fun? I highly recommend it.
00:14:33.000 I’m not saying to build your own for production, but it’s a nice experiment.
00:14:40.720 Writing a simple protocol helps you gain insights into how things work.
00:14:49.040 Another experiment could be porting a basic Reddit server using Node.js.
00:14:55.680 This is a great exercise for grasping networking, protocols, and data structures.
00:15:01.600 As you do this, read through mailing lists and keep learning.
00:15:08.440 It’s valuable to read the documentation every day to keep it fresh in your mind.
00:15:15.920 Being in IRC can also be beneficial, but keep in mind it can be distracting.
00:15:23.520 You can ask questions or find help about various issues you're facing.
00:15:31.760 Once you've ported something to their idioms, you'll want to try it in their idiomatic way.
00:15:39.920 This requires embracing common practices and paradigms in this new language.
00:15:47.680 Ask questions, get feedback from those experienced, and learn why this approach is used.
00:15:56.640 It's like when you first learned Ruby: digging into libraries and asking questions is how we all learned.
00:16:04.600 Asking clarifying questions is an excellent way to dive deeper into a language.
00:16:12.160 After a while, help others who are coming into the community.
00:16:19.520 By answering their basic questions, you strengthen your knowledge and gain their gratitude.
00:16:27.280 As you work with more languages, you may notice your original code begins to look different.
00:16:34.360 Interoperability is critical; watch out for integration issues that can arise.
00:16:41.680 Remember when CORBA created challenges in connecting multiple languages?
00:16:48.560 Realize the difficulties in making these languages talk to each other without compatibility problems.
00:16:55.520 Be aware that many attempts at standards—like SOAP—have fallen short of expectations.
00:17:03.360 However, JSON today is a simple and widely used standard with enormous support.
00:17:15.440 Its simple language and human-readable structure make it much easier.
00:17:22.640 When sending JSON over the wire, most languages have a built-in decoder, which makes life easier.
00:17:28.960 Yes, it has its downsides like not being binary safe and less efficient with wire.
00:17:35.680 But you must consider the trade-offs before deciding on the solution.
00:17:43.840 In addition, learn other formats like BSON and REST, which simplify concerns around data formats.
00:17:51.760 REST is also very powerful, but not every language has support for more advanced features.
00:17:59.440 Older clients may not handle the latest requirements, but new ones often support them.
00:18:04.720 Be cautious of schemas and formats to follow for effective communication.
00:18:10.960 You will avoid becoming locked into an unsuccessful approach.
00:18:18.880 Remember the lessons from the past to avoid repeating the same mistakes.
00:18:25.840 What I want to emphasize is that collaboration and learning from each language is vital.
00:18:31.920 As you grow and gain experience, transfer the knowledge from one language to another.
00:18:39.360 Seek simplicity and efficiency in your data exchange formats.
00:18:47.040 If it cannot be easily decoded, seriously consider whether you should use it.
00:18:54.640 Lastly, keep learning, reading, and repeating what works.
00:19:00.680 Thank you!
Explore all talks recorded at GoGaRuCo 2010
+25