Version 1.5 of Sun Microsystems’ Java Development Kit (JDK) is set to be released this summer and promises a list of features to ease the development of your Java applications. In this article DevChannel introduces you to many of the new features and provide code samples, so you can hit the ground running when the final release becomes available.
Is it any faster?
It’s gotten faster with every release. Especially the most recent releases. When was the last time you worked with it?
Is Swing native in this release?
…explicit destruction of objects. That would be sweet. Oh, and operator overloading.
“…explicit destruction of objects. That would be sweet. Oh, and operator overloading.”
<sarcasm>
How about pointers!! Ooh ooh and pointer arithmetic!!! And inline machine code!!
</sarcasm>
No, Swing is not fully native, but it has become faster, especially under Linux.
The reimplementation of the AWT using XLIb helped, as did using OpenGL pipelines for Java2D. Swing has been accellerated under windows using DirectX for quite some time now.
Since 1.5, Linux now also has similar benefits.
1) There is no need to use explicit destruction of object. That’s why Java uses a Garbage collector. In the future, all language will have a garbage collector
2) Is it possible to call finilize() in a function ? if yes – that’s a possibility to use explicit destruction of objects … thought I’m really not sure, if it’s possible to use it explicitely. and even if – you would never be sure, if you would do it *befire the garbage collector. So explicit deallocation of object is something impossible.
No it isn’t. Nor will it be. Nor does it need to be. What it needs to be is faster. It is faster and getting faster with each new release.
swing is a broken ui model. it is something from academia that simply doesn’t work in the real world.
when java decides to put in a real ui, wake me up.
It’s good to see enums(what was with the hold up on that?), generics, variable length args(a proper printf finally) and other things getting into java finally. You can thank Microsoft for giving Sun a little competition in the mainstream managed language world.
Still no user-defined value types(good for numeric computing), the generics implementation is hackish(read, it’s still objects under the hood), I still prefer delegates for callbacks. I still think java is a bit of a deployment pain. You still have to mess around with classpaths. You still have to set up a physical directory to mirror your package structure. In mono or .NET you just refer to a CIL library as if it was a native library and be done with it.
I’m waiting for someone to come up with a _complete_ c# development environment in Eclipse that mirrors the environment that java has. Yeah, I’ve got Visual Studio, but that’s windows only. I hear the guy that wrote the vim plugin for eclipse is working on a c# environment for eclipse.
Here’s some interesting statistics from a very pro Java guy that did a direct line-by-line translation of his java product into c#.
http://www.redhillconsulting.com.au/blogs/simon/archives/000080.htm…
“swing is a broken ui model. it is something from academia that simply doesn’t work in the real world.
”
oh. my master. can you specify what flaws you are talking about SPECIFICALLY or get lost
“Swing has been accellerated under windows using DirectX for quite some time now.”
Since when? It always flickers when I’m moving a Swing window, or resizing a swing window, or creating a Swing window.
I meant that in the most sincere way, too! It wasn’t a flame, brother!
In the Swing code, they made the base window use one DirectX API call. Swing is by no means optimized for DirectX.
It would probably be a total rewrite to optimize Swing to run on any native platform with good performance. And you’d have to put all sorts of special code into the VM, similar to what Apple has done.
The truth of the matter is that off-the-shelf Java is not suited for any sort of UI other than applet/cellphone style stuff. You have to go native; either like Apple did with their Java implementation or like IBM did with SWT.
I’m using Solaris 10 build 54 and Java 1.5 is part of it. All of the java apps that come with Solaris run a lot faster than they did in Solaris 9.. and they look better;)
These features are only some of the language features. J2SE 1.5 offers much more than those changes. Yet, i am pleased with the typesafe enums, enhanced for, varargs and autoboxing. However, static imports, unboxing and somewhat generics does not appeal my personal taste of java programming. Though, some others may like.
i am also pleased that they do not put operator overloading and destructor crap into the java.
For beta-1 new features check here: (this may change in the beta-2 and final)
http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html
…if you stop to think that hardware has evolved. I used Java 1.0.x with a P150. It was slow. I now use Java 1.4.x with an AMD K7 1.2GHz. It’s faster!
But it certainly can be optimised. I mean, IBM Java for OS/2 used to be way faster than Sun’s Java for Windows. Neither could match Cincom Smalltalk (which has no static binding) for Linux running under FreeBSD, though…
“i am also pleased that they do not put operator overloading”
string 1, 2, 3;
3 = 1 + 2;
vs
string 1, 2, 3;
2.Concat(3);
1.Concat(2);
…?
And no properties. IMHO the getter/setter functions instead of properties are very stupid things in java. The C# language is far better, IMHO java will dead.
” The C# language is far better, IMHO java will dead.”
IMHO windows will ‘die’ and c# will need to run on UNIX before it can be use for big enterprise apps. ERP etc.
And no properties. IMHO the getter/setter functions instead of properties are very stupid things in java. The C# language is far better, IMHO java will dead.
—
C# properties compiled to getters and setter. Yes the language C# is maybe easier/more clean than Java in this point. But the code generated is about the same…
I’d like properties too though..
i do not thing C# is cleaner. they have more language commands, makes it more difficult to learn. And operaor overloading or destructors are killing i.
i dont see any problem with getter and setter, because producing or using them is dead easy with modern editors like IDEA and Eclipse.
And, yes i know there is only one execption for overloading in JAva, String declaration. Other operations over primitives cannot be considered overloading (because te otherway is not possible). But language does not have a easy to define overloading, which i like.
should be “any way” not “a aeasy to” in the last sentence..
I’m curious: what is wrong with operator overloading?
I’m curious: what is wrong with operator overloading?
Oh, nothing. It’s just that if a computer language or OS lacks a certain ferature, zealots consider that feature “evil”.
Actually, some may prefer operator overloading. but i like strongly typed languages, and less rules in developing. If you look at a code with operator overloading, it may cause much confusion like this:
ObjectA a= new ObjectA();
ObjectB b= new ObjectB();
a = a + b;
What will “+” do? You have to check the A class for understanding. And what if = is also overloaded?
But in java lets say + represents “append” opeartion
a = a.append(b)
To me second is
– more understandable, i have an idea what method does without looking at code.
– applies the strict rules if method call, i do not have to know the rules of generating operator overloading etc.
it is ok to me write 5-6 characters more to apply the same method operator does over an objct. And if you ever use IntelliJ Idea, you will what i mean , strong editor help usually voids all the complaints of slow coding..
i am talking personal preferences, some may prefer overloading, but i see the perils of it from C++.
Even more cryptic stuff can be written by overusing operator overloading..
sorry the java code should be
a.append(b); only. much better
I agree that an append operation should be called using a method with a descriptive name such as “append”. But there are numerous cases (matrices, vectors, complex numbers etc.) where it is absolutely clear what is meant by +. In these cases it should be possible to override the + operator.
This is not that important for business logic, but for numerical computing it is essential, just like value types.
“And, yes i know there is only one execption for overloading in JAva, String declaration.”
Like, ah, doesn’t that mean that operator overloading is useful?
It seems like, you know, it would make extremely messing code during mathematical operations, though, to be using function calls all of the time.
Vector6 = (Vector1 + Vector2) – (Vector 3 * (Vector4 + Vector5);
Yeah, that’s a made-up example, my man but I had to do something similar when I was fooling around with MDX.
What’s the Java equivilent of that? Is it clear and easy to read/maintain?
The point is, why take away a valuable function to the programmer, you know? That’s, like, arguing against generics because the brackets scare you – some of us need the performance boost, the rest of you can keep doing your append() and subtract().
The + operation on String class is the only real instance of operator overloading
but
a = a + c
is not equal to
a.concat (b)
IIRC the + invokes a string builder class that grabs every ‘+’ String and then concatenates the all at once since Strings are immutable. This is much more effecient and a lot less complicated. I think it was made for the benefit of noob programmers and for convience.
Technically I ‘spose ++ and — and all the OPERATOR= are examples of operator overloading too. It’s just that you can’t define your own operators to overload.
If you really want operator overloading write a preprocessor that compiles into Java. There problem solved.
Ok, here what i say again, operator overloading might look very innocent, or cool in some cases. but it allows user to abuse it easily. That is why i like the java way.
The example “shapeShihter” gave is a made up situation (if not an ugly way of coding), and if i really need to do such an operation, i prefer to do it in a special method or as a class.
or, as CaptainPico said, i would make a preprocessor.
Also, you can use scripting languages together with java (like groovy, or ruby) if you really in love with operator overloading.
Another isue is, lets say for vectors some people are using + operator for overloading “append” method. and another guy made it for mathematical sum operation. there you enter the mess. Confusion in the use of vectors in each different API. i hope you can see my point. sometmes restriction gives you beter interoperaility, or clarity in the long run.
You honestly believe that doing vector math is is a made up situation? I take it that you’ve never done any sort of numerical computing then. Just try writing some 3D graphics code in Java. Just have a glance at Java3D. The API is hideous due to its lack of operator overloading. Adding numerical types using “+” is natural. Adding them using the english “plus” is unnatural, and it makes things very ugly when you have to do more than one operation at a time.
If you think that making a preprocessor is a viable solution, then you might as well give up on your language of choice. The purpose of a programming language is to give its user more expressive and logical control than machine language gives. That’s it. When you write java code, and support its lack of operator overloading, you’re actually saying that a less expressive language is better. I do not see any way that you can believe that.
Even MS is not dumb enough to be touting C# as the “be all and end all” language for all programming ever. (That is how they market the .Net framework)
Java is good for a lot of things, however for other things it isn’t ideal. As mentioned above the lack of operator overload makes implementing complex mathematical problems difficult and rather awkward.
For reasons unknown a lot of people here seem to want Java to be a complete C++ clone. If you need managed/bytecode solutions using C++ you can achieve this with .Net.
If you want to use C++ for everything its your perogative to do so. C++ is supported on nearly every platform. Be Happy and Merry and look not upon Java programmers as any less of a developer.
The listed improvements to java are certainly a step in the right direction for faster development (especially the autoboxing of native types). A feature I’d like to see is callbacks to calling objects and functions. The ability to trace the execution stack. Of course this breaks a fundamental OO principle. But principles are made to be broken. Aren’t they?
Of course this breaks a fundamental OO principle. But principles are made to be broken. Aren’t they?
No, but java breaks so many OO principles already…
Whether someone overloads the operator+() to wipe out your hard drive, or overloads append() to wipe out your hard drive, the effect is the same. You never know unless you look. And using operators instead of functions in those places where we came to expect them – e.g. working with complex numbers, matrixes, vectors, accounting etc. – just makes code *more* readable. All the silly things you can do with operator overloading can be done with functions, too.
@ jizzles:
> > “…explicit destruction of objects. That would
> > be sweet. Oh, and operator overloading.”
>
> <sarcasm>
> How about pointers!! Ooh ooh and pointer arithmetic!!!
> And inline machine code!!
> </sarcasm>
If you would want to write a device driver in Java, or an operating system, you’d want to have them, no? But no-one wants that, because that’s not what Java was intended for.
But, you see, they already copied templates, enums, and printf()… so I wouldn’t be so sure that rather reasonable things like deterministic object destruction and operator overloading won’t make it into Java 1.6 or 1.7.
@ HelloWorld82:
> There is no need to use explicit destruction of object.
> That’s why Java uses a Garbage collector.
Things being as they are, you have to call your cleanup functions manually because you can’t tell when (or if) finalize() will be called. Sounds a bit like “freeing memory manually”, doesn’t it? 😉
> In the future, all language will have a garbage
> collector
Optionally, perhaps, and I would even applaud that. But you have to realize that not all the world is Enterprise Java Beans, and that there are areas where a garbage collector is a pain in the backside if you can’t turn it off.
“still have to set up a physical directory to mirror your package structure”
You have never had to do that. The compiler will put the .class files into the correct directory structure regardless of where the source code is.
At Symantec we once had all of our .java code in a single directory (weith about 20 different packages) until I moved it into the directory strucuture.