Ted Leung on the air
Ted Leung on the air: Open Source, Java, Python, and ...
Ted Leung on the air: Open Source, Java, Python, and ...
Wed, 01 Oct 2003
Orthogonality vs Harmoniousness
Artima has an interview with Matz, the author of Ruby. I attended Matz's philosophy of Ruby talk at OSCON, and while I haven't fallen in love with Ruby, there's something about his approach to language design that's subtley appealing.
Here's an example. I've always taken it as a given that orthongonality is highly desirable. But on page 2 of the interview, Matz describes how orthogonality can be bad.
[01:32] |
[computers/programming] |
# |
TB |
F |
G |
2 Comments |
An example of orthogonality is allowing any combination of small features or syntax. For example, C++ supports both default parameter values for functions and overloading of function names based on parameters. Both are good features to have in a language, but because they are orthogonal, you can apply both at the same time. The compiler knows how to apply both at the same time. If it's ambiguous, the compiler will flag an error. But if I look at the code, I need to apply the rule with my brain too. I need to guess how the compiler works. If I'm right, and I'm smart enough, it's no problem. But if I'm not smart enough, and I'm really not, it causes confusion. The result will be unexpected for an ordinary person. This is an example of how orthogonality is bad.
The orthogonal features, when combined, can explode into complexity.This is going to require some pondering.
I tend to agree with Artima on this one. I have certainly gotten bitten in my C++ coding on this issue. I find that I am always looking at the headers and code to make sure I am using the right one.
Posted by Jim Adams at Wed Oct 1 08:28:05 2003
Posted by Jim Adams at Wed Oct 1 08:28:05 2003
I disagree with his definition of orthogonality. If the two features were truly orthogonal, then there wouldn't be an explosion of complexity. It's precisely because those two features aren't orthogonal that people get bitten by their interaction.
As an example of orthogonality, let's look at Python's list comprehensions, and the len function. Since they're (really) orthogonal, you can combine them to write:
x = [len(y) for y in otherList]
and get a list of the lengths of the things in otherList.
When you throw in the automatic type-promotion of C++, you can get some really strange bugs in function definitions, too.
Posted by Blake Winton at Wed Oct 1 12:01:38 2003
As an example of orthogonality, let's look at Python's list comprehensions, and the len function. Since they're (really) orthogonal, you can combine them to write:
x = [len(y) for y in otherList]
and get a list of the lengths of the things in otherList.
When you throw in the automatic type-promotion of C++, you can get some really strange bugs in function definitions, too.
Posted by Blake Winton at Wed Oct 1 12:01:38 2003
You can subscribe to an RSS feed of the comments for this blog:
Add a comment here:
You can use some HTML tags in the comment text:
To insert a URI, just type it -- no need to write an anchor tag.
Allowable html tags are:
You can also use some Wiki style:
URI => [uri title]
<em> => _emphasized text_
<b> => *bold text*
Ordered list => consecutive lines starting spaces and an asterisk
To insert a URI, just type it -- no need to write an anchor tag.
Allowable html tags are:
<a href>
, <em>
, <i>
, <b>
, <blockquote>
, <br/>
, <p>
, <code>
, <pre>
, <cite>
, <sub>
and <sup>
.You can also use some Wiki style:
URI => [uri title]
<em> => _emphasized text_
<b> => *bold text*
Ordered list => consecutive lines starting spaces and an asterisk