Thursday, August 19, 2010

Why Brevity Matters

If you are used to a mainstream language like C# or Java, your introduction to Io will feel like meeting a woman from a spy movie: seductive but also dangerous. Mainstream languages coddle the programmer and take power away from the hacker. They are designed for corporate use, and businesses enforce conformity over productivity. To ensure this, the designers of blub languages limit the meaning of language constructs to a predefined few things and guard every abstraction with syntactic boilerplate. The cost of this overabundance of caution is cumulative: everything takes more code.

Io feels dangerous because all the guard rails are gone. Io allows you to express complex ideas with short code and extend its semantics without calling out your extensions with syntactic boilerplate. Why does this matter? Because in coddling languages that do not allow you this, frameworks and design patterns spring up to fill the gap. This is why these languages have so many frameworks. The trouble is such languages will never really allow to say anything as succinctly as you might like, so just invoking and combining elements from the frameworks themselves takes enough code that the calling code may also need to be abstracted. The alternative is long functions that are too big to fit on the screen or in your head. Yet whether you sweep the cruft under the rug of a framework or leave it in an open pile, it's still the same amount of cruft, just pushed around. Much effort is expended and endless ritual code devoted to the boilerplate rain dance, but the process of programming itself never optimized beyond a local minimum. That is the hallmark of corporate programming.

This is why brevity matters: it is prerequisite to advancing the art of programming past the rut it is stuck in. Every unnecessary keyword stands between you and what you really mean to say. If a language has irreducible syntax no amount of abstraction can allow you to express yourself more succinctly than the atoms of that language. Io is disruptive because its atoms are smaller. It is dangerous because the meaning of those atoms is in the hands of the programmer. Embrace danger and write shorter code, and you will taste freedom.

5 comments:

  1. What about J? Brevity is fine and dandy but it helps if you can read what you wrote. I find Python to be a great compromise.

    ReplyDelete
  2. WHY VISIBILITY MATTERS

    If you expect people to read your stuff, you have to avoid making it difficult to read. Lose the color scheme.

    ReplyDelete
  3. Thanks Tim. I've changed to white text and lightened the background (less contrast might be easier on the eyes). Is it an improvement? (I already have a blog that's black text on white background and I was bored with that color scheme, so I'm experimenting with light text on dark backgrounds.)

    ReplyDelete
  4. @Pavel: Well there are two related concepts, let's make sure we have them straight. There's brevity in terms of having short keywords or just using symbols, which at its extreme could lead to a language that consisted of nothing but symbols (it's been done). Io is not that type of language.

    What I'm talking about is a more nuanced idea, which is that of being able to do things using few wordlike-elements, and very little punctuation. The kind of brevity I believe is Io's strong point is not that of being able to pack a lot into a short line (heck, you can do that in C!) but being able to define one or a few words to do something meaningful. That will become more clear when I talk about Io's 'do()' method in a future post.

    I'm glad you asked, what about being able to read what you wrote? This is the point: in languages like Java readability is enforced by the designer by limiting how far you can extend the basics of the language to do what you want. In a language where you have more power, it is up to the programmer to ensure that the language extensions he creates are meaningful and readable. It would be a fallacy to say that if the language doesn't enforce readability that it necessarily follows that unreadable code will be written.

    As for Python, I don't really know it well but it looks like a fine language. However. There are many blogs about Python. Here I'm writing about Io, because there aren't many (any?) other blogs devoted to Io.

    ReplyDelete
  5. There is a series of very good posts about IO at Cliff's blog.

    ReplyDelete