An alternative to syntax extensions

One of the common criticisms made by advocates of scripting languages such as Python, Perl, and Ruby, of languages like Java is that programming in Java can be quite verbose due to the lack of syntactic support for things like maps. In Python, if you want to access a variable in a map you can do so with simething like:
In Java, you must use:
value=(ObjectType) map.get(“key”);
Java’s syntax is obviously more verbose, but Java advocates defend this verbosity on the basis that a language’s syntax should be as simple as possible, and the notion of extending the syntax to support a particular (albeit popular) type of datastructure is anathema.
This conservative attitude is understandable when one looks at a language like C++, which in many ways gleefully encourage the programmer to muck around with syntax, the result being that one practically needs to learn to interpret a new programming language every time they try to decipher a new developer’s C++ code.
So, what hope for reducing Java’s verbosity without falling into the C++ trap? Salvation may come from an unlikely source, the IDE. The notion that a developer might wish to have a more concise way to express and view common code structures and expressions is understandable, the difficulty comes when they must impose their syntactic preferences on others.
The solution? What if an IDE allowed a developer to define syntactic shortcuts which they could use, and which would be used in the code they are viewing, but which would automatically be converted to “vanilla” Java before being saved to disk.
This would afford most, if not all of the benefits of a more consise syntax, without the disadvantage of having to endure the ill-judged syntactic conventions of others.

Leave a Reply

Your email address will not be published. Required fields are marked *