Valhalla Legends Forums Archive | Java Programming | Java 1.5

AuthorMessageTime
Tuberload
I have read a lot about the new version and see things I like (such as generics), but haven’t migrated because of fear of change. :-\

I was just curious if any of you have upgraded, and what your thoughts on it are?
May 18, 2004, 10:07 PM
Tuberload
[quote]One interesting feature of the beta is the ability to choose whether or not to use the new 1.5 features. When compiling your code, you have to explicitly state that you want the Java compiler to use the new 1.5 features. You do this with the following syntax:


javac source 1.5 YourClassName.java[/quote]

I found this in an article I just read, and it is nice to hear. I will be upgrading now, and will post more about it later.
May 18, 2004, 10:10 PM
iago
Good plan, I'm the same way. I don't want to change :)
May 18, 2004, 11:41 PM
Myndfyr
Looking through the spec, I see:

[quote]
Autoboxing/Unboxing
This facility eliminates the drudgery of manual conversion between primitive types (such as int) and wrapper types (such as Integer). Refer to JSR 201 .
[/quote]

I say, boo! Primitive types -- value types -- should be able to have methods called on them directly without worrying about a reference type wrapper. Boxing wastes memory and ticks.

The enumeration addition copies exactly the way enums function in C#. :P

I like the moves that Java is making, though. It's almost becoming useful. :P
May 19, 2004, 12:40 AM
Hostile
I've been familiarizing myself with the new features since the beta pre-releases of it but even with final versions out i never end up making much use of the new API until its integrated in the products I use with it. Like WebLogic.
May 19, 2004, 2:33 AM
Tuberload
[quote author=Myndfyre link=board=34;threadid=6867;start=0#msg60756 date=1084927202]
Looking through the spec, I see:

[quote]
Autoboxing/Unboxing
This facility eliminates the drudgery of manual conversion between primitive types (such as int) and wrapper types (such as Integer). Refer to JSR 201 .
[/quote]

I say, boo! Primitive types -- value types -- should be able to have methods called on them directly without worrying about a reference type wrapper. Boxing wastes memory and ticks.

The enumeration addition copies exactly the way enums function in C#. :P

I like the moves that Java is making, though. It's almost becoming useful. :P
[/quote]

Good thing your opinion doesn't matter. :P JK
May 19, 2004, 2:57 AM
St0rm.iD
java is way too verbose imo. it's getting better with 1.5, but still not enough.
May 19, 2004, 7:09 PM
DaRk-FeAnOr
I believe that 1.5 is still beta.
May 20, 2004, 12:14 AM
Myndfyr
[quote author=St0rm.iD link=board=34;threadid=6867;start=0#msg60830 date=1084993765]
java is way too verbose imo. it's getting better with 1.5, but still not enough.
[/quote]

I now understand why you disdain VB. As I have been working on an extremely simple sample VB .NET bot using my API, I have discovered that it uses a lot to say a little.

What I say in VB .NET:
[code]
For i As Integer = 0 to someArray.Length Step 2
' blah
Next
[/code]
I can do in C#:
[code]
for (int i = 0; i < someArray.Length; i+=2) {
}
[/code]

Even better are function declarations, with attributes:
C#:
[code]
[STAThread()]
public static int Main(string[] args) {
}
[/code]
Note the line-continuation marker after the attribute declaration (I don't know why they decided on that, but it's gay).
VB:
[code]
<System.STAThread()>_
Public Shared Function Main(ByVal args() As String) As Integer

End Function
[/code]

Eck.

Anyway, off-topic, of course. This all gets around to -- why is it you think Java is verbose? I would tend to disagree -- in fact, I think it's relatively concise.
May 20, 2004, 12:16 AM
Tuberload
[quote author=Myndfyre link=board=34;threadid=6867;start=0#msg60873 date=1085012160]
Anyway, off-topic, of course. This all gets around to -- why is it you think Java is verbose? I would tend to disagree -- in fact, I think it's relatively concise.
[/quote]

I agree with you about it being concise, but when compared to languages like Python, and Scheme which storm talks about it does require a lot more typing.
May 20, 2004, 1:14 AM
St0rm.iD
After much exploration into other languages, I've decided operator overloading is a must. Makes things so much easier and concise.

Plus, Java is a dynamic language in a static world. It needs eval()!
May 20, 2004, 1:17 AM
Tuberload
[quote author=St0rm.iD link=board=34;threadid=6867;start=0#msg60893 date=1085015864]
After much exploration into other languages, I've decided operator overloading is a must. Makes things so much easier and concise.

Plus, Java is a dynamic language in a static world. It needs eval()!
[/quote]

I would like to see operator overloading, but I don’t mind the dynamic nature of Java. Besides, I could just write my own eval() method.
May 20, 2004, 1:23 AM
Myndfyr
[quote author=St0rm.iD link=board=34;threadid=6867;start=0#msg60893 date=1085015864]
After much exploration into other languages, I've decided operator overloading is a must. Makes things so much easier and concise.

Plus, Java is a dynamic language in a static world. It needs eval()!
[/quote]

I agree, I like operator overloading in C#. :)

I remember when I first started programming in C# (I stepped up from Javascript). I referenced the JScript .NET assemblies in my project, just so I could use the eval() function. Now I say, "run away! run away!"
May 20, 2004, 1:48 AM
Hostile
[quote author=DaRk-FeAnOr link=board=34;threadid=6867;start=0#msg60872 date=1085012070]
I believe that 1.5 is still beta.
[/quote]

yeah... you can download here: http://java.sun.com/j2se/1.5.0/download.jsp
and... api specs here: http://java.sun.com/j2se/1.5.0/docs/api/index.html
May 20, 2004, 4:20 AM
iago
I disagree - I *hate* operator overloading. It makes things happen that shouldn't happen which just confuses things.

std::string a ="123test" + 3;
That should make a point to the character array "test", and it's impossible to figure out what's going on without the documentation because of the two overloads (= and +).
May 20, 2004, 12:16 PM
St0rm.iD
But you can't do syntactically beautiful things in Java!
May 20, 2004, 9:53 PM
Skywing
[quote author=iago[yL] link=board=34;threadid=6867;start=0#msg60971 date=1085055382]
I disagree - I *hate* operator overloading. It makes things happen that shouldn't happen which just confuses things.

std::string a ="123test" + 3;
That should make a point to the character array "test", and it's impossible to figure out what's going on without the documentation because of the two overloads (= and +).
[/quote]
Operator overloading can be handy as long as you know exactly what is going on.

One of the nice things about it is that you can have template functions that work (without code changes) for both primitive and user-defined types.
May 24, 2004, 3:32 AM
iago
[quote author=Skywing link=board=34;threadid=6867;start=15#msg61489 date=1085369561]
Operator overloading can be handy as long as you know exactly what is going on.
[/quote]

If you could always know what's going on it might not be so bad, but, especially when using a class you didn't write, you might not be able to tell when you're using an overloaded operator or now.
May 24, 2004, 8:12 AM
Skywing
[quote author=iago[yL] link=board=34;threadid=6867;start=15#msg61508 date=1085386352]
[quote author=Skywing link=board=34;threadid=6867;start=15#msg61489 date=1085369561]
Operator overloading can be handy as long as you know exactly what is going on.
[/quote]

If you could always know what's going on it might not be so bad, but, especially when using a class you didn't write, you might not be able to tell when you're using an overloaded operator or now.
[/quote]
That's what documentation is for. You can't really tell exactly what a particular function call does without documentation, either.

Besides, STL is very well documented...
May 24, 2004, 2:42 PM
iago
[quote author=Skywing link=board=34;threadid=6867;start=15#msg61528 date=1085409732]
[quote author=iago[yL] link=board=34;threadid=6867;start=15#msg61508 date=1085386352]
[quote author=Skywing link=board=34;threadid=6867;start=15#msg61489 date=1085369561]
Operator overloading can be handy as long as you know exactly what is going on.
[/quote]

If you could always know what's going on it might not be so bad, but, especially when using a class you didn't write, you might not be able to tell when you're using an overloaded operator or now.
[/quote]
That's what documentation is for. You can't really tell exactly what a particular function call does without documentation, either.

Besides, STL is very well documented...
[/quote]

But if you see a function like "dosomething(a)", you'll always know that a function is being called, but if you see "a = 17" you might not be able to tell that it's calling an overloaded function.

I just think that code clarity is lost when you overload operators..
May 24, 2004, 4:14 PM
St0rm.iD
When I was a Java programmer, I said that too.
May 24, 2004, 7:54 PM
Adron
[quote author=iago link=board=34;threadid=6867;start=15#msg61532 date=1085415294]
I just think that code clarity is lost when you overload operators..
[/quote]

Code clarity can be gained or lost. Many things look much clearer when you can use overloaded operators. Large number classes is an excellent example of that.

bignum a, b, c;
a.assign(4);
b.assign(1);
c.assign(a.multiply(b));

vs

bignum a, b, c;
a = 4;
b = 1;
c = a * b;

Overloaded assignment operator and overloaded multiplication operator makes a lot of sense.

May 28, 2004, 11:38 PM
Maddox
Things get confusing when you overload the dereferencing operator though.
May 29, 2004, 4:47 AM
K
How often do you see that? I think the std::iterator class and derivatives do an excellent job of overloading it sensibly.
May 29, 2004, 7:03 AM
Adron
I see the dereferencing operator overloaded for smart pointers, collections and similars. In most cases the meaning of the operator stays the same, but the operator can be a applied to a new data type.

If you know the data types of the variables in the expression, you'll then know that you're looking at an overloaded operator. If it wasn't an overloaded operator, it would be a compile error.
May 29, 2004, 8:45 AM
iago
[quote author=Adron link=board=34;threadid=6867;start=15#msg62436 date=1085787508]
[quote author=iago link=board=34;threadid=6867;start=15#msg61532 date=1085415294]
I just think that code clarity is lost when you overload operators..
[/quote]

Code clarity can be gained or lost. Many things look much clearer when you can use overloaded operators. Large number classes is an excellent example of that.

bignum a, b, c;
a.assign(4);
b.assign(1);
c.assign(a.multiply(b));

vs

bignum a, b, c;
a = 4;
b = 1;
c = a * b;

Overloaded assignment operator and overloaded multiplication operator makes a lot of sense.
[/quote]

I don't like that -- you don't know what's going on. I don't like the extra layer of abstraction (says the Java user).
May 29, 2004, 6:40 PM
Adron
[quote author=iago link=board=34;threadid=6867;start=15#msg62633 date=1085856023]
[quote author=Adron link=board=34;threadid=6867;start=15#msg62436 date=1085787508]
[quote author=iago link=board=34;threadid=6867;start=15#msg61532 date=1085415294]
I just think that code clarity is lost when you overload operators..
[/quote]

Code clarity can be gained or lost. Many things look much clearer when you can use overloaded operators. Large number classes is an excellent example of that.

bignum a, b, c;
a.assign(4);
b.assign(1);
c.assign(a.multiply(b));

vs

bignum a, b, c;
a = 4;
b = 1;
c = a * b;

Overloaded assignment operator and overloaded multiplication operator makes a lot of sense.
[/quote]

I don't like that -- you don't know what's going on. I don't like the extra layer of abstraction (says the Java user).
[/quote]

You don't like that? How can you not like a statement that clearly says that c is set to a times b, vs a complex one with a whole lot of function calls?
May 29, 2004, 7:35 PM
iago
In Java, I would do this:
[code]import java.util.BigInteger;
...
BigInteger a = new BigInteger(4);
BigInteger b = new BigInteger(1);
c = a.multiply(b);
[/code]

I personally prefer that over your operator overloading.
May 29, 2004, 7:40 PM
St0rm.iD
Then you would like Scheme/Lisp:

(* 5 (+ 2 3))
May 30, 2004, 8:27 PM
K
[quote author=iago link=board=34;threadid=6867;start=15#msg62660 date=1085859632]
In Java, I would do this:
[code]import java.util.BigInteger;
...
BigInteger a = new BigInteger(4);
BigInteger b = new BigInteger(1);
c = a.multiply(b);
[/code]

I personally prefer that over your operator overloading.

[/quote]

Some of us prefer the overloaded version, but the great thing is that you could do support both and simply have the operators call the named member functions, or vice versa.
May 30, 2004, 8:32 PM
Skywing
[quote author=iago link=board=34;threadid=6867;start=15#msg62660 date=1085859632]
In Java, I would do this:
[code]import java.util.BigInteger;
...
BigInteger a = new BigInteger(4);
BigInteger b = new BigInteger(1);
c = a.multiply(b);
[/code]

I personally prefer that over your operator overloading.

[/quote]
If you really like things being extra-verbose, you could always do c.operator=(a.operator*(b));
May 30, 2004, 11:13 PM
St0rm.iD
I hate typing for no reason.
May 31, 2004, 12:05 AM
iago
[quote author=Skywing link=board=34;threadid=6867;start=30#msg62845 date=1085958785]
[quote author=iago link=board=34;threadid=6867;start=15#msg62660 date=1085859632]
In Java, I would do this:
[code]import java.util.BigInteger;
...
BigInteger a = new BigInteger(4);
BigInteger b = new BigInteger(1);
c = a.multiply(b);
[/code]

I personally prefer that over your operator overloading.

[/quote]
If you really like things being extra-verbose, you could always do c.operator=(a.operator*(b));
[/quote]

That just looks ugly..
May 31, 2004, 1:27 AM
Adron
[quote author=iago link=board=34;threadid=6867;start=30#msg62871 date=1085966861]
[quote author=Skywing link=board=34;threadid=6867;start=30#msg62845 date=1085958785]
[quote author=iago link=board=34;threadid=6867;start=15#msg62660 date=1085859632]
In Java, I would do this:
[code]import java.util.BigInteger;
...
BigInteger a = new BigInteger(4);
BigInteger b = new BigInteger(1);
c = a.multiply(b);
[/code]

I personally prefer that over your operator overloading.

[/quote]
If you really like things being extra-verbose, you could always do c.operator=(a.operator*(b));
[/quote]

That just looks ugly..
[/quote]

Well, you could settle for c = a.operator*(b); which looks rather close to your java version.

Is the = operator overloaded in java? Or does it always do some particular thing? (i.e. member-wise assignment, pointer assignment, something like that)

And I still don't understand why you prefer function names over operators. It seems a little strange that you'd want to know exactly what happens, but at the same time you're programming in a language that is farther away from the hardware than C++ is. Is this based on bad experiences with someone using the operators to do non-intuitive things?
May 31, 2004, 1:50 PM
iago
I was beaten with overloaded operators as a child :'(

But seriously, it's because I like code clarity, and I don't htink operators provide that.

And = in Java is always the same -- assignment. If it's a primitive type, it assigns the value to the variable, and if it's a pointer (ie, an object) it assigns the pointer to the variable.

One of the reasons I like Java is simply for code clarity -- unless you're a crappy programmer, code in Java is very clean and readable. For example, compare this C++ code:
[code]ebp = *(DWORD *)((BYTE *)(Copy+3) - ((esi >> 5) << 2));[/code]
To the equivolant Java code (as best as I could write it):
[quote]int location = 12 - ((esi >>> 5) << 2);
ebp = IntFromByteArray.LITTLEENDIAN.getInteger(Copy, location);
[/quote]

I rather prefer the more verbose, but clearer code in Java.
May 31, 2004, 5:39 PM
Adron
[quote author=iago link=board=34;threadid=6867;start=30#msg62956 date=1086025189]
I was beaten with overloaded operators as a child :'(

But seriously, it's because I like code clarity, and I don't htink operators provide that.

And = in Java is always the same -- assignment. If it's a primitive type, it assigns the value to the variable, and if it's a pointer (ie, an object) it assigns the pointer to the variable.

One of the reasons I like Java is simply for code clarity -- unless you're a crappy programmer, code in Java is very clean and readable. For example, compare this C++ code:
[code]ebp = *(DWORD *)((BYTE *)(Copy+3) - ((esi >> 5) << 2));[/code]
To the equivolant Java code (as best as I could write it):
[quote]int location = 12 - ((esi >>> 5) << 2);
ebp = IntFromByteArray.LITTLEENDIAN.getInteger(Copy, location);
[/quote]

I rather prefer the more verbose, but clearer code in Java.

[/quote]

I prefer the less verbose but clearer C++ code:

ebp = Copy[3 - esi / 32];

(assuming Copy has been properly declared as a pointer to DWORD or int or whatever you're pointing at)

I suppose it really does become a matter of opinion. I find it much easier to abstract away as much detail as possible, and only keep the important things. The less code I have to look at, the better.
May 31, 2004, 6:04 PM
St0rm.iD
[code]
int location = 12 - ((esi >>> 5) << 2);
ebp = Copy[location];
[/code]
May 31, 2004, 7:22 PM
iago
[quote author=impersonating members is bad! link=board=34;threadid=6867;start=30#msg62975 date=1086031356]
[code]
int location = 12 - ((esi >>> 5) << 2);
ebp = Copy[location];
[/code]
[/quote]

That won't work because of different pointer sizes.
June 1, 2004, 12:36 AM

Search