News for hackers. Stuff that matters.
Re:How to C in 2016 by kazinator on Friday January 08, 2016 @11:23AM (#10865971)
If, for some inputs, the program is supposed to calculate the value 42, but it throws an integer overflow, then it is not correct.

Detecting overflows and throwing nice exceptions instead of continuing execution with garbage values isn't the same thing as ensuring correctness.

Re:How to C in 2016 by ealloc on Friday January 08, 2016 @12:00PM (#10866310)
Is it really the case that some programming languages are more resilient to hardware errors than others?

Java does array bounds checking in principle, but it is usually optimized out of the machine code. Isn't it then virtually just as susceptible to hardware error as C? And the JVM is written in C anyway.

Re:How to C in 2016 by lmm on Friday January 08, 2016 @12:28PM (#10866545)
The JVM is written in C, but that C has been subject to some formal analysis. And even if it hadn't, I'd bet the defect rate of a Java program running on a C JVM would be much much lower than that of a C program.
Re:How to C in 2016 by kazinator on Friday January 08, 2016 @01:09PM (#10866863)
But, in keeping with this topic, that C has not been subject to formal analysis from the angle of defending against rays doing random things to the CPU and RAM or other hardware errors.
Re:How to C in 2016 by unscaled on Friday January 08, 2016 @09:42PM (#10869844)
So let's stop unit testing all of our code, since it's provably incorrect anyways, due to cosmic rays flipping random bits of RAM once in every gazillion calculations.
Re:How to C in 2016 by pjmlp on Saturday January 09, 2016 @05:07PM (#10873094)
> And the JVM is written in C anyway.

Which one?

https://en.wikipedia.org/wiki/List_of_Java_virtual_machines

Depending which one we are speaking about, they are implemented in Assembly, C, C++ or even Java.

Re:How to C in 2016 by kazinator on Friday January 08, 2016 @12:25PM (#10866517)
This has been the subject of some papers, like

https://www.cs.princeton.edu/~appel/papers/memerr.pdf [2003]