CSC323 2010S Software Design

Beautiful Code: Treating Code As An Essay

Matsumoto, Yukihiro (2007). Treating Code As An Essay. Chapter 29 (pp. 477-482) in Oram & Wilson (eds), Beautiful Code. Sebastapol, CA: O'Reilly.


Ruby has come up a few times in this book. Is this representative of its popularity in real life? Is it worth learning as another scripting language in addition to Python?

As each new programming language may help you think about problem solving in a different way, it's often worth learning another language. Ruby seems popular among the elite hacker crowd, and there's some evidence that following practices of that crowd is helpful.

From what I've found hacking seldom creates beautiful code.

It depends on what you mean by hacking. To many, a good hack is beautiful.

Brevity may decrease the amount of code that is needed to be read, but wouldn't it also often result in increased complexity (which humans don't like), causing reduced readability? (As an extreme example, obfuscated C code is typically very succinct, but not very readable or beautiful.)

In part, it's the intent. You can try to write clear short code. Of course, even code that should be clear can be hard to read when short. We've seen a bit of this in Scheme. Lots of use of sectioning and other higher-order techniques makes concise code, but it takes a lot of practice to read it. Consider (l-s l-s l-s).

I find it interesting that we read this section along with the Extreme Programming text, since the author seems to advocate for a more conservative approach (or says that humans are more likely to understand and gravitate towards such an approach) to programming. However, in the spirit of XP's stated goal of reducing waste, much of what the author discusses makes sense for this specific purpose - that is, if all you want to do is print a statement, certain tools and languages are obviously much easier and less wasteful than others.

Also isn't this code more about development?

In some cases, brevity forces the person reading the code to make inferences. If these inferences cause misunderstandings, wouldn't errors caused by the misunderstandings negate the benefits brevity was intended to create?

From page 479 of Beautiful Code: "Although relying on IDEs to input information has become popular recently, these tools are not intended to help interpret meaning." I'm not sure what the author is implying by this. Is the use of IDEs to blame for redundant code? Also, he says that rather than using supporting tools to create elegant code one should choose a more elegant language; I don't know why you couldn't do both. My sources at wikipedia tell me that some IDEs have support for those languages praised for their beauty, python, ruby, etc.

Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Thu Apr 8 11:41:01 2010.
The source to the document was last modified on Tue Mar 16 09:17:47 2010.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CSC323/2010S/Readings/beautiful-29.html.

You may wish to validate this document's HTML ; Valid CSS! ; Creative Commons License

Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright © 2010 Samuel A. Rebelsky. This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc/2.5/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.