4 ms·
Maybe because Java is a more principled OO language? I'm not sure what he's getting at either but the only skill difference is manual memory management right? (
by hood_syntax 10y ago
Maybe because Java is a more principled OO language? I'm not sure what he's getting at either but the only skill difference is manual memory management right? (although that certainly isn't overly intuitive it's easier in C++ than C from what I've heard)
I don't use C++ so I could be way off base, just putting forth a possible explanation
- adrianN 10y agoC++ is completely different from Java unless you chose to write Java with C++ syntax. Modern C++ is heavy on using templates and static dispatch instead of virtual calls and inheritance. The culture is very different as well; you won't see many FactoryFactories in C++ code.
- hood_syntax 10y agoFair enough, I stand corrected.
- mistermann 10y agoIf FactoryFactories are so bad, why do Java and C# devs (even "smart" ones) still use them? Harder to decompose = more job security?
- humanrebar 10y agoI think much of the problem with FactoryFactories is naming them FactoryFactories. We don't call processes 'ProgramCounterContextCollections'. The pattern isn't bad, in fact flavors of it (if you squint) are used regularly even in low-level C systems code.
- jerven 10y agoRuntime loading of code by frameworks leads to Factory objects. e.g. database drivers. The only factory factory I know of is in the Spring runtime dependency injection framework.
- pjmlp 10y ago> you won't see many FactoryFactories in C++ code. Oh the fun of writing CORBA and DCOM....
- gjulianm 10y agoC++ is considerably more complex than Java, though. There are differences which we could consider "simple", such as operator overloading, iterators, lambdas... But then there's the templating system which is way different, and memory management can be a daunting topic (before it was just having pointers and keeping track of them, now there's the unique_ptr and the shared_ptr and the move/forward semantics if I'm not wrong) and which is also way different than in C (I don't know whether it's easier or not. In C you have malloc/free, and that might be a blessing or a course depending on the person). Also, for me the major difference is that, in C++, you have the books to learn to write C++ and then the books to learn to write good C++ code (Scott Meyers' books) which I would say are incredibly important, unlike in any other languages where you might do well without these types of books.
- humanrebar 10y ago> the only skill difference is manual memory management right? More differences off the top of my head: * 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. * C++ is full of Undefined Behavior, which officially can do anything up to and including Launch the Missiles. Undefined behavior can be caused by something as innocuous as using an iterator the wrong way. * 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++ has value semantics, not reference semantics. That means that `SomeObject a = b;` is a copy by default. Sometimes. You can write SomeObject to behave either way. Or in some quirky (probably broken) combination of the two. This seems like a little thing, but it has wide implications in all sorts of design decisions. * On the plus side, C++ culture includes determinism in cleaning up after yourself. This is related to, but different than, manual memory management. C++ has never needed a `finally` keyword and there's a good case that C++ is better for it. But it does mean that some things are subtly harder, like proper use of exceptions. C++ coders talk about 'exception safe code', a term I don't hear about in Java conversations all that often. * Java is OOP with some functional stuff mixed in. C++ is typically similar, but the "modern C++" style is increasingly moving toward something... else? Something more like the STL and less like adventures in class taxonomy. There are a lot more differences than that even, but maybe that will give everyone a flavor for how it's different. It's very different.
- 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