views:

133

answers:

6

It is really annoying that each programming language has its own vocabulary. For example, in Java we have

if ... {}

yet in Bash script we have

if ... then ... fi # using "fi" is so insane for me

It would be really nice if all programming languages shared the same vocabulary. The language designers could then define the underlying semantics. I wonder if there were any attempts to build such a vocabulary?

+4  A: 

No, for the very same reason all human languages don't share the same vocabulary: Vocabulary and semantics serve specific niche needs. Hebrew has more than 20 words to describe harvesting (A unique word for each fruit, cereal and vegetable!); Arabic has a few dozens for camels, and so on.

Computer languages are much alike. bash emphasizes some features (e.g. short commands, immediate execution of os commands) while Java emphasizes other features (e.g. clear object hierarchy). These emphasizes are materialized using different semantics and vocabulary.

One could argue that there can be an automatic translator that would take a program from one language and translate it to another. Although it is theoretically possible (for all turing-complete languages), it might be extremely tedious due to subtle differences between the meaning of a command in one language and its meaning in another. For example, the meaning of the if keyword might vary slightly between the aforementioned languages, especially in case of errors and unexpected input.

EDIT: Following the comment: I have chosen another example, as it seems that Inuit languages does not exactly have hundreds of words to describe snow, just lots of adjectives.

Adam Matan
http://en.wikipedia.org/wiki/Eskimo_words_for_snow :-)
paxdiablo
Just a tiny nitpick. Regarding the Eskimo words for snow meme, read this (among many other accounts): http://users.utu.fi/freder/Pullum-Eskimo-VocabHoax.pdf
siride
Corrected to an example I know personally: לקצור, לגדוד, לארות, לבלוס, למסוק, ללקוט, לפרוק, לרדות and many other describe harvesting of a specific crop in Hebrew.
Adam Matan
+2  A: 

Just be glad they all (or large majority) use latin alphabet, unlike human languages. ;)

Mchl
A: 

Even in simple cases like the if statement it would not be viable. Some languages can use "statement if condition" clauses, for example, that may be not viable in bash. Consider then pradigm specific sematics (classes, functions, predicates....) it goes deeper than vocabulary.

Julio Faerman
A: 

Well, IBM had a product, Visual Age Generator, which had a common language which was then 'compiled' to everything from C under UNIX to COBOL on the mainframe. I think it's well out of service now and there may have been other attempts that don't spring to mind immediately.

However, the whole point of having different semantics is because languages are different, otherwise there would be no reason to choose Java over COBOL or Ruby over BCPL.

And fi was a brilliant idea. To have a different ending word for each construct greatly eased the parser and allowed greater error checking. In other words, if had fi, case had esac. The only thing I _don't like is that do uses done rather than od :-)

paxdiablo
A: 

There are many languages which have adopted conventions from 'C' (C++, C#, Java, Javascript, Verilog, etc). I am not aware of any effort at any formal convergence.

If you look at the kind of minute stuff language design/standardisation processes get bogged down in, I don't think that industry-wide efforts to homogenise things would ever come to much.

It does seem that modern languages put together by groups of thoughtful intelligent people try to borrow as much from their heritage as possible. Not all languages are created like this, though...

Will Dean
A: 

No, but you can create a 'Hello World' app in any language.

Ed B