views:

502

answers:

3

Hi,

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

+1  A: 

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.

JoseMarmolejos
while rare,people do apply the term to programming languages as well.
Peter Recore
+8  A: 

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.

Bakkal
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
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
A: 

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.

Elf King
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