Posted: May 2, 2005 6:03 PM
> "I like that C++ doesn't enforce a particular programming
> style or paradigm on you, and offers several, as they are
> useful for different purposes."
> Yes, but its not particularly good at any of them.
Could you give some examples?
- When it comes to OO, for example, C++ supports access specifiers, multiple inheritance, virtual inheritance, virtual and non-virtual functions, access and inheritance being orthogonal (you can inherit and override a private function, but not call it), and so on. Comparing with other popular languages, they tend to be rather a lot simpler when it comes to support for OO, and hence the available expressivity.
- When it comes to support for generic programming, it again shines (I've written more about that in another posting, so I won't repeat it). I can just add equal or better language support for user-defined types, as for built-in types, including operator overloading, and that it treats built-in and user-defined types the same way (so there's no inherent performance penalty for user-defined types over built-in types, unlike Java). Again, can you point to another language that does it better, and why?
- Support for structured programming. C++ gives first-class support for free functions. Languages like Java don't do that.
- Support for functional programming. This is pretty decent, with library support, but this is still an area of exploration. Other languages, like Haskell, provide this natively (but then _don't_ provide other things that C++ does, such as iteration).
- Quite good support for DSL building (Boost.Spirit being one example). One big advantage with having a DSL in the language is that it interoperates seamlessly with the language.
> prefer a nice scalpel for surgery over a swiss army knife.
The problem is when all you have is a scalpel, when doing surgery...
Naturally, C++ (like Java) is a general-purpose language, and there may well be cases where a more special-purpose language could be preferrable. Examples include DSLs like SQL, regex, HTML, etc.