|
Re: Abstraction and Efficiency
|
Posted: Feb 20, 2004 1:53 AM
|
|
Many people seem to think that C++ is about performance and thus, you are sometimes "forced" to use it even if you would prefer Java or C#. To me, this is not the issue at all. I prefer C++ over C# and Java not because of performance but because of the way it allows you to think. I find that it offers a much more diverse set of solutions to a given problem. And as Bjarne states, the type system helps you put your thoughts into order; when you have to state the type of a container, you are forced to think through what you will actually be using it for. So even if you don't accidentally put an apple into your pear vector, once you have stated the type, you've spent some time thinking through what it is that you actually want it to do.
Furthermore, I find that C++ has a certain neatness to it which is hard to describe. For instance, I have a very small class template that adds range checking to a type. Instances of this act just like int's (if the template type is int) and youi rarely notice it in the code. Combined with RAII, you get what I find to be very nice code. In Java and C#, In Java/C#, I would probably not have made a such type. Where a class in C++ seems like a "type" to me, classes in Java and C# seem more like a combination of data and code. (I realize that both are both, it's just not the same feeling). I think that C# properties emphasizes this the best; it indicates that a class has "sub elements" which you want to access more or less directly. Now I don't intend to start an "operator overloading is bad/good" discussion or anything. I am just saying that C++ is more than just a well performing language which can be used only when you optimizing.
|
|