javax: Suggestion for Including New Language Features
For a while now, a lot of people have expressed a lot of opinions about how to keep the Java language up to date with other languages like C#, Groovy, Ruby etc etc. Some want features that they belive would make their life a lot simpler. Others see the same features as a problem that would make their life more complicated. The problem is simple, one solution can't never make everyone happy. Some people hate to type and therefore would like the shortest syntax possible, while other would focus on other problems that in their eyes dwarfs the gains with a short syntax.
The only solution that I can find for this problem is not to make everyone using the same solution but to allow programmers to choose if they would like the Java-language to work. In java (the libraries) we already have a solution for this. Packages that starts with Java are standard, while other packages that could be considerd more experimental are are named javax. I would therefore suggest a simular solution for the Java language. Files named .java are using the same old (slowly evolving) java as usual while those who like to live on the edge using files named .javax. .javax files could have a kind of import-statement for language-features that would tell the compiler what to expect in the file.
There are ofcourse several problems that must be solved. The most important is of political nature. Why should any company allow their programmers to use these new language-features? One solution could be that Sun packages some of these .javax features with the JDK as extensions that they would recomend of think could be close to inclusion to the standard java language.
The main point of the suggestion is to find a way to allow Java to evolve quickly without getting a bloated language.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)










Comments
Ricky Clarkson replied on Fri, 2009/03/20 - 5:23am
"Some people hate to type and therefore would like the shortest syntax possible"
Actually, it's more that we hate to read irrelevant code. Compare Java:
Runnable runFoo = new Runnable() { public void run() { foo(); } };
to C#:
Action runFoo = foo;
If there were people who actually wanted the shortest syntax possible, there'd be requests to get J syntax into Java. There aren't, so it's not that.
Jeroen Wenting replied on Fri, 2009/03/20 - 7:31am
Tracy Nelson replied on Fri, 2009/03/20 - 8:16am
What's the difference between that and someone deciding to use Spring or Hibernate or JPA or XML or any other "foreign" technology? I'm sure at one time or another everybody's gotten stuck maintaining someone else's toy "research project" (like a web service implemented as a JSP that just forwards requests to a CGI script written in Perl, just to flog a personal horror story). Language extensions are rarely as bad as what people can come up with to emulate them if they're not there.
Brian Diekelman replied on Fri, 2009/03/20 - 8:22am
in response to: jwenting
Mario Cormier replied on Fri, 2009/03/20 - 9:35am
in response to: d3ik
Mathias Ricken replied on Fri, 2009/03/20 - 1:37pm
Werner Keil replied on Sat, 2009/03/21 - 12:16pm
Artur Biesiadowski replied on Mon, 2009/03/23 - 4:14am
in response to: catmedia
Don't worry, investment banking is generally not interested in money class. Most of the work is done on doubles, some of fixed point offsets with integers/longs, some on strings and very very few on BigDecimal/Money-like classes. It is probably (I hope) different in private banking, back office accounting etc. But stay with javax.money.MoneyBloat objects out of derivatives.
As far as original poster is concerned - there is an idea of adding source/encoding keywords on top of files to allow extensibility of language
http://mail.openjdk.java.net/pipermail/coin-dev/2009-March/000249.html
Anyway, I don't think it makes much sense. If you allow something, you have to be prepared to deal with it, so you can as well add it to main language. If you don't want to add it to main language, use .scala or something similar :)
Brian Sayatovic replied on Mon, 2009/03/23 - 5:55pm
in response to: htowninsomniac
Robin Bygrave replied on Mon, 2009/03/23 - 7:48pm
in response to: abies
This makes a lot of sense to me.
This means that you can add a lot of new features (new keywords/syntax) without backward compatibility worries (or at least hugely reduced backward compatibility worries).
My understanding is that it is going to be rather difficult to add new keywords without doing something like this.
I think it would be different if scala say, was a lot more similar to java than it is... I think scala is almost a different mindset... and I think we need to keep the java language developing/evolving.
Ibrahim replied on Wed, 2009/03/25 - 6:21am
Tom van Breukelen replied on Wed, 2009/03/25 - 7:32am
hookfi replied on Sun, 2009/05/31 - 7:50am