Why oh Why do Sun do this to me?

From Visual Basic to GNU C, this is the place to talk programming.

Moderators: SecretSquirrel, just brew it!

Why oh Why do Sun do this to me?

Postposted on Fri Mar 26, 2004 7:23 pm

I've asked this question before with other people at my university, and no-ones given me a straight answer to be perfectly frank.

Why has Java not got unsigned data types? I've done two "Java Applications" programming projects so far - Data Packetisation, and Image Processing.

Both have required me to use the variable & 0xff trick to get them to output the correct numbers and values.

Surely unsigned data types are used enough in the computing world that the people at sun saw this as a potential problem. Off the top of my head I can think of the following:

- Data packetisation and image processing (both stored as bytes)
- Any form of text processing

I'm almost certain there are an uncountable number of instances where you need unsigned data types.

When Sun made HotJava, did they not think "ah, these images are unsigned byte values, why didn't we think of that?"

Such a silly omission means that I'm now doing 0xff operations all over the shop in my code. It means that:

a) My code is slower (not a biggie given current processing speeds, but one method of my image processing takes a few seconds to complete, so faster = better)

b) My code is more bloated as I'm in effect casting to an integer and then casting back to a byte again to display the image using java's default libraries... (see above bracketed comment)

c) My code is more difficult to find bugs is (trust me, I coded the damn thing :-D)

d) My code is more prone to error (what's the difference between oxff and 0xff? :-P I've noticed myself making that mistake a few times, I've managed to spot it as I wrote it though which is lucky)...

If java is based on C, why did they take this functionality out????

It beggars belief (to me at least :-D)

</rant :-D>,
-Mole
Living proof of John Gabriel's theorem
IntelMole
Grand Gerbil Poohbah
 
Posts: 3529
Joined: Sat Dec 29, 2001 7:00 pm
Location: The nearest pub

Postposted on Fri Mar 26, 2004 8:58 pm

Did a quick google and came up with this.

http://software.topcoder.com/catalog/c_ ... 3016&ver=1
Yahoolian
Grand Gerbil Poohbah
 
Posts: 3576
Joined: Sun Feb 16, 2003 3:43 pm
Location: MD

Postposted on Fri Mar 26, 2004 9:36 pm

That requires money. And how do you create a primitive data type in java? I wasn't aware that was possible :-D

So, as I see it, even that is an object. Which makes it a fudge. I could create an integer object like that too. I'm not going to though, because it's no less a fudge than what I'm doing now.

Besides, the question still stands: What were the idiots at sun thinking when they removed unsigned variable functionality from Java?

It's baffling me something chronic :-D,
-Mole
Living proof of John Gabriel's theorem
IntelMole
Grand Gerbil Poohbah
 
Posts: 3529
Joined: Sat Dec 29, 2001 7:00 pm
Location: The nearest pub

Postposted on Fri Mar 26, 2004 9:48 pm

If it wasn't in there in the first place, there was nothing to remove.

Java was supposed to have the best of C/C++, and removing the bad parts.
Last edited by Yahoolian on Fri Mar 26, 2004 9:48 pm, edited 1 time in total.
Yahoolian
Grand Gerbil Poohbah
 
Posts: 3576
Joined: Sun Feb 16, 2003 3:43 pm
Location: MD

Postposted on Fri Mar 26, 2004 9:48 pm

They had to have SOMEthing to differentiate it from other modern languages!
Buub
Maximum Gerbil
Silver subscriber
 
 
Posts: 4204
Joined: Sat Nov 09, 2002 11:59 pm
Location: Seattle, WA

Postposted on Fri Mar 26, 2004 9:58 pm

Yahoolian wrote:If it wasn't in there in the first place, there was nothing to remove.

Java was supposed to have the best of C/C++, and removing the bad parts.


It WAS there in the first place, that's the whole point. Java was supposed to take the best bits of C.

Surely a requirement for a half decent stab at a language (instead of a mish-mash of styles, which I'm still convinced that java is to this day) would be an unsigned integer type.

And buub, yes that's about the best answer I have, but it has one fatal flaw: Java already HAS that!

- It's cross-platform
- It has automatic garbage collection
- You don't need to know anything about pointers to use it.

There are three factors that differentiate it from C/C++

So I STILL don't have an answer :-P,
-Mole
Living proof of John Gabriel's theorem
IntelMole
Grand Gerbil Poohbah
 
Posts: 3529
Joined: Sat Dec 29, 2001 7:00 pm
Location: The nearest pub

Postposted on Fri Mar 26, 2004 9:58 pm

Because James Gosling thinks you're too stupid to know how to use it.
In programming language design, one of the standard problems is that the language grows so complex that nobody can understand it. One of the little experiments I tried was asking people about the rules for unsigned arithmetic in C. It turns out nobody understands how unsigned arithmetic in C works. There are a few obvious things that people understand, but many people don't understand it.
http://www.javaworld.com/javaworld/javaone01/j1-01-gosling-p2.html

I'll just point out that C# has unsigned types, along with enumerations (or does Java have those now?) and delegates, and nobody seems to have a problem with them.
UberGerbil
Gerbil Khan
 
Posts: 9993
Joined: Thu Jun 19, 2003 3:11 pm

Postposted on Fri Mar 26, 2004 10:02 pm

Java was supposed to take the best bits of C.


And your definition of best bits is different from those who created java.
Yahoolian
Grand Gerbil Poohbah
 
Posts: 3576
Joined: Sun Feb 16, 2003 3:43 pm
Location: MD

Postposted on Fri Mar 26, 2004 10:03 pm

UberGerbil wrote:Because James Gosling thinks you're too stupid to know how to use it.
In programming language design, one of the standard problems is that the language grows so complex that nobody can understand it. One of the little experiments I tried was asking people about the rules for unsigned arithmetic in C. It turns out nobody understands how unsigned arithmetic in C works. There are a few obvious things that people understand, but many people don't understand it.
http://www.javaworld.com/javaworld/javaone01/j1-01-gosling-p2.html

I'll just point out that C# has unsigned types, along with enumerations (or does Java have those now?) and delegates, and nobody seems to have a problem with them.


Hmm... the rules of unsigned arithmetic??? What's he talking about? Or does he just refer to whatever it in a weird way...?
-Mole
Living proof of John Gabriel's theorem
IntelMole
Grand Gerbil Poohbah
 
Posts: 3529
Joined: Sat Dec 29, 2001 7:00 pm
Location: The nearest pub

Postposted on Tue Mar 30, 2004 4:32 pm

IntelMole wrote:And buub, yes that's about the best answer I have, but it has one fatal flaw: Java already HAS that!

- It's cross-platform
- It has automatic garbage collection
- You don't need to know anything about pointers to use it.

There are three factors that differentiate it from C/C++

Well, of course I was joking, but...
- It's cross-platform

Perl, Python, C, C++, TCL/Tk, PHP, etc.
- It has automatic garbage collection

... which is not always your best choice for efficiency or resource usage; it just makes it easier on the programmer.
Perl, Python, C#, etc.
- You don't need to know anything about pointers to use it.

Pointer are a double-edged sword. They're the very reason that C/C++ was so powerful when it first came out. It allows you to be high-level, but still get down to the bare metal when necessary. They are not just evil. They are both evil and good.
Pretty much any language besides C/C++


But those are really the fundamental differences between C++ and something like Java, aren't they? C++ gives you as many tools as possible, so you can do as many different things as possible in as many different ways as possible. Including the tools to shoot yourself in the foot, should you so choose.
Java (and C#, etc.) choose to enforce a paradigm "vision" on you. Adhere to the vision to gain their benefits. But try to do things differently and you need to move to a different language tool.
Buub
Maximum Gerbil
Silver subscriber
 
 
Posts: 4204
Joined: Sat Nov 09, 2002 11:59 pm
Location: Seattle, WA

Postposted on Tue Mar 30, 2004 4:49 pm

I didn't know that the same code in C works on PCs and Macs without recompilation? Granted both C and Java would need "tweaking" or they would run dog-slow in certain situations, but the principle stands...

And pointers are a double edged sword yeah I know. But at the same time, working in Java without them sometimes increases the bloat factor a fair bit, in terms of the sheer number of parameters, local and instance variables you have to play with...

Anyways, we're getting away from the main question, that I still haven't got an answer to. If there's some really good reason why this is, please tell me :-D,
-Mole
Living proof of John Gabriel's theorem
IntelMole
Grand Gerbil Poohbah
 
Posts: 3529
Joined: Sat Dec 29, 2001 7:00 pm
Location: The nearest pub

Postposted on Tue Mar 30, 2004 5:02 pm

I dont know but can you please post a picture of your rig. I nearly **** my pants when i saw your sig. :)
Shuttle SN25P nForce4 & A64 4000 939 90nm
1024MB Corsair XMS PC3200 CAS2
ATI RADEON X850XT 256MB PCIE
Dual 74GB 10K WD RaptoRAID XP Pro SP2
JediNinjaWizards
Irritating Rash
 
Posts: 1627
Joined: Tue Aug 19, 2003 9:46 am
Location: Player's Republic of Pimpachusetts

Postposted on Tue Mar 30, 2004 5:24 pm

........ to shoot yourself in the foot, should you so choose.......


Are you a College professor ?

I had a College professor always say that phrase ? is that like something that every C/C++ kiddie learns the first day ?

Actually it probably is, since i learned that on the first day as well.
or at least was told....
Bye.
Lordneo
Gerbil First Class
 
Posts: 116
Joined: Fri Jun 14, 2002 11:57 pm
Location: Virginia !!! Mucho nicer then Dirty NYC

Postposted on Tue Mar 30, 2004 7:19 pm

JediNinjaWizards wrote:I dont know but can you please post a picture of your rig. I nearly sh*t my pants when i saw your sig. :)


Good point, that needs updating these days.

That was my old computer. I worked with that slug for about 4 years, until last October when I moved to university.

The computers there are all about the 2Ghz mark or so Athlons or Celerons or Pentium 4s.... However, I believe there to be a few 486s if you look hard enough...

http://www.bath.ac.uk

The current computer is a laptop (so I can cart it to and from uni)...

P4-M 533fsb 2.8GHz.
512 RAM
40Gb HDD
1024x768 LCD screen
DVD-RW drive
GeForce4Go something or other. Piece of crap :-D

Anyways, it gets me there...
-Mole
Living proof of John Gabriel's theorem
IntelMole
Grand Gerbil Poohbah
 
Posts: 3529
Joined: Sat Dec 29, 2001 7:00 pm
Location: The nearest pub

Postposted on Tue Mar 30, 2004 9:07 pm

Lordneo wrote:
........ to shoot yourself in the foot, should you so choose.......


Are you a College professor ?

Heh, thank God, no. Otherwise I'd spend all my time pondering theory rather than writing actual code. :-)

I had a College professor always say that phrase ? is that like something that every C/C++ kiddie learns the first day ?

I think it's just that the quote applies so well. C++ is a great big box full of very sharp tools. How's that? :-)
Buub
Maximum Gerbil
Silver subscriber
 
 
Posts: 4204
Joined: Sat Nov 09, 2002 11:59 pm
Location: Seattle, WA


Return to Developer's Den

Who is online

Users browsing this forum: No registered users and 4 guests