Preview of Java 1.5
gafter writes "An early access prototype implementation of
the proposed new J2SE 1.5 language features is
available. The prototype includes
generics (JSR 14),
typesafe enums, varargs,
autoboxing, foreach loops, and static import
(JSR 201). In other words, all the new language features
planned for 1.5 except
metadata (JSR 175). The
prototype includes full sources for the compiler,
written in the extended language. You can download the prototype from
java.sun.com.
It requires J2SE 1.4.1 and provides some examples of how to use the new language constructs. The prototype includes an experimental type
system (variant type parameters)
for Generic Java that is being considered
for Tiger (1.5) based on a paper by
Igarashi and
Viroli at ECOOP 2002 .
Comments and votes for the new type system are
being gathered at
bugParade."
Some of these things are certainly nice (typesafe enums...) - but wouldn't it be nice to try and keep the java language *simple*? There are iterators for doing stuff like foreach-looping ... varargs? Why? It is an object-oriented language - take use of that polymorphism!
Surprisingly (!!!) all the things C# had (or will have - generics) that made it superior. This is going to be fun seeing these two compete. So far I am on the C# side but who knows :) this is really fun.
While, as a java developer, I'm looking forward to most of these changes, I'm a bit afraid that java may lose it's positions as simple OO language which can be used for teaching in schools. Java was originally built with idea that you can read every java program in the world without problems. A lot of expresive power was sacrificed because of that - most notable preprocessor (to avoid people designing their own 'languages' for each project and library, as it is done in C).
Anonymous inner classes was first major ugliness which came into language - not very clear, hard to explain to a newcomer. But with all these new proposals, significant complexity is added to code in terms of visual overview. This is not critical for developers - perl hackers are faring very well, despite of having language 10 times as complicated as java as far as syntax is concerned - but pure-OO, java-is-new-pascal-for-algorithms academic society will probably start looking for a new language soon... (ok, maybe not really 'academic', I'm thinking more about secondary-level school programming basics).
You could troll and say that Java has finally caught up with where C++ was better than a decade ago. .Net onslaught. Good luck, Java.
More constructively, maybe the implementation will improve on things from all that time and experience.
Java is the best defense against the
Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
As a "weenie who can't handle pointers" I take Java's slowness very seriously. I wish that a better method could be used to process Java programs because I believe that future high level programming languages are going to be modeled around Java. PHP certainly is being modeled around Java. Am I the only one here who'd like to some day be rendering serious 3d graphics through Java? I think the language has potential and I don't just shrug off its slowness as an inherent property, I want it to improve in that respect too.
You're right, I wouldn't steal a car. But if it were possible, I sure as hell would download one!
I've pretty much stopped using Java. Sun has broken their promises when it comes to making Java an open standard (and, in fact, they have several patents on core Java technologies). And technically, even with these additions, Java 1.5 is still behind C# in several important areas (native code/data interfaces, genericity, support for numerical computations).
.NET, and Mono have a chance if Microsoft doesn't shoot themselves in the foot with stupid legal threats against open source projects. Otherwise, there are plenty of other languages; the choice isn't just between Java and C#, you know.
Also, after trying to live with it for years, I have concluded that "100% pure Java" just doesn't meet my needs. "99% pure" is good enough for me: it means that porting is easy, but the last 1% of platform specific code is what makes the difference between applications that merely run and applications that integrate well with each platform.
I expect Java will continue to survive in some niches (most notably, bloated web services implementations), but Sun has largely missed the boat when it comes to creating a general-purpose programming language: it's too little too late technically, and they have annoyed too many people. I think C#,
It seems to me that languages like Java and C# really don't need them.
...because there's nothing like running a 2kb calculator and a 2kb notepad and both have them run on separate 10-15mb VMs. That is a real drag for any non-monolithic use of Java (yes I do know of servlets etc.)
Kjella
Live today, because you never know what tomorrow brings
JSR 201 says nothing about "varargs".
Sounds like they are adding a lot of features that the Dylan programming language has had since it's release (approximately 1995).
But whereas the features were elegantly incorporated into Dylan since the beginning and are consistent and easy to use, I suspect that in Java they are a hack.
Wasn't Java designed to be a simple language?
It's correct to say that the start-up time for JVMs is a concern (more so than actual Java execution speed) but fortunately things are getting better in this respect. Java 1.4.2 (which is in beta at the moment) has made some significant improvements in this area.
Suck figs.
These additions seems to put Java on par with C#, but to make a quantum leap in expressiveness you need a dynamically typed scripting language.
Most applications these days can be written in higher-level languages, resulting in 5-10 times less source code compared to Java/C#, and making them correspondingly simpler to code and maintain.
Java doesn't really have a kick-ass companion scripting language. In MS world, VB plays this role. VB is really popular, but (I think most people would agree) a crap language and not really that high level. JavaScript just doesn't seem to cut it (pretty much only used in browsers).
Why doesn't Sun take a hint and phase JavaScript out in favor of a powerful multi-purpose high-level language like Python or Ruby? That'll put them miles ahead of Microsoft in terms of increasing programmers' productivity... and programmers' quality of life.
Don't know about JBoss, but Tomcat is a breeze; untar and start it up; you can start drop in webapps straight away.
Now, if you're talking about a secure, robust Tomcat installation, using apache httpd to serve static content, well, that's another matter.
Tomcat is for one of the examples of the success of Java code married to the Open Source model; Sun likes Tomcat becuase they farm out RI work for the Servlet and JSP specs, leaving engineers to concentrate on, well, coming up with more convoluted specs. Sun and its ISVs neither can or want to make any money on a pure Servlet container + JSP implementation.
J2EE, on the other hand; well, Sun hates JBoss, as it is eating to ISV revenue and Sun can't create a monoculture around Java (as Microsoft has very successfully with Win32) if someone is going to give implementations away for free
Please remain calm, there is no reason to pani... wait, where are you all going?
foreach isn't really redundant. It just gets used a lot when it shouldn't be used. If a type can easily be iterated-over with a standard for loop (for(i=0; i < obj.count; i++) { }) then you shouldn't use foreach. In .Net, at least, the iterator version is somewhat slower.
foreach is designed for cases where you can't simply use an index (i.e. obj[i]), such as a hash table or a linked list. In these cases, you need some kind of state for your iteration -- hence, an iterator.
While you can implement some kind of iterator without language support, language support in this case helps simplify the code. Instead of implementing the iterator yourself in your way (how many ways can this problem be solved?), you use the language-supported way. Much cleaner.
Syntactic sugar is bad when it leads to many ways to do something, but good when it simplifies the common case. I think iterators do this as long as they aren't used inappropriately.
Time flies like an arrow. Fruit flies like a banana.
Most major corporations who are planning on moving to Linux if they have not done so are cancelling and puting their plans on hold thanks to SCO.
If you use mono at work assuming its mature enough and ms pulls a sco you can kiss your linux workstation goodbye.
According to MS halloween documents, legal fud got a negative response form %80 of all bussinesses.
http://saveie6.com/
I program Java for several customers, from scientific to business apllications.
Autoboxing is yet another way of hiding overhead; the wrapper classes still exist, but are now a big "secret" masked by autoboxing.
Why add autoboxing to make containers look more "natural with POD types, then ignore the crying need to operator overloading in scientific and engineering applications? Why one piece of syntactic sugar as opposed to another?
Overall, I'm not terribly impressed. The new generics seem weak; I don't see an emphasis on fixing bugs, stability, or independent standardization. Much as I like Java, 1.5 does not address most of my needs.
All about me
Java is NOT slow. For numerical work I use IBM's JVM which has occasionally given me BETTER performance that optimised C++. Sun's 1.4 VM is typically 10-30% slower than C++ in most cases, I find.
Even a slight performance hit is well worth the safety and security of Java. Many products and companies were wrecked through the use of C++ as a development language in the late 80s and 90s, as a result of buffer overlow and pointer bugs.
My bet would be that C# was developed taken into consideration common complaints about Java - or things that were already planned to be added to Java 'some time in the future'.
;)
And hats off to Microsoft for doing so, C# is a nice language.
I agree, however, that the next release of Java will raise a few eyebrows wrt 'fixing' Java's current 'problems' (if you could call them that - they're more like syntactic unpleasantries).
Should be interesting
I sure hope future languages aren't modeled on Java. That will retard language development like too much reliance on C has retarded it over the last couple of decades. But Java isn't even as original as C was. The language design is purely derivative, a cleaned-up, restricted C++ with some features added from other languages, according to Jim.
I'm not saying Java is a bad language, but that it would be a bad one to base others on.
I'm tired of hearing that 'java isn't used in real-world applications", then some stupid example touted as proof. Java is used in plenty of real-world scenarios. The U.S. State Department uses java, and so do a large number of countries around the world to aid in the export control of nuclear, chemical, biological, and other hazardous materials.
Am I the only one here who'd like to some day be rendering serious 3d graphics through Java?
No, but I've been doing it for years. Don't know which closet you've been hiding in, but there are heaps of alternatives for doing 3D graphics in java. Java3D, GL4Java, LWJGL and more. In fact, our (open source) toolkits use all of these and we have hundreds of users running on everything from PDAs up to CAVEs all done in Java. We've just released code to handle Elumens Domes/VisionStations too, which, again, is in Java (although that one required a small amount of native code to slap Java3D into gear to do it).
Take a look at Xj3D for more information.
Life is complete only for brief intervals in between toys or projects -- John Dalton
for (int i : C) {... }
also allow :
for (int i : C.iterator) { }
so that iterators other than the default (the SimpleIterator named "iterator") could be used.
This would not complicate the iterator syntax much and would make using different iterators easy - and thats something that is often needed.
Since the "C" above is an expression, it could be a function that returns an "Iterable" - allowing interesting hackery to provide alternate iterators using inner classes or other fun. However while I think this allows programmers to do about what they need, it does not make things exactly readable and that is a bit bothersome.
Another thing I'd like, and would like to have efficient and easy to use, is a way to iterate over the indexes of an array - in particular a multidimensional array. I get tired of doing things like the following (which I can't get to indent easily) :
It would be much easier to do something like
for (int i : C) {}
or more properly
for (CMemberType cMem: C) {}
is something that I have to scratch my head about. The fact that people conflate i with c_mem and confuse a collection member with a loop index tells me that the new construct is going to give problems.
Yeah, yeah, Law of Demeter and all that style stuff, you shouldn't be pulling values out of objects and doing logic on them, you should be telling an object what to do and have it do it. But you can take all this OO purity so far, and the first way is instantly recognized by every C, C++, Java, and C# programmer.
You take all this OO purity stuff so far and you have something that looks like Objective C, Smalltalk, (God forbid) Eiffel, or C++ STL on a bad hair day. I am a Pascal person myself, but as of 2003 I am willing to concede that C-style syntax has won: there is a huge "installed-base" of programmers familiar with it. I am all in favor of staying consistent with it instead of going of inventing all kinds of bizarro syntax.
The way generics are implemented in Java might be a hack, but parametric types are a very sound mathematical construction (see type theory, category theory, etc). When implemented correctly in a programming language, they can:
1. improve programmer productivity
2. improve quality of code
3. improve efficiency (speed/space) of developed software
However, I am sure Java's generics are nothing more than heavy syntactic sugar. Still, anyone who complains about generics in Java doesn't know very much about programming languages. Generics are a good thing, and Java's only mistake is that it didn't have them designed into the language from the begining.
Same goes for Java having "primitive" datatypes. Yeah, that just complicates both syntax and semantics. They seem to be patching up these problems with these new features.
That is impossible. Java has to do the same as the C code, plus the extra overhead of doing the JIT. There is no way Java can be "as fast".
Ah, the "impossible" word. ;-)
You're presuming that the ahead-of-time compiler can "know" everything that the JITC can. That isn't true, in many common cases.
Another point regarding JITC compilation is that it can be for the exact target processor, something not typically the case for traditionally compiled programs.
All that said, current JVM performance certainly varies between 'better than C++' and 'worse than C++', with pathological cases in both directions.
The current 1.4 JVMs actually took a hit on some math operations, though that is supposed to be fixed in 1.5.
I hope gcj gets to the point where it supports the latest language spec. The libraries are tougher, and many of them aren't needed for interesting projects. For certain applications, an ahead-of-time compiler is nice.
By the way, for a good example of a 'fast' Java program, check out Eclipse from www.eclipse.org.
Galileo: "The Earth revolves around the Sun!"
Score: -1 100% Flamebait
Lisp is certainly not slow, even when compared with C++. It can even do certain things faster than C++ with most tasks in a very acceptable range, including being much faster than java and having a much better and more stable garbage collector.
http://www.norvig.com/Lisp-retro.html
Also Java sucks when compared to Smalltalk in terms of productivity and ease of use. Smalltalk should be a mandatory first OO languages in universities especially for concepts. Java is more popular than Smalltalk and has a lot more libraries, standardization and available programmers, but it still sucks, albeit less than C++.
Everyone tries to defend languages that they're fond of and used to without getting out of their comfort zone and trying something that might be better. If someone claims that Java is better than Smalltalk or Lisp, then they have not worked with Smalltalk or Lisp.
There are a lot of good languages out there with useful features, nice libraries and support for different paradigms which are better. Take Objective Caml for instance, which is very fast, strongly typed, dialect of ML and is certainly a better language than many, but it is doomed to live in academia, because people from the industry (pointy haired bosses) are too dumb and scared to even know about these things.
However, I see these new additions to Java as a welcome change. Hopefully someday people would not have to use some other language in the JVM just to implement closures and hopefully Java will catch up with languages like Lisp and Smalltalk and Python and Ruby and Haskell and Perl and Scheme and Dylan after it finishes catching up with Objective C.
Try Component Pascal. You can get a compiler here which will compile to either the .NET platform or to Java byte code, so you still have access to all that underlying modern stuff if you really want it. :)
I agree with Squeak one can teach some powerful ideas even to kids (which is one of Alan Kay's goals). You can just like Java run applets in your browser.