jump to navigation

Java Growing? February 8, 2008

Posted by gordonwatts in computers.

I’ve mentioned several times on this blog that the lack of new features in C++ makes me nervous. I’ve not seen Java grow much either, but that may have more to do with the blogs I look at. I saw this on Gosling’s blog, the creator of Java (and many other things — like emacs):

Java feels alive, not stuck in some chisel marks on stone tablets. Closures were left out of Java initially more because of time pressures than anything else. Closures, as a concept, are tried and true – well past the days of being PhD topics. The arguments are in the details, not the broad concepts.

I am very happy to see this sort of thing. Programming languages should be living things.

Closures are a very cool concept, btw. They come straight from functional programming, and they make it very easy to design call-backs in complex systems. Basically, I can write the following (in no particular syntax of any language that exists today – that I am aware of):

int x = 0;

vector<int> junk;

… fill the vector of int’s junk with some values…

junk.foreach (doit (int val) { x = x + val; });

I define this inner function “doit”, which is passed as an argument to the foreach method of the vector junk. The foreach method calls “doit” for each value. And do it adds to x the value generating the sum. Anyone that has used STL and the std::for_each algorithm function knows the kind of pain it causes: if you have to maintain any state between each call you end up having to create an object. In C++ that is a lot of syntatic overhead. Closures almost totally eliminate that. I’ve used the C# language, which has closures, and writing this sort of code just flows from your finger tips – in C++ you have to fight to get the code to come out, your source files become huge, and you generate all these objects you never reuse.

Maybe someday soon C++ will have this as well. That would be sweet and would make STL a whole lot more powerful — and most importantly — easy to program.



1. hrivnac - February 6, 2008

Hi Gordon,
Groovy language (which I’ve mentioned in another place in your blog) already has closures. Nice example shows how to fill histogram from an SQL table:

sqlDriver = Sql.newInstance(“jdbc:mysql://localhost/Tuples”,
sqlDriver.eachRow(“select mycolumn from mytuple”) {

The full runnable example is here: http://hrivnac.free.fr/wordpress/?p=72

Scala is another Java-compatible language which supports closures (and more).


2. gordonwatts - February 7, 2008

Julius – thanks. I’d heard of Groovy and Scala, but I’d not explored them. This is one of the fantastic things about VM’s like the JVM and the CLR – it makes it so much simpler to build these new languages which are so much more productive than C++ (I think). I just wish particle physics would have seen the light previously.

And sorry your comment got held back, it seems my spam filter has trouble with code snippits.

3. hrivnac - February 7, 2008

Well, the light has been seen – by some – and hidden – by others.


4. gordonwatts - February 7, 2008

Ok — so the question is — given where particle physics is now – how do we get them in?

5. hrivnac - February 7, 2008

Short answer:
Write useful applications.
Examples from Atlas: Atlantis, Tag Collector, AMI,…
Examples from HEP: FreeHEP, jHepWortk,…

Longer answer:
Write useful applications + convince bosses to allow non-Root/non-C++ components. There is a big problem with CERN IT management: they have chosen to choose one framework/language and to boycot anything else.
The first choice was LHC++/Objy/IrisExplorer, the second is Root. The second choice is clearly better, but the main problem persist: bureaucratic
monopolisation. Any project capable of disturbing Root/C++ monopoly is illegal in CERN. There are many concrete examples: people are asked to remove their code from LCG repository because it is in Java, proposed presentations and tutorials are refused for the same reason.
Java is not the only victim, non-Root C++ projects suffer as well.

Many choices made by LCG (Atlas incl.) have been made just to lock us in the “chosen” technology: Root C++ dialect.At the beginning of LCG, there were some some (shy) attempts to make real modular architecture with abstract interfaces. Several RTAGs went in that direction. All that has been canceled. Java RTAG (yes, it was scheduled) was renamed to “future languages” RTAG and silently canceled later. Etc,etc

6. Weblog of Julius Hrivnac » Blog Archive » How to get HEP in Java ? - February 7, 2008

[…] contribution to the Java discussion on the Gordon Watts […]

7. Paolo - February 10, 2008

The next C++ Standard, due before the end of the decade, will certainly offer lambda expressions and closures. More generally, *a lot* is going on in the ISO C++ Standard Committee, as regards both the core language and the runtime library. In order to stay up to date, I suggest following this series of documents:


Also, the GNU C++ compiler, in the next releases (4.3.x series) will allow experimenting with some of the new features.

8. gordonwatts - February 10, 2008

Paolo, thanks! That is a great link. I’ll have to write a post about it when I figure out my date problems!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: