3 ms·
> * Java gets a lot of benefit from having Object as the base class of nearly everything. It would be a long write-up to explore all the implications, but suffi
by bbatha 10y ago
> * Java gets a lot of benefit from having Object as the base class of nearly everything. It would be a long write-up to explore all the implications, but suffice it to say that the new C++ `any` and `variant` are attempts to get some of the features that Java has been taking for granted for decades.
Counter point, C++'s templates and preference for value types means that downcasting is rarely needed. `variant` also has no equivalent direct equivalent in Java, because it can only be "downcast" to one of the named variants whereas `Object` can be downcast to any type in the program.
> * C++ has barely any reflection mechanisms, which sounds like no big deal, but it prevents things that Java programmers take for granted, like high-powered debuggers, standard off-the-shelf database abstraction layers, and dependency injection mechanisms.
C++ prefers to do its metaprogramming at compile time. For instance you can get type safe sql[1]. C++ added features needed to do this kind of work only recently in C++11, and has not had the time or the guidance from the language committee for these types of libraries to gestate. Whereas Java has standardized library interfaces for just about anything.
Regarding debugging, C++ has excellent debugging tools. While its true Java can give the debugger more information, C++ gives you more predictable execution (by not having a JIT) which can make debugging easier.
[1] https://github.com/rbock/sqlpp11 https://github.com/rbock/sqlpp11
- humanrebar 10y ago> Counter point, ... downcasting is rarely needed. Dunno if that's a counterpoint. I'll agree everything you said there. I was saying Java uses the downcast in a lot of situations that C++ doesn't. And it uses downcast to achieve features that are not there or not as developed in the C++ ecosystem. It looks like C++ is ready to catch up, but these things need to percolate through the library ecosystem over time. > C++ prefers to do its metaprogramming at compile time. Terminology is a little muddled here, but I was talking about both compile time and run time metaprogramming. C++ has little support for either while Java has a pretty robust system for each. Java has things like JMX, JMS, and JDBC Template as standard things while C++ has at best a hodge-podge of things that don't necessarily play nice with each other.