02Jun Cing from Java – C++ quirks
300 views
Lately I have been toying around with Visual C++ to rebuild some of my pathfinding algorithms done originally in AS3 and CSharp. While working on porting the code over, I can’t help to feel that OOP was just slapped into C++ from C. I might be getting this feeling as I use mostly Java inspired languages (yes, CSharp is also very Java inspired) that had a lot of forethought on how OOP should work and how developers implement it in their code. For example, it seems counter-intuitive to me to declare methods that float somewhere outside the class definition brackets. Also, it seems confusing to me that you declare the default values for method parameters in the method prototype and not in its definition. Additionally, why isn’t the compiler smart enough to look ahead for a function/method declaration instead of requiring the user to manually create extra code prototyping their existence. Perhaps Java-like languages has spoiled me, or I don’t see the “big picture” yet on why the language acts the way it does. Anyone from a similar background wonder the same thing about traditional C++?


June 18th, 2009 at 3:21 pm
Yes, I felt exactly the same very often. C++ is so “old school” sometimes. Still, I like it’s power.
About prototyping and header files, isn’t it though very useful when you include libraries headers? If the language itself forces you to make these files, it is easier when you share the code. Of course, decompiling to extract the type signatures, like with swc and jar would be a solution, but is this doable and effective with compiled code? And then it comes the platform jungle. At least header files can use directives to switch.