Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×

Comment Re:Unsigned Byte (Score 1) 434

Most of this I think goes back to me not really seeing "primitive" as mattering much once you aren't going for mimicking the CPU anyway.

Good point. But then you should not have primitives outside a java.jni package anyway. Just like Smalltalk or Scala. That would then be truly OO.

Comment one complent, two complement (Score 1) 434

They don't have the same unsigned arithmetic.

That seems wrong to me. In fact it seem the wrong way around for me.

For signed binary arithmetic there are two option:

One-Complement: Where we have symmetric positive and negative ranges. Including a negative zero. Seldom used.

Two-Comlement: Where we have asymmetric positive and negative ranges. With the negative range having one extra number.

But for unsigned binary arithmetic I only know one way of doing it. 30 years of experience in the field. More then a dozen programming languages learned. Degree in computer science. I am hard pressed to even think of a different way to do unsigned binary arithmetic. Even on a purely abstract and academic level.

But one is never to old to learn something new and I a the curious type: Please enlighten me!

Comment Re:Unsigned Byte (Score 1) 434

Actually those where UTF-8 characters. slashdot.org converts the UTF+8 characters to HTML entities. Does a good job on it. But then put them out literately. Maybe I have another look at the option.

“sane subtraction 3 - 7 = -4.”

That is only sane in the centre of the valid range. But how about: X = MIN_BYTE + 3; y = x - 7;

The problem was just moved elsewhere where it is not so notable. My main critic on Java is that whenever the investors of Java encountered a difficult to implement possible feature; instead of thinking it through; finding the proper solution; the investors of Java shied away and declared it “unnecessary” or “dangerous”.

I don't blame them. AFAIK Sun what breathing down there Necks telling them to finish by X. Probably also the reason why the few difficult features which did make in (like clone ()) tuned out to be a pigs ear.

Comment Carry Flag (Score 2) 434

True. CPUs do roll over.

And thinking of it (and correcting myself): Ada does for unsigned typed as well. Not for signed. There a RANGE_ERROR is raised. Strange but sometimes useful asymmetry.

But that does not invalidate my statement. All CPU I know of (there might be others, more exotic CPUs of course) set a carry and/or overflow flag on signed and unsigned roll-overs as well. One does not exclude the other here.

In 8 bit times those flags where extremely important to do 16 bit operation with only an 8 bit arithmetic logic unit. That is why it is called carry flag. And of course you can branch on the carry flag set or unset.

Comment Operator Overloading, Optimizer (Score 1) 434

Not good enough because Java is missing another important OO Feature: operator overloading. If I may expand the title of the Article “Love for the JVM and Hate For Java”.

Also: Arithmetic contains great potential for optimisation. But for this the compiler need to know what kind of type he is dealing with:

x + 1 + 2 should be optimized to x + 3
MAX_FOO + 4 should be evaluated at compile time
x < y ||&#160;x = y should be optimized to x <= y

You can still have a library in background to be used by the compiler but the type must be part of the language. The SmallTalk approach that would be.

Anyway: For me the solution was to use Scala when ever I can.

Comment Ada and Scala (Score 1) 434

Ada gives a access to CPU unsigned types without &ldquo;implementation defined&rdquo;. Mind you Ada prescribes RANGE_ERROR on for overflows in signed types and modulo operations on unsigned types. Either way it is well defined.

Scala hides the difference between class Integer and primitive int behind a new type Int. The compiler decides automaticly if a class or primitive should be used. The quite old language SmallTalk does so as well. Primitives are only interesting when you JNI work. Worse case scenario: array of unsigned byte or short in to our out of a JNI call.

Also it should have been build into the compiler. A library is not good enough because Java has no operator overloading. Ada has, Scala has. Almost all other OO Languages have. But not Java.

Comment Unsigned Byte (Score 1) 434

How about you need 0 &#8230; 255? Very common need in computing.

Java bytes go negative => mayor pain in the arse
short could be negative and 256 onwards => if (x<0 && x> 255) destroying all speed advantages. And you need twice as much memory.

Slashdot Top Deals

The use of money is all the advantage there is to having money. -- B. Franklin

Working...