4 ms·
> What's the point of the language? It's a drop-in replacement for C that is much more powerful and succinct.
by kingkongrevenge 17y ago
> What's the point of the language?
It's a drop-in replacement for C that is much more powerful and succinct.
- halostatue 17y agoThat's the theory. The reality is that it's not more succinct and it's not significantly more powerful in most cases. Yes, there are some neat things you can do with templates (and I do), and some of the syntactic sugar things you get with objects and overloading and namespaces are nice, but there's nothing that you can do in C++ that you can't do equally well in C. That said, C++ is in no way a "drop-in replacement" for C. What makes C++ "interesting" is that most of the time, you can drop C code into a C++ program and it will just work. Of course, you can do the same thing with Objective C, and the object model behind Objective C is much more sane.
- kingkongrevenge 17y ago> but there's nothing that you can do in C++ that you can't do equally well in C. I'm shocked you're saying this in seriousness. C is a simple language lacking a large number of constructs and compiler safety features of C++. You might as well argue that BASIC is just as powerful as Python. Inherently OOP problems like large simulations with huge class hierarchies could not realistically be done in C. The C++ frameworks for writing servers have no parallel in C because the language lacks required abstractions. I have never seen C code that could not be rewritten more clearly in C++.
- deleted 17y ago[deleted]
- halostatue 17y agoIMO, C++ offers no useful compiler safety features. One of the most celebrated "safety features" is const correctness. That's caused more pain in my experience than any possible value that it supports (and it has also resulted in a lot of unnecessary duplicated boilerplate code). Templates, while useful and (sometimes) fun (as long as you're not having to debug them), aren't as interesting as having a real dynamic language like Python or Ruby. I'd argue that your statement about "Inherently OOP problems" is incorrect from the first word. IMO, there's no such thing as a problem that's "inherently OOP"; there are problems which may be modeled easier in OO, but there's no problem that OOP solves that can't be solved a different way. (Why does a large simulation require a huge class hierarchy in any case? Maybe you're just Doing It Wrong.) There's also an assumption that C can't do OO, which is patently false; it's just not sugared for you like in C++. I'd love to see what "required abstractions" you think that C++ provides, because I just simply don't see them. Except maybe namespaces. Overloading is nice, but not a necessary condition. References are just a mess. Templates are overkill for a lot of things. RTTI in C++ is a joke, especially if you're working cross-platform (and dynamic_cast on older versions of g++ just don't work, and sometimes you just can't escape those older versions). All that said, I write C++ in my day job. A lot of it. But I don't pretend that anything I'm doing in C++ couldn't be done in C, possibly better and cleaner. We're designing a new set of APIs for plug-ins in our product, and we're moving toward a clean set of C-based APIs because they're (a) more portable across platforms and (b) more portable across languages so that we don't force people who want to write plug-ins for our product to use C++.