MC logo
[^] Ch. 1: Overview and History
[Ch. 1: Overview and History] [Syntax] [Names and Scope] [Types and Type Systems] [Semantics] [Functions] [Memory Management] [Imperitive Programs and Functional Abstraction] [Modular and Class Abstraction] [Functional Programming] [Logic Programming]
[Orthogonality] [Binding Examples] [Tucker and Noonan's History Figure]
This is one of the slipperier terms we throw around in class. It refers to how well the features of a language combine with each other. Generally, orthogonality avoids having special cases and exceptions. For instance, if arrays combine orthogonally with the rest of the type system, the language allows you to create arrays of any type. Most languages allow this, or only forbid a few obscure combinations. On the other hand, the perl language does not allow an array to contain another array, which violates orthogonality.

A plain C struct can contain variable declarations, but not functions. C++ allows functions in structs, which conforms better to the idea of orthogonality.

A Java variable declared Object x can be assigned any class type, but not basic types. Like most any rule which contains the word “except,” this one violates orthogonality, since some combinations are forbidden.

Most languages limit the types which can be used as array subscripts to integers and a few simple types. Likewise, most languages which have a switch or case control structure limit the test type to integers or other simple types. Both of these rules violate orthogonality.

Orthogonality suggests any variable should be allowed to be on the left of an assignment, presuming the types match. The C and C++ languages forbid arrays to be assigned.

Of course, orthogonality isn't the only virtue. For instance, the limits on subscript type make subscript calculation simpler and faster.