Linked by Thom Holwerda on Fri 3rd Feb 2012 23:43 UTC
Thread beginning with comment 505865
To view parent comment, click here.
To read all comments associated with this story, please click here.
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[3]: You're wrong. It's bad iOS developers.
by MORB on Sat 4th Feb 2012 11:34
in reply to "RE[2]: You're wrong. It's bad iOS developers."
I don't think a buggy java application doing the things you mention will survive it any better than C++.
I doubt many java developers setup exception handlers to recover gracefully (or at all) from a division by 0, an out of bound array access or trying to dereference a null pointer.
RE[4]: You're wrong. It's bad iOS developers.
by Elv13 on Sun 5th Feb 2012 20:12
in reply to "RE[3]: You're wrong. It's bad iOS developers."
The thing is, a simple try {} catch(e){printstack} autogenerated by Eclipse will usually (and often accidentally) catch them and allow the application to go on. As long as you use regular exception instead of specific one, the application will stay open without any additional/intentional work.
RE[3]: You're wrong. It's bad iOS developers.
by BeamishBoy on Sat 4th Feb 2012 17:55
in reply to "RE[2]: You're wrong. It's bad iOS developers."
RE[4]: You're wrong. It's bad iOS developers.
by MORB on Sun 5th Feb 2012 14:47
in reply to "RE[3]: You're wrong. It's bad iOS developers."
Handling a division-by-zero error in C++ is trivial. Subclass std::runtime_error and handle it like you would any other exception.
Only if you're using visual C++ and their silly structured exception handling, which is pretty bad for various reasons, including performances. Throwing an exception on a division by zero is non standard behavior.
Also, a division by 0 won't necessarily cause the program to halt. If you work with floats it will usually just yield a special type of NaN value indicating an infinite.
The best way to deal with divisions by 0 is to special case the situations where they can happen, or assert if it is never supposed to happen.
If you don't explicitly deal with the division by 0 cases it can result in either a crash (that includes uncaught exceptions) or bugged behavior, in absolutely any language.
Edited 2012-02-05 14:49 UTC





Member since:
2006-06-12
Java is not native so when it segfault, it just throw and exception and go on. While it may corrupt the application state to the point it still explode shortly after, it is not because of the fault itself, but the consequences of it. C++ application wont survive calling a method from an invalid pointer, array overflow and division per 0. It will close instantaneously.
That said, Java do suck and I code in C/C++/Lua when I can.