Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×

Comment Re:Assembly == SLOW ; JAVA == FAST! (Score 1) 372

I would dare you to take a 20 year old program in any language and have it run successfully on any current computer without having to do some substantial tweaking or putting that computer into some sort of historical mode of operation.

10 PRINT "HELLO, WORLD!"
20 END
RUN
HELLO, WORLD!

Yup, still works without any tweaking!

Comment Re:-Wall (Score 1) 470

We have a rule that you should always set the loop counter when starting a loop, so that it is in a clearly defined state and anyone looking at the loop can see that.

Better yet, you should always define and set the loop counter when starting a loop, e.g.,

for (int i = 0; i < imax; i++)

so that its type definition is clearly defined and anyone looking at the loop can see it. There is never any good reason for this:

int i;
...
for (i = 0; i < imax; i++)

No need to go off and hunt where it was set.

Or go off and hunt where it was defined.

Comment Re:Null pointer detection at compile time (Score 1) 470

You said, "If the compiler does anything but check to see if the pointer p is null and execute g() if p is a null pointer then the compiler is broken." I'm saying that's incorrect. Note that the compiler is full well within its right to also try to initialize x by dereferencing p, thereby causing an exception. There is no rule that int x = *p; be optimized out of existence just because it can be.

Comment Re:Is there a way to generate value besides mining (Score 1) 256

So if you want your work to be find a prime number larger than 1 trillion, after the number is found; then checking it is fast and easy.

I don't think you quite understand how prime numbers work. If it's easy to check that a number n (known to be larger than some m, for example 1 trillion) is prime, then it's also easy to find the first prime after m, due to the distribution of primes. For example, you only have to expect to test about 14 odd numbers greater than 1 trillion to find one that is prime. So if the test for primeness is "easy," then finding the first prime number larger than 1 trillion is only 14 times as much work — i.e., still "easy."

Slashdot Top Deals

I've noticed several design suggestions in your code.

Working...