I kind of want to do something different today. When I write I tend to write, in cliche blog form, in two modes: “Hey, look at this!” or “I’m going to be snarky and rant about this!” Today, I would kind of like to have a narrow conversation.
The advent of the invokedynamic JSR, as well as the continuing RoR vs whatever hype and framework proliferation in Java has brought a question to the forefront: where is Java going? I have some ideas that I would like to express. This isn’t necessarily a highly structured treatise, but more of a braindump.
However, I would like to hear what other people would like to see. I don’t mean this as an exploration of other programming models or an academic conversation in language design. Rather I would like people to look at (a) what tools are they using all the time that should just be there, and (b) what would really make your day to day life better, both of these taken in terms of the JSE — lets leave the web framework wars out of this for a little while.
One of the things that was just gawd awful was an idea floated a while back for integrating XML at the language level. You might have seem this discussion about API enhancements in Dolphin. I think there are some good ideas there, but it bothers me that the XML is dealt with as Strings. What we really need is something akin to JDOM there. That is a W3C compatible object model that is loose bound and easy to use. There have also been much more radical ideas floated, such as support actual tags IN the .java files as initializers and constructors.
My problem here is something much more fundamental, however: Java needs help with datatypes and method signatures. Cedric kind of touched on this recently though in a completely different context. Things like bound integer values have more uses than just performance in constrained systems: they help make the Java definition model closer to the XSD system. The problem with Java right now, especially in terms of XML mapping, is there is no way to constrain, for instance, a String value to a certain length or a RegEx match, or an Integer to a certain range, while XML Schemas provide for this. This means than any back and forth mapping of data really has to be started with the Schema as authoritative, and I really dislike this.
Moreover, method signatures do not provide means of giving schema hints for web services, and even a good “design by contract” ideology in the code. “public void doSometing( Integer foo, Integer bar )” has no indication that a null is allowable for bar, but not foo and Foo has to be between -4 and 27. Moreover when this gets translated into a SOAP call, there is no way for an Schema generator to make these determinations.
Now, annotations DO solve some of this problem, especially at the metadata level for back generating stuff, however, annotations don’t actually give you anything at the language level. Moreover, the finality of the java.lang types means that you cannot provide backward access to code if you created new types. This is the kind of thing that really does need to be in at the language level, and tighten up the signatures and datatypes.
The next thing I would like to talk about is the JRE itself, and from there I will spiral off into a couple of different areas, including my poo pooing of invokedynamic.
The JRE sucks. Really. Don’t get me wrong, I know that Mustang is faster (and I do find it funny how nobody bashes Ruby for being slow like they have Java for years). The problem is the JRE does too much, has too much legacy stuff in it nobody cares about in new software, and lacks things it really needs. To this end, I think the JRE needs to be broken out into 3 different distributions:
- A Classic or Server JRE that has everything.
- A desktop application JRE, perhaps just packaged and branded WebStart that includes what you need for most desktop apps, with some changes. Cut all the CORBA code and SOAP clients. Add Gecko as a JRE supported component. A binary repository system that is more Maven and less (like the current) WebStart.
- A slim JRE that runs as a system-service level. It could share the binary repo with the desktop, but it needs an intelligent download-as-needed jar system. It needs to start in less than 3 seconds on the average low-end desktop. This is an Applet runner and external call system. Basically, there is no reason Applets can’t perform as well as Flash. The second part of this goes to something I will talk about in a bit.
There are a few points here that seem to me to be critical to Java development.
First, applets need to be viable against Flash. This means they need to start fast; they need to download additional jars from the server on a JIT basis; they need better media support and access to devices for which Java now kind of sucks (see: CCD cameras, microphones, USB widgets — how old is the javax.usb JSR now?). For this I say executing them all in a persistent runtime environment, rather than an isolated JRE is the best case scenario — unless the Applet demands more than the standard limited sandboxing. Mostly, though, people want to use applets to provide things that a browser can’t — DnD, better comms, etc. I would also add to this system service a persistent applet runner application comparable to Dashboard, SuperKaramba or Konfabulator. This isn’t a great leap forward, but it would put a little of the sex appeal back in applets.
Second, this persistent Java runtime needs good hooks for external coding and code execution. SOAP is nice, CORBA is… well.. CORBA, but there is no reason the average little app needs this to make calls into Java. There are two points here, I will go with the more mundane first, then I will anger some people.
The first point of this is if Java applications are going to be a first class citizen on the Desktop then they need to work with the other desktop apps. MBeans should show up as COM automation components; they should show up as Apple Automator elements; they should show up as DCOP providers. We have all kinds of stuff right now — JNI is mediocre, Com4J is pretty slick and KDE-Java works OK. However, all of these are, for lack of a better description, outbound. A Java application should be as integrated with desktop tools as other desktop applications.
The other half of this goes to why I *hate* invokedynamic: let us not pretend that Ruby or Python people give a [expletive deleted] about being “first class citizens in the JVM. Ruby on JVM will never be “real” Ruby. Python on the JVM will never be *real* Python. Don’t believe me? How many Java people out there really care about IKVM? Do you really want your Java to be running in the CLR? No. What we need is an inbound call system that lets these other languages execute Java in the real Java runtime and execute their own code in their own runtime/interpreter. What Java really needs is a better external system for integrating with other APIs in the proper way.
Next on my rant list is SWING. Josh Marinacci is a friend of mine and he listens to my rants on this topic more than he would care to, I am sure. However, for all SWING is powerful, it is lacking in major ways that really matter to most developers. First, it lacks a real framework. Most of the reason people think Java apps are “slow” is because people write bad Java apps. However, people write bad Java apps because it is EASY too. For all the Matisse editor and the new Layout manager makes creating a good looking SWING app easier, even if you are using NetBeans, it doesn’t provide a framework for separate UI threading, which makes UI response feel bad as comms and processing is down inline. Secondly, all these years after the JavaBeans spec, SWING still doesn’t have a decent databinding system, nor is it in general Collections aware. Next to things like Flex and Laszlo, this is a killer in the “RIA” space. Lastly, UI needs to be declarative, not programmatic. Avalon and Sparkle are truly awesome. XUL is really nice. Even ObjC/XCode on the Mac with its “freeze dried” objects is not bad. Next to all of these, SWING has an Everest-style learning curve to work with proficiently.
Next, we should be able to create a Dynamic Proxy off an Object class. This seems a little more academic than I want this discussion to be, but giving this ability would require a lot less invasive changes to the language than invokedynamic but would allow Java to see RoR style frameworks.
Finally, JNDI needs to not suck. Really, looks at what Spring does in terms of factory providers, configuration and service registries. There is no reason for it, except everyone has always hated the JNDI interface. Perhaps we just need a whole new system here, rather than overhaul JNDI, but we need something that knows how to get SOAP services, use basic factories and handle some basic config stuff without the LOC overhead than JNDI always seems to have. EJB3 takes a big step forward on the J(2)EE spec. JAX-WS is a bid step forward for web services. It is time for javax.naming to get some serious love.
This isn’t a really well structured list of things or particularly well correlated, but it does represent my wish list for Java in small, discreet quanta. Now the question: what do you wish Java had, or alternately, why am I a moron?


Regarding limiting values - why not just subclass String, Integer or whatever you need? Why change the language or use annotations, when object oriented programming solves this easily?
In C# forks can do something like:
[MaxValue=3]
int I{ get{return i}};
which i think is awesome.
You won't get better integration with native systems, since that would reduce Java from a platform to just a programming language.
If Java is used only as a neat programming language to interact with native components, then Sun can not sell you big sparc servers when you need to scale up, so they don't make money.
cheers,
dalibor topic
Regarding limiting values - why not just subclass String, Integer or whatever you need? Why change the language or use annotations, when object oriented programming solves this easily?
All the basic types in Java are final.
with it’s “freeze dried†objects --> with its “freeze dried†objects
I've had the very same thoughts as you do on the JRE, Swing and JNDI. And definitely for some sort of Maven-JavaWebStart like repository to make runtime library management easier. It seems there is a lack of vision at Sun for Java. On XML language integration... it is not clear where you stand on that. I think that XML language integration (such as like what E4X does for JavaScript) is a very good thing. XML is perhaps the most important markup language and so for that reason I think it is a good idea for languages to have more native support for it instead of just libraries. And on XML Schema... it's true that Java doesn't have the constraint system that XML Schema has but I don't think XML Schema should drive languages to add compatible constructs. XML Schema enforcement is something that I think should be done as is done today--implemented by libraries.
~ dsmiley at mitre dot org
On a side note, gcj already offers you the 'JVM as a system service' option, as you can compile your bytecodes to native, run gcjh to create CNI headers for them, and then happilly call you Java code (now sitting in nice shared native libraries) from other languages, like perl, python or ruby. See PyLucene for how to do it python, http://search.cpan.org/dist/GCJ-Cni/lib/GCJ/Examples.pod for how to do it perl, http://jakarta.apache.org/poi/poi-ruby.html for how to do it in ruby.
Much, much better than dealing with a JVM in the first place.
cheers,
dalibor topic
> why am I a moron?
you are a moron because:
(1) "The JRE sucks" the JRE download size is fine, the speed is good too. Different profiles for very specific apps make sense, but you must have seen the slides about JRE size from JavaOne - its bang in the middle of the scale for various popular (real world) consumer downloads
(2) Although some kind of native structured data support in Java is worth investigating, bounded integer ranges, and Strings bounded by regex are too trivial to be motivating examples. If you are going to add native structured data support to Java, then it may as well be xml?
(3) "we should be able to create a Dynamic Proxy off an Object class" - occasionally I come across situations where I want to do this too, but normally as a quick fix. Given a bit more time, I revisit the application architecture and see what should have been done differently. Its not always something that can be fixed, but adding a new feature (multiple inheritence anyone) that simplifies some rare cases, and will be abused by many more people than use it properly, is surely not a good thing? (I'm all for language designers being proscriptive in their decisions)
(4) "Do you really want your Java to be running in the CLR?" why not? (if it works - Microsoft should license the TCK). Seriously, IronPython was getting very good benchmarks on the CLR before Microsoft employed the developer and it stalled. Wonder what he's doing?
Well, If It Ain't Broke Don't Fix It. Avoid hype and framework marketing (smoke and mirror).
> If Java is used only as a neat programming language to interact with
> native components, then Sun can not sell you big sparc servers when
> you need to scale up, so they don't make money
Such simplistic-black-and-white views are usually incorrect.
BTW, what's the value of using opensource like "gcj already offers you the 'JVM as a system service'", does anyone use in production environment?
I mean having something done is very different from being stable enough and 100% compatible. I still remember the Linux hype days, a bunch of unfinished software portrayed as "the end Microsoft", only when some companies started adding some value to it, like Red Hat or IBM, it became useful for things greater than webservers.
Since then I have some caution with hype, specially coming from opensource folks.
1. JDOM? Puhlease. That's like XML for dummies. Start with something like dom4j for the beginnings a real XML framework. It has some stuff you don't need, but it's very powerful.
2. (Oops). Metaprogramming can *never* fulfill DBC. The fact that it's being used for DBC is a great initiative, (apparently on several fronts), but if Java really wants this, it will have to step up to the plate with new language constructs.
3. Scripting languages on the JVM *will* happen. the scripting JSR is gonna enable this bigtime, and it will be an exciting evolution. You can consider it a new step in Java evolution. Who cares if Ruby doesn't show up to the party. That pos language is just a flash in the pan anyway. Python, however, please come over, let me serve you a glass of wine...
>Lastly, UI needs to be declarative, not programmatic. Avalon and >Sparkle are truly awesome. XUL is really nice. Even ObjC/XCode on the >Mac with its “freeze dried” objects is not bad. Next to all of these,
>SWING has an Everest-style learning curve to work with proficiently.
huh, u think that swing has an everest-style learning curve, others like me don't.
& y don't we use html for swing ui if UI needs to be declarative, not programmatic.declarative approach just *****.
I've amazed that Design-by-Contract still is only provided by 3rd party vendors and has yet to make it into the language itself. At a very minimum, having a JSR that would at least define a common set of annotations so that one doesn't have to be forced into a proprietary implementation would be helpful.
What? No my web framework is better than your web framework??? Sounds like you have given in and think RoR is going to win. In which case you are in for a treat - Grails is the Java answer to RoR. It uses the other official programming language of the JVM Groovy which is an agile language that plays well with your jvm objects written in Java.
The Grails web framework plays well with spring and hibernate so you can plug-in your existing services and hibernate object written in Java. You can also easily write a service to delegate to your EJB session beans with no hassle and inject it via spring to leverage your existing Java investment. I think that is where Java is going to go. Lighter, faster, agile, less 'big framework' code sticking out all over the app. Write your core components in Java and script them with the loosely typed jvm language groovy wherever you can. Also why use an xml config file why you can use a .groovy file that scripts the configuration of your Java internal components as the container comes up by calling their methods directly? Why not unit test with groovy http://www-128.ibm.com/developerworks/java/library/j-pg11094/ to make writing tests more fun?
I agree with you that GUIs should be declarative not programmatic. Anyone that has worked with a declarative UI technology would not touch swing with a barge pole. Any programmer that can build great SWING apps is wasted writing a GUI. They should be writing core business component code and let a designer that can script a little do the UI with a declarative technology.
If you want to see what is really hot with Java and declarative UIs check out ZK which happens to be an mind blowing web framework also. It does not use flash or applets - it outputs d-xhtml or xul depending on the browser and fires events over AJAX back onto the Java objects running on the server. No plumbing or thinking about the http incidental objects is required.
Someone should either sort out a decent XUL framework for rich java apps or fix the mozilla-java bridge so that the desktop space can finally be invaded by java.
What is a Applet again? It rings a bell but I think that it was just another one of those things that you had to learn to pass the exam but you instantly forgot about as it was as dead as a Dodo even back when you used to sit exams...
XML language integration? xml is for documents not for constraining variables. if you would like to see a feature to handle documents better than perhaps a 'document here' feature for java source code would be nice as exists for bash and php e.g.
$mydoc
i dont like is that you have to bundle the whole JDK you cannot just ship a part of it. i think that greatly limits the ability to get it onto the desktop. big fat downloads are not inviting to users. it would be much better if as you suggest the default install is was a mirco edition with just a small core of code - then when you try to run a new app it would see what other core libraires the app needs and pull those on demand. webstart is a smart technology which can be adapted to extend its release technology to the core runtime. i also agree that java should play better with dom, dcom, xpcom, corba, mozilla, et al. if folks want to call native services then that should be up to them. it should be a trivial task to bridge JMS to MSMQ on a windows box by instantiating the MSMQ com objects via automatically generated Java wrapper classes. when Sun saw Windows as trying to invade its market server share this looked very risky. given that what Java actually needs to invade the Windows desktop share to break out of its current server silo such a feature would really level the playing field. if the interoperability was by-directional and worked for mozilla xpcom also then you might start to see loads of cross platform mozilla xul desktop that have core business components written in java start to invade the desktop. instead the current big new hope of opensource on the desktop is novell's opensource implimentation of C# and all its runtimes called Mono. how sad is that that there is no java version of Microsoft Outlook with a big market share. even sadder that the big push on the desktop in Linux is Gnome and it is backing C# not java. lets just face facts. sun "dont do desktops" anymore. i guess it should not really come as a shock that opensource on the desktop is following the windows clone of java not java itself. it would take a massive push by sun to reverse this trend.