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.
Subscribe to our weekly newsletter
Erin Meyer explains the keeper test and how it can make or break a team.
- There are numerous strategies for building and maintaining a high-performing team, but unfortunately they are not plug-and-play. What works for some companies will not necessarily work for others. Erin Meyer, co-author of No Rules Rules: Netflix and the Culture of Reinvention, shares one alternative employed by one of the largest tech and media services companies in the world.
- Instead of the 'Rank and Yank' method once used by GE, Meyer explains how Netflix managers use the 'keeper test' to determine if employees are crucial pieces of the larger team and are worth fighting to keep.
- "An individual performance problem is a systemic problem that impacts the entire team," she says. This is a valuable lesson that could determine whether the team fails or whether an organization advances to the next level.
A study finds 1.8 billion trees and shrubs in the Sahara desert.
- AI analysis of satellite images sees trees and shrubs where human eyes can't.
- At the western edge of the Sahara is more significant vegetation than previously suspected.
- Machine learning trained to recognize trees completed the detailed study in hours.
Why this matters<img type="lazy-image" data-runner-src="https://assets.rebelmouse.io/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpbWFnZSI6Imh0dHBzOi8vYXNzZXRzLnJibC5tcy8yNDU2MDQ1OC9vcmlnaW4uanBnIiwiZXhwaXJlc19hdCI6MTYzOTkyODg5NX0.O3S2DRTyAxh-JZqxGKj9KkC6ndZAloEh4hKhpcyeFDQ/img.jpg?width=980" id="3770d" class="rm-shortcode" data-rm-shortcode-id="3c27b79d4c0600fb6ebb82e650cabec0" data-rm-shortcode-name="rebelmouse-image" />
Area in which trees were located
Credit: University of Copenhagen<p>As important as trees are in fighting climate change, scientists need to know what trees there are, and where, and the study's finding represents a significant addition to the global tree inventory.</p><p>The vegetation Brandt and his colleagues have identified is in the Western Sahara, a region of about 1.3 million square kilometers that includes the desert, <a href="https://en.wikipedia.org/wiki/Sahel" target="_blank">the Sahel</a>, and the <a href="https://www.sciencedirect.com/topics/agricultural-and-biological-sciences/subhumid-zones" target="_blank" rel="noopener noreferrer">sub-humid zones</a> of West Africa.</p><p>These trees and shrubs have been left out of previous tabulations of carbon-processing worldwide forests. Says Brandt, "Trees outside of forested areas are usually not included in climate models, and we know very little about their carbon stocks. They are basically a white spot on maps and an unknown component in the global carbon cycle."</p><p>In addition to being valuable climate-change information, the research can help facilitate strategic development of the region in which the vegetation grows due to a greater understanding of local ecosystems.</p>
Trained for trees<img type="lazy-image" data-runner-src="https://assets.rebelmouse.io/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpbWFnZSI6Imh0dHBzOi8vYXNzZXRzLnJibC5tcy8yNDU2MDQ3MC9vcmlnaW4uanBnIiwiZXhwaXJlc19hdCI6MTYzNTk5NTI3NH0.fR-n1I2DHBIRPLvXv4g0PVM8ciZwSLWorBUUw2wc-Vk/img.jpg?width=980" id="e02c0" class="rm-shortcode" data-rm-shortcode-id="79955b13661dca8b6e19007935129af1" data-rm-shortcode-name="rebelmouse-image" />
Credit: Martin Brandt/University of Copenhagen<p>There's been an assumption that there's hardly enough vegetation outside of forested areas to be worth counting in areas such as this one. As a result the study represents the first time a significant number of trees — likely in the hundreds of millions when shrubs are subtracted from the overall figure — have been catalogued in the drylands region.</p><p>Members of the university's Department of Computer Science trained a machine-learning module to recognize trees by feeding it thousands of pictures of them. This training left the AI be capable of spotting trees in the tiny details of satellite images supplied by NASA. The task took the AI just hours — it would take a human years to perform an equivalent analysis.</p><p>"This technology has enormous potential when it comes to documenting changes on a global scale and ultimately, in contributing towards global climate goals," says co-author Christian Igel. "It is a motivation for us to develop this type of beneficial artificial intelligence."</p><p>"Indeed," says Brandt says, "I think it marks the beginning of a new scientific era."</p>
Looking ahead and beyond<p>The researchers hope to further refine their AI to provide a more detailed accounting of the trees it identifies in satellite photos.</p><p>The study's senior author, Rasmus Fensholt, says, "we are also interested in using satellites to determine tree species, as tree types are significant in relation to their value to local populations who use wood resources as part of their livelihoods. Trees and their fruit are consumed by both livestock and humans, and when preserved in the fields, trees have a positive effect on crop yields because they improve the balance of water and nutrients."</p><p>Ahead is an expansion of the team's tree hunt to a larger area of Africa, with the long-term goal being the creation of a more comprehensive and accurate global database of trees that grow beyond the boundaries of forests.</p>
Water may be far more abundant on the lunar surface than previously thought.
- Scientists have long thought that water exists on the lunar surface, but it wasn't until 2018 that ice was first discovered on the moon.
- A study published Monday used NASA's Stratospheric Observatory for Infrared Astronomy to confirm the presence of molecular water..
- A second study suggests that shadowy regions on the lunar surface may also contain more ice than previously thought.
Credits: NASA/Daniel Rutter<p>Still, it's not as if the moon is dripping wet. The observations suggest that a cubic meter of the lunar surface (in the Clavius crater site, at least) contains water in concentrations of 100 to 412 parts per million. That's roughly equivalent to a 12-ounce bottle of water. In comparison, the same plot of land in the Sahara desert contains about 100 times more water.</p><p>But a second study suggests other parts of the lunar surface also contain water — and potentially lots of it. Also publishing their findings in <a href="https://www.nature.com/articles/s41550-020-1198-9#_blank" target="_blank">Nature Astronomy</a> on Monday, the researchers used the Lunar Reconnaissance Orbiter to study "cold traps" near the moon's polar regions. These areas of the lunar surface are permanently covered in shadows. In fact, about 0.15 percent of the lunar surface is permanently shadowed, and it's here that water could remain frozen for millions of years.</p><p>Some of these permanently shadowed regions are huge, extending more than a kilometer wide. But others span just 1 cm. These smaller "micro cold traps" are much more abundant than previously thought, and they're spread out across more regions of the lunar surface, according to the new research.</p>
Credit: dottedyeti via AdobeStock<p>Still, the second study didn't confirm that ice is embedded in micro cold traps. But if there is, it would mean that water would be much more accessible to astronauts, considering they wouldn't have to travel into deep, shadowy craters to extract water.</p><p>Greater accessibility to water would not only make it easier for astronauts to get drinking water, but could also enable them to generate rocket fuel and power.</p><p style="margin-left: 20px;">"Water is a valuable resource, for both scientific purposes and for use by our explorers," said Jacob Bleacher, chief exploration scientist in the advanced exploration systems division for NASA's Human Exploration and Operations Mission Directorate, in a statement. "If we can use the resources at the Moon, then we can carry less water and more equipment to help enable new scientific discoveries."</p>