Just started learning Java...
I have just started learning Java but there are at least 3 thing I'm missing from c/c++/c#:
1)unsigned types
2)function pointers/delegates
3)something like .Net Framework's CodeDomProvider
If there are no Java equivalents for 2 & 3 I would give it up!
So, dear Java fans:
can you motivate me to learn Java?
[Edited by - Kambiz on May 17, 2006 12:15:46 PM]
Hahaha, what a lame message! Did you try to buy a book? Like "Head first Java" or "Core Java". First study a little, later start bitching and whining.
There are some Java books available I can use and I have read some chapters from them, I thought about using Java for my next Project to make it cross platform but if the language is so much weaker than c#(at least from my point of view... (I really need dynamic code...)) I will go with Microsoft. Why should I spend so much time learning a new language when it is useless for me?
Quote:Original post by Kambiz
1)unsigned types
There aren't any. Why exactly do you need them?
Quote:
2)function pointers/delegates
Simply declare an interface and have different classes implement it.
public interface FunctionPointer{ public int function(String a, int b, Object x);}public class Foo implements FunctionPointer{ public int function(String a, int b, Object x) { return a.length() + 5*b + x.hashCode(); }}public class Bar implements FunctionPointer{ public int function(String a, int b, Object x) { return a.indexOf('n') * b - x.toString().length() & 0x1234; }}
Quote:
3)something like .Net Framework's CodeDomProvider
Since I have no idea what this is I cannot comment on that.
Quote:Original post by Kambiz
There are some Java books available I can use and I have read some chapters from them, I thought about using Java for my next Project to make it cross platform but if the language is so much weaker than c#(at least from my point of view... (I really need dynamic code...)) I will go with Microsoft. Why should I spend so much time learning a new language when it is useless for me?
I don't think you understand what you are talking about at all. Each language has its own way of doing stuff, trying to program C++ in Java only leads to poor code and headaches.
All your so much "needed features" are done in one way or the other:
- Why in the h*** are you going to need unsigned types? Unless you are programming for embedded devices, and even so this is not a problem all the times since the data is there anyways, you would care about it?
Java developers don't use, don't need and don't want unsigned types. The only people I saw complaining about it are C++ developers trying to find a pretext for not to use it.
- What you do with "function pointers / delegates" is done with anonymous classes / listeners in Java in a much clearer way.
- I have no idea what CodeDomProvider does but have everything you could ever need for XML processing.
Java is Java, so either you make up your mind about learning it or not. The choice is yours, we don't need to prove anything to you.
Quote:
language is so much weaker than c#
Millions of people disagree with you, all over IT industry where Java is #1. In the opensource too, take a look at sourceforge.
OP: Your post (a) sure looks like a troll to me, and (b) probably belongs in General Programming anyway. But I'll bite:
Actually, there is one: 'char' is effectively 'unsigned short'.
But yeah, why do you think you need them? I can think of two reasons:
- "unsigned correctness", similar to "const correctness", which also isn't provided in Java. Well, you can choose a language according to how much type-checking you want it to do, but there are lots of people who prefer that the language check basically nothing at all at compile-time. So, to each their own.
- Optimizations where you need a value to range 0 to 255 and you want it to fit in a byte. Well, this can certainly be dealt with when you do need to: As long as you can keep track of which bytes you want to be "unsigned", just convert the signed value whenever you use it in an expression. Java promotes numeric subexpressions at least to 'int' anyway, so this is the trick:
Each bitwise-and causes the x and y to be promoted to int, and sign-extended. The 0xff literals already are ints, so nothing changes there. We use the bitwise-and to mask off the sign bits, and then multiply the new unsigned values.
Right. The main reason function pointers exist in C++ in the first place, and that C# has delegates to refine the concept, is C backwards-compatibility. You know, that non-OO language where you had to create those abstractions yourself.
Quote:Original post by Fred304Quote:Original post by Kambiz
1)unsigned types
There aren't any. Why exactly do you need them?
Actually, there is one: 'char' is effectively 'unsigned short'.
But yeah, why do you think you need them? I can think of two reasons:
- "unsigned correctness", similar to "const correctness", which also isn't provided in Java. Well, you can choose a language according to how much type-checking you want it to do, but there are lots of people who prefer that the language check basically nothing at all at compile-time. So, to each their own.
- Optimizations where you need a value to range 0 to 255 and you want it to fit in a byte. Well, this can certainly be dealt with when you do need to: As long as you can keep track of which bytes you want to be "unsigned", just convert the signed value whenever you use it in an expression. Java promotes numeric subexpressions at least to 'int' anyway, so this is the trick:
byte x, y;// laterx = (byte)200; // it stores -56, but we can recover an unsigned valuey = (byte)150; // similarlyint z = (x & 0xff) * (y & 0xff); // 30000
Each bitwise-and causes the x and y to be promoted to int, and sign-extended. The 0xff literals already are ints, so nothing changes there. We use the bitwise-and to mask off the sign bits, and then multiply the new unsigned values.
Quote:Quote:
2)function pointers/delegates
Simply declare an interface and have different classes implement it.
Right. The main reason function pointers exist in C++ in the first place, and that C# has delegates to refine the concept, is C backwards-compatibility. You know, that non-OO language where you had to create those abstractions yourself.
Quote:Original post by Kambiz
If there are no Java equivalents for 2 & 3 I would give it up!
So, dear Java fans:
can you motivate me to learn Java?
news flash: no one (with any luck) cares what language you use. if you have a question try asking it.
Quote:Original post by Kambiz
3)something like .Net Framework's CodeDomProvider
If all you want to do is compile Java to native binaries, then you might want to look into the GNU Java Compiler. If you actually want to compile code at run-time, try poking around for information on JIT (just-in-time) compiling.
Quote:Original post by programwizard
If you actually want to compile code at run-time, try poking around for information on JIT (just-in-time) compiling.
What!?
Java already does that out of the box, no one needs to worry about "getting information on JIT".
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement