13

I am wondering if Java is orthogonal or not, and if yes, then which are its features that make it orthogonal. How can you determine if a language is orthogonal or not? For example, I found on some website that C++ is not orthogonal, but no explanations, why not. What other languages are orthogonal? Please help me, because there is almost no information on the internet about this topic.

Thanks

5
  • 13
    Please give a direct explanation or link to your intended definition of orthogonal.
    – Peter G.
    Jul 17, 2010 at 15:07
  • Orthogonality is rarely (if ever) a Boolean ("Is X orthogonal?") but a matter of (usually comparative) degree ("X is more orthogonal than Y.") Jul 17, 2010 at 15:20
  • 1
    but can programming languages be linear as well?
    – mvds
    Jul 17, 2010 at 15:58
  • should this question be tagged homework?
    – mvds
    Jul 17, 2010 at 16:01
  • Huh, and here I thought orrhogonal was a made-up term that meant the token was like pulling teeth. Oct 16, 2015 at 15:26

5 Answers 5

28

The Art of UNIX Programming, Chapter 4. Modularity, Orthogonality, Page 89:

Orthogonality

Orthogonality is one of the most important properties that can help make even complex designs compact. In a purely orthogonal design, operations do not have side effects; each action (whether it's an API call, a macro invocation, or a language operation) changes just one thing without affecting others. There is one and only one way to change each property of whatever system you are controlling.

Programming Language Pragmatics, Chapter 6, Page 228:

Orthogonality means that features can be used in any combination, that the combinations all make sense, and that the meaning of a given feature is consistent, regardless of the other features with which it is combined.

On Lisp, 5.2 Orthogonality:

An orthogonal language is one in which you can express a lot by combining a small number of operators in a lot of different ways.


I think an orthogonal programming language would be one where each of its features have minimal or no side effects, so they can be used without thinking about how that usage will affect other features. I borrow this from the definition of an orthogonal API.

In Java you'd have to evaluate for example if there is a combination of keywords/constructs that could affect each other when used simultaneously on an identifier. For example when applying public and static to a method, they do not interfere with each other, so these two are orthogonal (no side effects besides what the keyword is intended to do)

You'd have to do that to all its features to prove the orthogonality. That is one way to go about it. I do not think there exists a clear cut is or is not orthogonal in this matter either.

2
  • Yes, I understand orthogonality in general, but I cannot give an explanation why C++ is considered not to employ orthogonality, and how can you analyze it. I mean.. I cannot say that.. "Yeah.. Java is kindof orthogonal because public and static go together without any problems". I try to find something more general in these languages and there is nothing I can think about and there is no information on the internet either.
    – mbc
    Jul 17, 2010 at 15:44
  • 1
    I provided that as an example you cannot simply pick two features, you'd have to do that to all its features to prove the orthogonality. That is one way to go about it. I found two papers on portal.acm.org, one on general programming languages orthogonality and one on C++ orthogonality. I do not think there exists a clear cut is or is not orthogonal in this matter either.
    – bakkal
    Jul 17, 2010 at 15:54
3

Using the term orthogonal programming language is unusual. Typically, in computer science you are really talking about orthogonal instruction-sets. However, if we are to extend the meaning to the grammar of a language:

"...meaning [the language] has a relatively small number of basic constructs and a set of rules for combining those constructs. Every construct has a type associated with it and there are no restrictions on those types...." see ALGOL

Then we can assume that if not all instructions in the language can work on all datatypes will yield non-orthogonality. This however does not mean that the converse is true, that is to say if all language instructions do work on all data types, it does not necessarily mean that the language is orthogonal.

More formally, an orthogonal language would have exactly ONE way to do a given operation. Non-orthogonal languages would have more than one way to achieve the same effect.

Simplest example:

for loop; vs. while loop;

for and while are non-orthogonal.

3
  • Then again many programmers ignore the semantic difference between for and while loops. This is an issue not directly related to the orthogonality of the language itself, but IMHO a much bigger underlying issue, which demonstrates certain lack of grasp in basic abstract concepts.
    – Schedler
    Jul 17, 2010 at 16:04
  • I would say that while is "super" to for (in OOP terminology), or "contains" for (in terms of sets) in that any for loop can be expressed as a while, but not all while loops can be expressed as for loops. How does this impact orthogonality? I'm reading up on wikipedia, and, it seems that, since there are two ways of doing for loops... I dunno.
    – Thufir
    Nov 20, 2010 at 17:01
  • Actually this is considered Simplicity when talking about language evaluation Sep 8, 2013 at 21:22
2

Orthogonality is feature of your design independent of the language. Sure some language make it easier for you to have an orthogonal design for your system but you shouldn't focus on a specific language to keep your system's design as orthogonal as possible.

1
  • 1
    while rare,people do apply the term to programming languages as well. Jul 17, 2010 at 15:19
1

Orthogonality is not really a language feature as such, even though some languages have features that promote orthogonality (such as annotations, built-in AOP, ..). Regarding orthogonality in Java: I have written a little case study about this using log4j as example: "Orthogonality By Example" - you might find this useful.

1

Lack of Orthogonality in C:

  • An array can contain any data type except void
  • Parameters are passed by value but array are passed by reference

A programming language is consider orthogonal if:

  1. there is a relatively small set of primitive constructs that can combine in a relatively small number of ways to build data and control structures

  2. every possible structure is legal

For example a language with 4 primitive data types (Int, Float, Double, Char) and two
type operators (Array and Pointer) can create a relatively large number of data structures.

So the advantage of orthogonality is to make the language simple and regular because there are less exceptions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.