PDA

View Full Version : The Java language is being expanded



DavidP
06-09-2004, 08:48 AM
http://java.sun.com/developer/technicalArticles/releases/j2se15langfeat/

Check it out.

My thoughts about it:

I think they have realized their error-prone ways and in a desperate attempt to salvage their lost cause they have tried enhancing Java with C++ "like" features.



The int-enum will soon be gone
Like a foe we've known too long.
With type safe-enum's mighty power
Our foe will bother us no more


They shall die for saying int enums are a foe. Integer enums are like my best friend. I love them.

I do like the fact that they are adding in variable argument lists. That has been something Java has been in need of for a long time now. Generics are nice for typecasting, but they wouldnt be needed if the Java developers had gotten things right the first time around. The new for loop syntax is interesting, however, I think they could have spent the extra development time and just made the foreach loop instead of the new for loop.

Autoboxing/Unboxing is nice, but also I think they are a little late on the draw on it. It wouldnt be needed if the Java developers had gotten things right the first time.

Basically that's how it is with all the features they are adding. They are nice features that should have been included in Java in the first place, but they were left out. No offense to Java, but I think C# is very very slowly winning the war.


Since they wrote poems to enhance the visuality of the new language features, I will write my own poem:

Oh Java, Oh Java,
It came too late,
These new features are nice,
But you will soon meet your fate.

Lurker
06-09-2004, 08:57 AM
Looking good....however:

System.out.printf("%s %3d", name, age);

Where did they get that idea :) ?

axon
06-09-2004, 09:00 AM
one of java's drawbacks is that it expands and changes so damn fast...

Lurker
06-09-2004, 09:02 AM
I have a feeling that people could look at that both ways, but I understand what you're saying.

Prelude
06-09-2004, 09:42 AM
My thoughts:

I see signifigant improvements with these changes. They've fixed (not well, but it's a start) things that I disliked about Java:

>Generics
I'm a big fan of parameterized types and would probably not use C++ nearly as much if it didn't have support for them. One of my biggest beefs with Java is that many of the run-time errors could easily have been caught at compile-time. Generics take a step in that direction, which is a very Good Thing. :)

>Enhanced for Loop
This is a convenience feature, but it does eliminate the annoying need for temporary iterators. That alone wasn't a big problem, we do it all the time in C and C++, but the FormalParameter is a nice idea that removes the need for a local temporary to hold the collection item. I find the syntax very clean, and intelligent use of the feature should go a long way toward making Java more readable.

>Autoboxing/Unboxing
The only down side to this is that the object has to be declared as a generic type. But the advantages far outweigh the disadvantages and code will be a lot cleaner with boxing.

>Typesafe Enumerations
I like that they didn't go with integer based enumerations. That's a potential error zone in C and C++. I can see how some people would like to see integer based enumerations in Java because of the flexibility of having named integer constants, but the same effect can be achieved by declaring a variable as public static final. While it's useful, I think that integer based enumerations are too often abused rather than used as they were intended. So I like this feature, with a few minor reservations. :)

>Static Imports
Brilliant. This goes a long way toward removing the verbosity of Java that I dislike.

>Variable Arguments
The syntax looks a little awkward, but the idea in general is usually awkward, so I can forgive them. ;). I'm curious to see how one would implement a function that takes a variable number of arguments. I'd also like to know what inspired them to do this because variable arguments are usually a detriment to type safety and type safety seems to be the direction that Java is trying to move in.

>Formatted Output
I like printf, but forcing the client to specify types with a format string is error prone. I'd like to see how they avoid that potential problem. It seems like a step backward for Java if they're working toward type safety.

>Enhanced Input
Much better. Not great, but much better than what they had before. Probably my biggest problem with Java has been it's awful support for any input that isn't GUI based. The solution that they had before "Well, you should have been using a GUI instead of the command line" struck me as arrogant and idiotic. I guess they got too many complaints about their support for input. ;)

>Synchronization
Looks promising. :)

Response to DavidP:

>I think they have realized their error-prone ways and in a desperate attempt to salvage their
>lost cause they have tried enhancing Java with C++ "like" features.
That sounds like an accurate assessment. But it sounds better if you simply say that Java is trying to keep pace with C++ in improvements. Whether Java is a lost cause or not is debatable. "Good" languages tend to die where "Bad but useful" languages prosper. It appears that Java is implementing features that have been desparately needed or petitioned for.

>They shall die for saying int enums are a foe. Integer enums are like my best friend. I love them.
Opinion on both sides. Have you tried to see it their way? I find it hard to believe that an intelligent design team would avoid a feature that is as good as you say without excellent reasons. ;)

>That has been something Java has been in need of for a long time now.
Debatable. You'll notice that good C++ style tends to frown upon using variable length argument lists because of the lack of type safety. Even good C style looks for other options before using stdarg.

>Generics are nice for typecasting, but they wouldnt be needed if the Java developers had gotten things right the first time around.
Difficult to say. I can't see an easy solution for a typed language trying to be object oriented in a way that all objects derive from a root super class. You either end up with typecasting or some awkward parameterization.

>I think they could have spent the extra development time and just made the foreach loop
Language designers are allergic to new keywords. It's also not a good idea in general to add keywords to a language so late in its development. You have to consider breaking old code. Their attempt is admirable, and would adding foreach and in really make a profound difference over for and :?

>Autoboxing/Unboxing is nice, but also I think they are a little late on the draw on it.
I agree. :)

DavidP
06-09-2004, 09:55 AM
Ah i didnt even notice the new enhanced input. Yes indeed that is nice. I have never been a fan of the way Java does input.

Sang-drax
06-09-2004, 10:27 AM
They shall die for saying int enums are a foe. Integer enums are like my best friend. I love them.I think the following makes sense


2. It provides a separate namespace for each enum type and thus eliminates the need to include a prefix in each constant name
3. Constants are not compiled into clients so you can freely add, remove, or reorder them without recompiling the clients

Dante Shamest
06-09-2004, 05:24 PM
I always thought the Java language itself was sufficient. It's the implementation of the Java runtime that has always bugged me. The memory Java apps consume seems excessively large.

DavidP
06-09-2004, 06:27 PM
Java isnt a horrible language. In fact there are several features I really like about it.

In fact after reading about this new update I downloaded the 5.0 beta sdk and started developing using it just for fun while at work.

Here is one of the MAIN things that bugs me about Java: WAY to many readers and writers, including:

Reader
BufferedReader
CharArrayReader
FilterReader
InputStreamReader
PipedReader
StringReader
LineNumberReader
PushbackReader
FileReader
InputStream
ByteArrayInputStream
FileInputStream
FilterInputStream
InputStream
ObjectInputStream
PipedInputStream
SequenceInputStream
StringBufferInputStream
BufferedInputStream
CheckedInputStream
CipherInputStream
DataInputStream
DigestInputStream
InflaterInputStream
LineNumberInputStream
ProgressMonitorInputStream
PushbackInputStream
Writer
BufferedWriter
CharArrayWriter
FilterWriter
OutputStreamWriter
PipedWriter
PrintWriter
StringWriter
FileWriter
OutputStream
ByteArrayOutputStream
FileOutputStream
FilterOutputStream
ObjectOutputStream
OutputStream
PipedOutputStream
BufferedOutputStream
CheckedOutputStream
CipherOutputStream
DataOutputStream
DeflaterOutputStream
DigestOutputStream
PrintStream

whew...i doubt i even hit all of them...

swoopy
06-09-2004, 10:05 PM
>In fact after reading about this new update I downloaded the 5.0 beta sdk

How big is the download?

DavidP
06-10-2004, 07:21 AM
about 40 MB...a little bit over that actually...i think it is like 43...

swoopy
06-10-2004, 07:47 PM
Ok thanks, that's probably feasible with my dialup connection if I start it up and let it download overnight.

Xterria
06-10-2004, 07:56 PM
grrr...lost another one to ditech...i mean java...

VirtualAce
06-10-2004, 09:18 PM
Java runs too slow. Period.

I have the Java IDE and J++ and I just don't like any of it.

C++ forever.

Mister C
06-10-2004, 09:53 PM
Most of you are very uninformed about how and why Java was designed. If you would do your research first you would see why they did what they did(i.e. input, enum, etc.).

Well, here are my thoughts:

If any of you ever have the chance to teach java and C++, two different courses in one semester-which I have done many times, you will see differences and advantages/disadvantages which each language has. I personally perfer teaching Java over C++. I prefer C# over C++ as well.

:)

VirtualAce
06-11-2004, 03:53 AM
I don't care how they designed or it why they designed it. It does not suit my needs as a suitable game dev language and therefore I have no need of it. Not to say that it is useless...but in my world it is.

I don't research what does not apply to me in programming. There's too many areas in programming to do that. I concentrate on gamedev and as I said Java just doesn't cut it for that.

SMurf
06-11-2004, 07:39 AM
I think you're more interested in certain aspects of game development (Nice terrain thing on the GP forum, probably get about 4 FPS with Java3D :p), Bubba. Bear in mind that you can program puzzle games for it and they work fine (The reason why all these mobile Java games are just rehashes of games from 15 years ago).

Prelude
06-11-2004, 08:13 AM
>If you would do your research first you would see why they did what they did(i.e. input, enum, etc.).
I'm well aware of why the design decisions were made. Perhaps you should be giving concrete examples of why you think everyone is so misinformed rather than simply saying "Do your research". We aren't your students, and that just won't cut it here. ;)

>If any of you ever have the chance to teach java and C++
>you will see differences and advantages/disadvantages which each language has
This strikes me as incredibly arrogant seeing as how you haven't shown a respectable depth of knowledge in your time here.

DavidP
06-11-2004, 08:22 AM
>>If you would do your research first you would see why they did what they did

>I'm well aware of why the design decisions were made.

So am I. And in some aspects I fully agree with there decisions, but in other aspects I do not agree at all. :D

>If any of you ever have the chance to teach java and C++
>you will see differences and advantages/disadvantages which each language has

I have had the opportunity to teach both languages, not as a full fledged teacher, but more as a tutor. In my experiences, the Java language has definitely been an easier language to learn than C++, but also in my experiences I have noticed that those I tutor in Java simply dont get the full load of what they should be learning about how things work on the inside. That is the main reason I support C++ being taught to people before Java. I am not a Java hater, I am simply a C++ advocate. :cool:

nvoigt
06-11-2004, 08:30 AM
That list of enhancements sounds like they saw what was better in C# ( and planned enhancements of C# ) and implemented it in Jave.

Mister C
06-11-2004, 10:02 AM
Join Date: Sep 2001
Posts: 5,796 Today, 08:13 AM >If you would do your research first you would see why they did what they did(i.e. input, enum, etc.).
I'm well aware of why the design decisions were made. Perhaps you should be giving concrete examples of why you think everyone is so misinformed rather than simply saying "Do your research". We aren't your students, and that just won't cut it here.

>If any of you ever have the chance to teach java and C++
>you will see differences and advantages/disadvantages which each language has
This strikes me as incredibly arrogant seeing as how you haven't shown a respectable depth of knowledge in your time here.


Hold on here...Prelude.

I am trying just make the point some people should research things first. Opinions are opinions- some people try to force opinions as facts on these boards.

Now, are you going to argue that this is not true?

As for my time here on this board- I only have time to post on this board when I have time to do so. I try to post my insights on my years of my teaching- and I have seeked help on occasions from people on this board to better myself and how I present things to my students.

The point about teaching Java/C++, etc. does not make me superior- it does however make someone, I believe, more insight ful about comparing Java/C++.

Now, I do not have to spell out noted comparisions/differents between the languages. Anyone can find that out on their own.

Prelude, during your time on these boards, you have provided help and good advice. Your knowledge of C/C+ is extraordinary and -in my opionion-better than the major of the people on this board. Even quite possibly maybe even me.

You and I are not perfect, Prelude. Your comments about me, show me your faults, especially when you do not know everything about me and my professional accomplishments. Once again, my opinion not fact.

Now, back to the topic..

For those of you that do not know... here is a summary of the new features of java. Java 1.5 (http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html)

Prelude
06-11-2004, 10:48 AM
>Now, are you going to argue that this is not true?
To do so would be futile. There are times that I forget to mention that I'm stating opinion, so to deny your accuracy with that statement would be the height of hypocrisy.

>it does however make someone, I believe, more insight ful about comparing Java/C++.
It's silly to compare languages most of the time. When it makes sense to do so, the goal is usually to determine which language to use for a single project. At that point the comparisons are practical and serve a purpose. For the purpose of teaching, it depends on the individual learning the language. I've seen people take to C++ in a flash but be stumped by Java, as well as the opposite.

>Anyone can find that out on their own.
The question was about the reasoning behind features, not the features themselves. That's harder to find, and I wouldn't mind seeing someone else's perspective on specific issues rather than just a hard demand to do research.

>Even quite possibly maybe even me.
That's still a pretty arrogant view. I won't deny a certain amount of ego on my part, but I recognize that there are quite a few people on these boards that know more than I do and have more experience than I. Confidence is fine, but one should be aware of reality as well so that they can improve.

>Your comments about me, show me your faults
A short post isn't nearly enough for you to see all of my faults. :D

>especially when you do not know everything about me and my professional accomplishments
This is true. And that's the reason why I comment only on what I've experienced of your abilities. Around here it doesn't matter what you say you've accomplished, only what you prove that you've accomplished.

Now that we've both responded to each other once, please direct further comments by way of private message so as to avoid a pointless flamewar. I'll do the same. :)

okinrus
06-11-2004, 11:14 AM
I personally don't like Java as much as C++. This is mainly do to verboseness involved in writing classes that look like



class C {
public String toString();
}

the extra "public" variable takes away considerable clarity from the text. In fact, it would probably be more clear if the syntax was something like


class C {
toString() : String;
}

this way the most important stuff is flushed left and in clear site, while the least important is further back. The issue about the semi-colon at the end seems more of a compiler issue. If C++ compilers would generate better guesses for some of the common mistakes this would not nearly be so much of a problem.

The C++ model of having everything declared before use in the source file really is not necessary, and this could be improved by adopting Java's model.

But I don't think having each public class in different file is such a good idea. This should probably be managed by the ide. Despite C++ namespaces being more flexible and consistant than Java's use of package statements, the use of namespaces makes indented text go too far to the right when indented.

DavidP
06-11-2004, 12:14 PM
I personally like how C++ does public/private/protected statements, for example:

class A
{
public:
...lots of declarations...
private:
...lots of declarations...
};

Whereas with both C# and Java you have to prefix every single declaration and definition with public, private, or protected, which I find quite annoying.

Zach L.
06-11-2004, 03:27 PM
>> Despite C++ namespaces being more flexible and consistant than Java's use of package statements, the use of namespaces makes indented text go too far to the right when indented. <<

My solution has always been simply not to indent inside of a namespace. It's the only place I don't indent, but it would seem rather silly to indent almost every line in a file for the sake of a couple of braces.

swoopy
06-11-2004, 08:53 PM
Prelude, during your time on these boards, you have provided help and good advice. Your knowledge of C/C+ is extraordinary and -in my opionion-better than the major of the people on this board. Even quite possibly maybe even me.
Mister C, you've got to be kidding me??? You are comparing yourself to Prelude? Now that's funny!

okinrus
06-11-2004, 09:07 PM
I think Prelude is really good at the syntax and the C++ as a language but it's quite possible mister-C is an expert at something that Prelude's not and vice-versa. I don't find anything objectional to stating Java was easier to teach. In fact, I think Java will be easier to teach merely for the fact that someone can teach most of the fundamentals faster, and once known, a programer can actually start learning the process of how to program. But this does not necessarily make Java a better language.