3 ms·
Is it? It suggests that typical Java code is for some reason full of run time type errors which it isn't. Whatever the differences between and respective advant
by pvg 8y ago
Is it? It suggests that typical Java code is for some reason full of run time type errors which it isn't. Whatever the differences between and respective advantages and disadvantages of Java and C++, runtime type errors are just not a some typical Java problem, let alone one that C++ solves.
- koala_man 8y ago>which it isn't NullPointerException is a run time type error and quite common. I'm not convinced it's a problem C++ adequately solves, though.
- pvg 8y agoYou can take a view of types that is broader than the one Java actually uses such that an NPE is a 'runtime type error' but you can do that with lots of runtime errors. It's not what the poster is talking about.
- koala_man 8y agoYou sure could -- Coq programmers might say that any error is a runtime type error. I don't think NPEs go much beyond Java's own definition though. If you have a reference to a String, it's not necessarily of type String. You'd get a runtime error if you try to treat it as such, just like you would in Python. This is not the case in C++, though obviously it's not an example of template metaprogramming.