Scott Meyers on C++ Complexity
-
Rohde wrote:
What's the point in driving a big car if the road is yellow?
1. The wizard will not help people who drive small cars. 2. It's pretty tough to fit a tin man in the back seat of a small car. 3. Oz is a long way from here, so ride in comfort. ---------- Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peters
-
Kevin McFarlane wrote:
3. Every language has its flaws. What are the three things you dislike
Just because you dislike the complexity does not mean it is a "flaw". A Garage full of tools for building Automobiles is very complex. What would you rather use, Legos? Perhaps you should try the "Plain English Compiler". Where is Osmobi-wan when you need him? :-D
led mike wrote:
Just because you dislike the complexity does not mean it is a "flaw".
Well, this is Scott Meyer saying this rather than me. And he obviously likes C++, though he dislikes its complexity. However, I would say that. 1. Some things are inherently complex. 2. These complex things can be implemented in more or less complex ways. Example The implementation of MI in C++ is deemed complex. The implementation of MI in Eiffel is far simpler, though I daresay it may still have some complexity. Many features in C++ are more complex than they could have been. Much of this is due to its having to maintain backward compatibility with C but not all. Of course it's far easier to pick holes in something than it is to come up with an alternative oneself! :) Kevin
-
Kevin McFarlane wrote:
3. Every language has its flaws. What are the three things you dislike
Just because you dislike the complexity does not mean it is a "flaw". A Garage full of tools for building Automobiles is very complex. What would you rather use, Legos? Perhaps you should try the "Plain English Compiler". Where is Osmobi-wan when you need him? :-D
led mike wrote:
Osmobi-wan
That's funny! LOL! :) ¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF!
-
John Cardinal wrote:
The whole fundamental concept of the application *had* to change and with it came a need for tools to match that foundation. You're talking about putting lipstick on a pig not really fundamentally fixing anything that we've had to put up with as developers for far too long.
I disagree. However....
John Cardinal wrote:
I guess my perspective is just different than some because my livelihood depends on time to market and richness of features in my applications and we don't have a cast of thousands of c++
When you add that we see that for your criteria you are in fact correct. The generalization is still incorrect. For your criteria a garbage collector and New and Improved class library makes it "easy" to throw applications together. Chris points out that if MS wanted to they could have built those 2 things for the C++ platform as could anyone. That of course would not have attracted the millions of VB drag n droppers to the platform so they made a "business" decision not a "technical" one. People that shudder and at the idea of memory allocation and faint at the sound of pointers should stay with the garbage collectors. :)
Last modified: Tuesday, June 13, 2006 10:18:11 AM -- go ahead and ask me what a pointer sounds like, I can take it!
Well I guess time will tell but I can tell you I've written a hell of a lot of c++ and c before that and I can think of exactly zero rewarding memories of time spent writing memory allocation code and hunting down bad pointers. Life's just too short for it. I don't think there is such a thing as a prototypical VB Drag n Dropper, sure we get pointed out to the worst examples of this kind here on a semi regular basis but I suspect there are a lot of excellent programmers who code VB all the time because the job or the situation requires it. Personally I prefer c# and I find very little of the drag n drop convenienece MS added to the IDE actually works better than coding it by hand, but I don't think it's reasonable to make sweeping generalizations about any group of people. I would say that rather than making it easier to "throw" applications together which I'm guessing by the tone of that means bad applications quickly created and poorly implemented I would contest it's exactly the opposite in fact: When you are freed from having to hand hold the memory management and hunt for a good encryption routine etc etc ad infinitum you actually have time to devote to creating a very good application that performs well, is intuitive and easy to use and popular with customers. That's always the bottom line and .net gives a developer (particularly in a smaller shop) more time to devote to that. In my mind using c++ to develop application software is almost criminally negligent to shareholders and anyone else who pays the bills for the development costs of an application.
-
3. Every language has its flaws. What are the three things you dislike most strongly in C++? I'd like to answer this question with "complexity, complexity, complexity!", but naming the same thing three times is cheating. Still, I think that C++'s greatest weakness is complexity. For almost every rule in C++, there are exceptions, and often there are exceptions to the exceptions. For example, const objects can't be modified, unless you cast away their constness, in which case they can, unless they were originally defined to be const, in which case the attempted modifications yield undefined behavior. As another example, names in base classes are visible in derived classes, unless the base class is instantiated from a template, in which case they're not, unless the derived class has employed a using declaration for them, in which case they are. http://www.bookpool.com/ct/98031[^] Kevin
I enjoy reading Scott Meyers, but he often makes mountains out of molehills and freaks out over things you simply don't need to freak out about. I'd say that the problem with C++ is that it CAN be complex, not that it is. But this is true of any truly useable computer language, including C#. BTW, I crack up when I hear people saying how C# has fixed their memory leak problems. How about resource leak problems? How many developers truly understand IDisposable? How many have watched your memory usage in .NET skyrocket even though objects should have been deleted automatically? I like C#, but in the end, I am spending way to much time trying to get .NET to do things Microsoft didn't design for (I have to P/Invoke WAY too often) and wresting with complex garbage collection issues. Ultimately, despite having worked with C# for over two years, I am still more productive in C++. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
-
I enjoy reading Scott Meyers, but he often makes mountains out of molehills and freaks out over things you simply don't need to freak out about. I'd say that the problem with C++ is that it CAN be complex, not that it is. But this is true of any truly useable computer language, including C#. BTW, I crack up when I hear people saying how C# has fixed their memory leak problems. How about resource leak problems? How many developers truly understand IDisposable? How many have watched your memory usage in .NET skyrocket even though objects should have been deleted automatically? I like C#, but in the end, I am spending way to much time trying to get .NET to do things Microsoft didn't design for (I have to P/Invoke WAY too often) and wresting with complex garbage collection issues. Ultimately, despite having worked with C# for over two years, I am still more productive in C++. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
Joe Woodbury wrote:
I'd say that the problem with C++ is that it CAN be complex, not that it is. But this is true of any truly useable computer language, including C#.
C++ is clearly the most complex of the high-level languages.
Joe Woodbury wrote:
BTW, I crack up when I hear people saying how C# has fixed their memory leak problems. How about resource leak problems?
Nothing can solve all problems. But one class of problem is greatly ameliorated. For example a huge number of security vulnerabilities, e.g., buffer overruns, are caused by memory management mistakes in C/C++ (mostly C, I suspect). This class of problems is eliminated in Java and C#. But the critique of GC seems to be analogous to : "Seatbelts can't always save your life, so we shouldn't wear seatbelts at all."
Joe Woodbury wrote:
Ultimately, despite having worked with C# for over two years, I am still more productive in C++.
My take on C++ is that I don't mind it if I've written it myself. But if I have to matian C++ vs. maintaining C#, give me the latter. Kevin
-
Joe Woodbury wrote:
I'd say that the problem with C++ is that it CAN be complex, not that it is. But this is true of any truly useable computer language, including C#.
C++ is clearly the most complex of the high-level languages.
Joe Woodbury wrote:
BTW, I crack up when I hear people saying how C# has fixed their memory leak problems. How about resource leak problems?
Nothing can solve all problems. But one class of problem is greatly ameliorated. For example a huge number of security vulnerabilities, e.g., buffer overruns, are caused by memory management mistakes in C/C++ (mostly C, I suspect). This class of problems is eliminated in Java and C#. But the critique of GC seems to be analogous to : "Seatbelts can't always save your life, so we shouldn't wear seatbelts at all."
Joe Woodbury wrote:
Ultimately, despite having worked with C# for over two years, I am still more productive in C++.
My take on C++ is that I don't mind it if I've written it myself. But if I have to matian C++ vs. maintaining C#, give me the latter. Kevin
Kevin McFarlane wrote:
This class of problems is eliminated in Java and C#.
And substituted by other ones.
Kevin McFarlane wrote:
But the critique of GC seems to be analogous to : "Seatbelts can't always save your life, so we shouldn't wear seatbelts at all."
When dealing with system resources, you MUST understand IDisposable and how and when to use it if you want to handle resources correctly in .NET. How this was construed to say that the GC shouldn't be used is beyond me. Beyond that, the GC isn't some magical thing; to write good code a developer should know as much about it as possible. Unfortunately, I've all to often run into the attitude that since Java and C# have garbage collection, object destruction is no longer a concern. I categorically reject that. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
-
Yes exactly right which is why it's going to become a fringe language for specialty applications. In our shop we've absolutely without a shadow of a doubt found that c# is a much more productive and maintainable language and it's cheaper to develop and maintain applications written in c# than in c++. Personally I love c# and wouldn't go back to c++ for anything, I understand how there are a lot of people here with a lot of investment in learning and becoming wizards in c++, but any programmer who has worked for more than a couple of decades will tell you that you just have to get used to letting go of a lot of knowledge on a regular basis. That's the bottom line, however we feel about it as programmers.
-
You know I'm with you on the c# thing and increasingly I'm finding it hard to think of any software application appropriate to code in c++.
-
Yes exactly right which is why it's going to become a fringe language for specialty applications. In our shop we've absolutely without a shadow of a doubt found that c# is a much more productive and maintainable language and it's cheaper to develop and maintain applications written in c# than in c++. Personally I love c# and wouldn't go back to c++ for anything, I understand how there are a lot of people here with a lot of investment in learning and becoming wizards in c++, but any programmer who has worked for more than a couple of decades will tell you that you just have to get used to letting go of a lot of knowledge on a regular basis. That's the bottom line, however we feel about it as programmers.
John Cardinal wrote:
In our shop we've absolutely without a shadow of a doubt found that c# is a much more productive and maintainable language and it's cheaper to develop and maintain applications written in c# than in c++.
That is only true for people who know how to write quality code. I spent a lot of time yelling to fellow students who wrote very very crappy code. All they replied was "Wtf are you talking about, it works doesn't it?". In C# you can make a huge mess of your application without even knowing it. I C++, if you even pass the compiler, anyone can see the bad results.
John Cardinal wrote:
Personally I love c# and wouldn't go back to c++ for anything, I understand how there are a lot of people here with a lot of investment in learning and becoming wizards in c++, but any programmer who has worked for more than a couple of decades will tell you that you just have to get used to letting go of a lot of knowledge on a regular basis.
I don't think that a C++ developer has to let go a lot of knowledge on a regular basis. I have a better understanding of C#, garbage collection, and some base classes based on my C++ knowledge than any other student who didn't code in C++. They just take everything for granted. Just like the time when I was doing a network simulation application with a few students. They just didn't understand the complete network interface. I'm glad that there was a fellow C++ developer who understood the concept of cleaning up resources. If that guy wasn't there, the whole DirectX part would've failed... Behind every great black man... ... is the police. - Conspiracy brother Blog[^]
-
3. Every language has its flaws. What are the three things you dislike most strongly in C++? I'd like to answer this question with "complexity, complexity, complexity!", but naming the same thing three times is cheating. Still, I think that C++'s greatest weakness is complexity. For almost every rule in C++, there are exceptions, and often there are exceptions to the exceptions. For example, const objects can't be modified, unless you cast away their constness, in which case they can, unless they were originally defined to be const, in which case the attempted modifications yield undefined behavior. As another example, names in base classes are visible in derived classes, unless the base class is instantiated from a template, in which case they're not, unless the derived class has employed a using declaration for them, in which case they are. http://www.bookpool.com/ct/98031[^] Kevin
Hi there, it seems as Kevin want to start a wholehearted discussion regarding advantages and weaknesses of C++. Unbelievable but the discussion ends with breakfast tips and driving cars on yellow roads. Hey guys please don't waste server space from codeproject in that way:rolleyes:. May the force be with you
-
Rocky Moore wrote:
I am not sure I would classify anything in C/C++ as a flaw.
As Scott says, all programming languages have flaws. It's just a question of how many.
Rocky Moore wrote:
In the right hands with the right amount of time, good solid code can be designed and implemented.
That applies to all languages. But some are less error-prone than others.
Rocky Moore wrote:
There are shortcomings compared to other languages and at the same time, there are advantages.
Yes, I'm certainly not advocating throwing it away! :) Howver, it's generally a much more pleasant experience using languages such as C#. I do miss thing such as STL but C# (.NET really) is getting more and more of that power, e.g., see PowerCollections. Kevin
Kevin McFarlane wrote:
but C# (.NET really) is getting more and more of that power, e.g., see PowerCollections.
Yeah, I remember back when people were outraged by the simple thought that an OS would be built in that bloated, memory hungry, poor coded C language and that any OS worth its salt must be build in assembler. Language and platforms move on and so should developers as time permits ;) I personally think the OS's and programming tools of today are pathetic compared to where we should be by now. We went through about 10 years of very little progress. I should be able to at least pick up my mouse and say "hello computer" ;) Rocky <>< Latest Post: Visual Studio 2005 Standard, whats missing? Blog: www.RockyMoore.com/TheCoder/[^]
-
I enjoy reading Scott Meyers, but he often makes mountains out of molehills and freaks out over things you simply don't need to freak out about. I'd say that the problem with C++ is that it CAN be complex, not that it is. But this is true of any truly useable computer language, including C#. BTW, I crack up when I hear people saying how C# has fixed their memory leak problems. How about resource leak problems? How many developers truly understand IDisposable? How many have watched your memory usage in .NET skyrocket even though objects should have been deleted automatically? I like C#, but in the end, I am spending way to much time trying to get .NET to do things Microsoft didn't design for (I have to P/Invoke WAY too often) and wresting with complex garbage collection issues. Ultimately, despite having worked with C# for over two years, I am still more productive in C++. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
Joe Woodbury wrote:
BTW, I crack up when I hear people saying how C# has fixed their memory leak problems. How about resource leak problems? How many developers truly understand IDisposable? How many have watched your memory usage in .NET skyrocket even though objects should have been deleted automatically?
Just browsing through the now many available code samples i find the same issue quite a bit. A lot of programmers are "discovering" the power of Win32 without having experienced the subtleties of Win32 and who owns what memory<- and is that even an issue? :laugh: That been said, i still prefer C# but likewise, if the mindset was to not leave it to the garbage collector and the habit of cleaning up was required, it would be *easier* methinks... a bit of an ironic twist though http://bryanallott.net/
-
Kevin McFarlane wrote:
This class of problems is eliminated in Java and C#.
And substituted by other ones.
Kevin McFarlane wrote:
But the critique of GC seems to be analogous to : "Seatbelts can't always save your life, so we shouldn't wear seatbelts at all."
When dealing with system resources, you MUST understand IDisposable and how and when to use it if you want to handle resources correctly in .NET. How this was construed to say that the GC shouldn't be used is beyond me. Beyond that, the GC isn't some magical thing; to write good code a developer should know as much about it as possible. Unfortunately, I've all to often run into the attitude that since Java and C# have garbage collection, object destruction is no longer a concern. I categorically reject that. Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
I know of three very experienced and very competent C++ developers who have moved over almost exclusively to Java in recent years. All three report that they are far more productive and able to write far more robust code now than they were able to in C++. I don't claim that any language is perfect but for your average business app. I don't see much necessity to reach for a tool such as C++. Kevin
-
I know of three very experienced and very competent C++ developers who have moved over almost exclusively to Java in recent years. All three report that they are far more productive and able to write far more robust code now than they were able to in C++. I don't claim that any language is perfect but for your average business app. I don't see much necessity to reach for a tool such as C++. Kevin
Kevin McFarlane wrote:
I don't claim that any language is perfect but for your average business app. I don't see much necessity to reach for a tool such as C++.
Depends on what you mean by business app. If you mean an application that runs on an intranet within an enterprise then I would start with .NET and would switch to something else only if there was a compelling reason to do so. If you mean a stand-alone product that will be sold commercially and run on individual computers, I would start with C++. Though a cliche, it's still true that you should pick the best tool for the job and .NET is simply not always the best tool; neither is C++, Delphi, Java. Sometimes assembly language is even the best language to use. (As a side point; I recently worked on a project with over 15 years of legacy code in it--yes, there were still remnants of the original DOS program in a few source modules--when adding features, I would often prototype them using a quick-and-dirty framework. In several cases, I tracked my hours carefully and found that it took three times longer to do anything with the legacy code than it did with brand new code. In the most extreme case, it took twenty minutes to write the prototype code and 72 hours to get that code to work in the original codebase [the funniest part was running across comments like "this code sucks, it needs to be rewritten" dated in 1997.] Interestingly, when I prototyped a rewrite in .NET, I found it still took me longer than in C++/MFC. Do remember, however, that this was a stand-alone application that had a networking component. Had it been a networking application with a stand-alone component, I'm quite sure the work would have gone faster.) Anyone who thinks he has a better idea of what's good for people than people do is a swine. - P.J. O'Rourke
-
Yes exactly right which is why it's going to become a fringe language for specialty applications. In our shop we've absolutely without a shadow of a doubt found that c# is a much more productive and maintainable language and it's cheaper to develop and maintain applications written in c# than in c++. Personally I love c# and wouldn't go back to c++ for anything, I understand how there are a lot of people here with a lot of investment in learning and becoming wizards in c++, but any programmer who has worked for more than a couple of decades will tell you that you just have to get used to letting go of a lot of knowledge on a regular basis. That's the bottom line, however we feel about it as programmers.