Good Programming Is Like Good Writing
David Heinemeier Hansson is a Danish programmer and the creator of the Ruby on Rails open source web development framework. He is also a partner with Jason Fried at the web-based software development firm 37signals. In 2005 he was given with the Hacker of the Year by Google and O'Reilly award for his creation of Ruby on Rails. He and Fried have also co-authored the New York Times bestseller "Rework," which reveals their secrets for boosting business productivity in the Internet age.
Question: What makes Ruby a special language?
David Heinemeier Hansson: To me good programming is just like good writing. It's succinct. You're expressing what you want to say in as few words as possible. You're picking just the right words for the sentence, and it's sort of a grand thing. A program is just like an article or a book; it's composed of tiny things like words that form into sentences, and paragraphs, and chapters, and so forth. A programming language—a good programming language—allows you to build a program in just the same way.
So you'll have methods that are really short. A big part of what makes Ruby so special to work with is just how much expression you can pack into few lines of code. When I compare it to something like Java where it takes perhaps ten lines to express a very simple operation, that same operation can be expressed in a single line of Ruby. And that just makes understanding the entire program that much easier when the density of expression is so much higher, and it's not just because it's short. There's plenty of programming languages where you can write exceptionally short code, and it's completely unreadable afterward. Ruby has this uncanny ability to just be shortened the same way your thought would be short, but no shorter than that.
The other part of it is also having a grand or free mode of expression that there are many different ways that you can say something. So for example: Lots of programming languages have—or all program languages have—conditionals. If something is true, do this. Now, sometimes you want the positive version of that. Like, “If employee works here, then print this screen.” Sometimes you want the opposite. In most program languages, you would go about that by saying, “If not programmer works here, then do this.” That's not a very natural way of expressing that. You would never say that in real life.
In Ruby, you can say, “Unless the programmer works here, do this.” So it's just all those little things where the creator of Ruby thought about the whole picture. It's not just that you can get something done. All programming languages can do the same things. There's nothing you can do in Ruby that you couldn't do in some other programming language. What makes Ruby special is how you say it.
Compared to natural languages, I think there's also just something to the tone and they rhythm of it. I'm Danish. I speak Danish, and I admit that Danish is not a very pretty language. Thankfully, it's not as ugly as German, which I think is probably one of the ugliest languages of all time. But if you compare something like German to something like French, you don't have to speak either language to hear that French is obviously the prettier language.
I think if somebody who doesn't even know code, they can look at a piece of Ruby code, and they can appreciate that Ruby is French and Java is German. That's sort of really the appeal to it. Because you have to work with this stuff all the time. Programmers often work for many, many, many hours a day, and this is your main mode of expression. It has to be good. If it's not good, if you're speaking in an ugly language every day for eight or ten hours a day... well, I won't say that it turns you into an ugly person, but I like to just surround myself with beautiful things. Ruby is beautiful; lots of other programming languages are much less so.
Question: Do programmers need to like the languages in which they code?
David Heinemeier Hansson: I think in the past, programming languages and environments have been determined by everything but the beauty of expression. It's been determined by “We have to make this really fast. We have to make this really efficient. We have to make this really logical. There has to be only one way of doing things.” All of these other concerns that you would think about when you would think about somebody approaching it in a very sort of binary approach. That's sort of the best way I can express it.
Ruby comes from a much different angle. In fact, the creator of Ruby said that his main goal of creating Ruby was to make programmers happy. Now, you're introducing something that in many ways seems like a foreign concept. You're talking about code. What does happiness have to do with anything? How does happiness play into this stuff? It absolutely does because programmers—surprisingly enough, I'm sure to a lot of people—are humans, too. And humans just respond to emotional things. They respond to beauty, they respond to a general sense of well being and liking your tools. It's not enough that your tools can get the job done. It's how they get them done. It's whether you like wielding those tools day out and day in.
And I've talked to a lot of Ruby programmers who came to sort of the edge of their career thinking they've been working in Java, or C-Sharp, or some other language that was just driving them miserable. And they were thinking, “You know what? I know how to do this stuff, but it's probably not for me. I'm not happy working with these languages or environments every day. I'm going to quit.” And then some of them found Ruby. And it almost sounds cheesy as sort of a religious experience that they find this program language that all of a sudden makes it interesting for them again to be programmers. But it's absolutely true. I felt exactly the same way. I was absolutely not convinced that I was going to be a programmer when I was working with PHP and Java.
To me, at that point programming was just something I had to do to get programs. It was sort of just a functional thing I unfortunately had to go through in order to realize the ideas that I had for programs. For me, Ruby just changed that such that the act itself was pleasurable. And I think that's just a magic moment. When you change over from not just being able to do the job to actually enjoying the job. That's just a huge difference. And I think that the product in the end also reflects that. The programs I write now are much better than the programs I wrote when I didn't like my tools.
Recorded on July 22, 2010
Interviewed by Peter Hopkins
"A big part of what makes Ruby so special to work with is just how much expression you can pack into a few lines of code," says Hansson.
What would happen if you tripled the US population? Matthew Yglesias and moderator Charles Duhigg explore the idea on Big Think Live.
Is immigration key to bolstering the American economy? Could having one billion Americans secure the US's position as the global superpower?
How Nobel Prize winner physicist Lev Landau ranked the best physics minds of his generation.
Rank 0.5 – Albert Einstein<img type="lazy-image" data-runner-src="https://assets.rebelmouse.io/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpbWFnZSI6Imh0dHBzOi8vYXNzZXRzLnJibC5tcy8yNDQ0NDY3NS9vcmlnaW4uanBnIiwiZXhwaXJlc19hdCI6MTYzNjI2NTU4OH0.FtBYC7oJz-ZOiiGC9y0Z50_JvQChmp-ONa3jhR3SuLA/img.jpg?width=980" id="d6f66" class="rm-shortcode" data-rm-shortcode-id="61288810a4f035ec2af8957fad4e9015" data-rm-shortcode-name="rebelmouse-image" />
Albert Einstein With Displaced Children From Concentration Camps. 1949.
Photo by Keystone-France/Gamma-Keystone via Getty Images
Rank 1<p>The group in this class of the smartest physicists included the top minds that developed the theories of quantum mechanics.</p><p><a href="http://en.wikipedia.org/wiki/Werner_Heisenberg" target="_blank">Werner Heisenberg</a> (1901 - 1976) - a German theoretical physicist, who's achieved pop-culture fame by being the name of Walter White's alter ego in <em>Breaking Bad</em>. He is known for the Heiseinberg Uncertainty Principle and his 1932 Nobel Prize award flatly states it was for nothing less than "the creation of quantum mechanics".</p><p><a href="http://en.wikipedia.org/wiki/Erwin_Schr%C3%B6dinger" target="_blank">Erwin Schrödinger</a> (1887 - 1961) - an Austrian-Irish physicist who gave us the infamous "Schroedinger's Cat" thought experiment and other mind-benders from quantum mechanics. The Nobel-prize-winner's <a href="https://en.wikipedia.org/wiki/Schr%C3%B6dinger_equation" target="_blank" rel="noopener noreferrer">Schrödinger equation</a> calculates the <a href="https://en.wikipedia.org/wiki/Wave_function" target="_blank">wave function</a> of a system and how it changes over time. </p>
Erwin Schrödinger. 1933.
Satyendra Nath Bose. 1930s.
Enrico Fermi. 1950s.
Rank 2.5<img type="lazy-image" data-runner-src="https://assets.rebelmouse.io/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpbWFnZSI6Imh0dHBzOi8vYXNzZXRzLnJibC5tcy8yNDQ0NDcwNy9vcmlnaW4uanBnIiwiZXhwaXJlc19hdCI6MTY0NDE1MDIxM30.Eg6tca61EredHxjqNH29HY3UeJbgBVa1nA13EhXTooU/img.jpg?width=980" id="90f86" class="rm-shortcode" data-rm-shortcode-id="0f1e6c5e13263a77b2061e1191fd8baf" data-rm-shortcode-name="rebelmouse-image" />
Lev Landau. 1962.<p><strong>Rank 2.5</strong> is where Landau initially ranked himself, rather modestly, thinking he didn't produce any foundational accomplishments. He later moved his prominence, as his achievement mounted, to the higher <strong>1.5.</strong></p>
Controversial physics theory says reality around us behaves like a computer neural network.
- Physicist proposes that the universe behaves like an artificial neural network.
- The scientist's new paper seeks to reconcile classical physics and quantum mechanics.
- The theory claims that natural selection produces both atoms and "observers".
Vanchurin interview:<span style="display:block;position:relative;padding-top:56.25%;" class="rm-shortcode" data-rm-shortcode-id="539759cbfd8fcd5b6ebf14a3b597b3f9"><iframe type="lazy-iframe" data-runner-src="https://www.youtube.com/embed/bmyRy2-UhEE?rel=0" width="100%" height="auto" frameborder="0" scrolling="no" style="position:absolute;top:0;left:0;width:100%;height:100%;"></iframe></span>
Vanchurin on “Hidden Phenomena”:<span style="display:block;position:relative;padding-top:56.25%;" class="rm-shortcode" data-rm-shortcode-id="18886ffd5e5840bb19d4494212f88d82"><iframe type="lazy-iframe" data-runner-src="https://www.youtube.com/embed/2NDVdNwsHCo?rel=0" width="100%" height="auto" frameborder="0" scrolling="no" style="position:absolute;top:0;left:0;width:100%;height:100%;"></iframe></span>Vitaly Vanchurin speaking at the 6th International FQXi Conference, "Mind Matters: Intelligence and Agency in the Physical World." The Foundational Questions...
A strange weakness in the Earth's protective magnetic field is growing and possibly splitting, shows data.
- "The South Atlantic Anomaly" in the Earth's magnetic field is growing and possibly splitting, shows data.
- The information was gathered by the ESA's Swarm Constellation mission satellites.
- The changes may indicate the coming reversal of the North and South Poles.
Is the Magnetic Field Reversing?<span style="display:block;position:relative;padding-top:56.25%;" class="rm-shortcode" data-rm-shortcode-id="e3e0b16dac3b05dab808a4ddf04d198b"><iframe type="lazy-iframe" data-runner-src="https://www.youtube.com/embed/51usJ74pPP8?rel=0" width="100%" height="auto" frameborder="0" scrolling="no" style="position:absolute;top:0;left:0;width:100%;height:100%;"></iframe></span>
43% of people think they can get a sense of someone's personality by their picture.
If you've used a dating app, you'll know the importance of choosing good profile pics.