Defect removal is preferred over defect survival. If some defect slips through the cracks, however, the C++ exception handling mechanism helps to fortify your software’s fault tolerance, as Cameron and Tracey Hughes explain. Also, elsewhere on the same site, old maps were marked with the phrase “Here be Dragons” to help seafarers steer away from dangerous places; in programming the best way to avoid dealing with bad code is to avoid writing it. Diomidis Spinellis points out 10 giveaways to spot bad code that you (or others) may have written.
What is it with OSNews and Informit?
Microsoft next windows vista was written 80% with C, and 20% with C# nothing with C++. Linux Kernels, Linux added GUIs are all written with C; So why not to drop C++ and start using Java ($JAVA = C++ – @Bugs;) or stick to the old ANSI C language?!
> Linux added GUIs are all written with C
Not true. The best one (IMHO), KDE, is written in C++.
And I just compared the number of jobs at jobpilot that contain the respective terms:
Java: 2772
C++: 2184
C#: 644
So C++ is hardly irrelevant.
2184 jobs for how many unemployed? Thats hardly relevent, you should have posted percentages. Look at sourceforge stats also. Its mostly because everybody see’s programming == C++ == EGO++. Its mostly ignorance and ego that drives people to use C++ thesedays. Personally Im tired of C++ and the inherent problems associated with it, Im sure over 50% of the usage of C++ is misuse where it would be better to use higher level languages.
I was brought into a company where this guy had no MFC and C++ experience but he wanted to go that way from VB6 just because he wanted to learn it and it was cool. WTF! I just shoved him the C# box and told him to do that. He wanted C++/MFC for a 6 month project from UML to shipping with NO experience. What a tosser and companies put “techie geeks” like him in the limelight cuz theyre techies?!!!
In my experience, people who can’t write proper C++ code can’t write proper Java or .net code either.
That’s because most of the mistake people do with C++ are not language specific, and are generally related to poor object oriented design.
And please do not make such strong amalgam between C++ and MFC. MFC is a piece of shit that violate a lot of common sense rules, like making sure that a constructed object is a fully working one instead of having a separate initialisation.
MFC apps are a pain in the ass to maintain, but it’s because of MFC, not C++.
I think most of the problems with C++ come from people who don’t know how to use STL and Boost and reinvent the wheel for everything they do.
“Not true. The best one (IMHO), KDE, is written in C++. ”
Not true. The best one (In the biggest linux ditributors like redhat and novell),GNOME (and GTK+), is written in C.
Is this why Fedora was recently considering dumping Evolution – one of the star GTK+ apps – because it was so buggy and unmaintained[1]? Is this why it took Gnome six hard month’s work to change their file-selector when KDE changed it in a week without any fuss at all? Or perhaps it’s the reason why all major new Gnome applications have been written in C# (Beagle, Muine, F-Photo, etc.).
There are a number of reasons why C is inferior to C++. These include:
1. No easy error handling, you either have to wrap every function call in an if statement or create your own exception system using macros, setjmp() and longjmp()
2. An awkward, unsafe, and inefficient[2] string system
3. No support for name-spaces or classes, which leads to awkward function names like
gtk_window_set_size (win, 300, 400);
instead of
using gtk;
win.setSize (300, 500);
4. No innate support for object orientation, which leads to awkward syntaxes for libraries (inheritance in paricular is especially messy).
5. No easy support for inheritance, leading to unfortunate amounts of copy-and-paste coding, which increases the number of possible bugs, and decreases the probability of finding and fixing all bugs.
The best example of this is this article: http://www-128.ibm.com/developerworks/opensource/library/os-gtk2/ It gives source examples in C, C# and Python. The C version is by far the hardest to comprehend. C++/Qt and C++/KDE are far superior to C/GTK+ when it comes to developing applications. That the Gnome developers have made more usable applications is a testament to their committment, not to their tools.
[1] http://lwn.net/Articles/179628/ (Becomes viewable to non-subscribers next Thursday)
[2] http://www.joelonsoftware.com/articles/fog0000000319.html
Edited 2006-04-18 11:16
“So why not to drop C++ and start using Java”
I went the other way, I learned how to program using Java and then I went to C++; It’s a decision I don’t regret.
This is obviously subjective, but I fell that C++ is still the best language for desktop applications and games. Java and .net are becomming industry favourites today because more and more fickle businesses are turning to network geared programing languages, and those fit the bill. C++ still runs much faster and has more power to it, it’s mature and quite stable, and in my opinion it has set a benchmark for desktop programming languages which has yet to be matched or surpassed. There’s a reason legacy languages are still around, and still make up the foundations for computer softare today.
And before you argue my point about C++ being faster than Java or .net by pointing me to some Sun Microsystems, Microsoft, or other third party payed off by the industry statistics you should know that I trust my own observations over people payed to blur the truth. I have a computer which is still fast by today’s standards, and I notice a significant speed difference between apps written with legacy languages and apps written with modern interpreted languages.
C++ was not designed as an “application” language so arnt you relaly using a screwdriver to bang in a nail?
C++ is a fine application language. So is Object Pascal and C#, and several other languages.
The problem with C++ (and C) is the amount of traps which can easily result in bad code, with equally bad consequences. Sloppy code practices do not have the same large consequences with Java, C# and Object Pascal. And that’s the main difference.
C++ is well suited for applications, but puts much more responsibility on the programmer than does Java and C#.
Did you write 100% of your “application” in this “systems” lanugage C++ or did you mix and match the best tools for the job? Im curious because there is such a stigma against mixing languages.
Modern interpreted languages? Can you give examples of these interpreted languages that you tested that are run LINE BY LINE and not COMPILED? Inquiring minds would like to know.
“Modern interpreted languages? Can you give examples of these interpreted languages that you tested that are run LINE BY LINE and not COMPILED? Inquiring minds would like to know.”
Before I start here’s a few points:
– I never said anything about interpreted languages being run line by line, based on your last two replies you either didn’t read or didn’t understand what I said.
– Have you ever heard of the falling rock analogy for code? Many languages including compiled ones are run line by line with exceptions (multithreading, function calls, etc…).
– Even though I never implied what you claim I did, I’ll bite.
Interpreters can do JIT compilation right away but that can cause the application to start much slower if it’s done wrong: as more code is written and more use of unique parts of the API happens, more time is needed for the program to be completely compiled at start. So instead of compiling everything at once, the interpreters spread out the work by pre-compiling the most frequently used code in advance, and compiling what they need when they need it. It slows down overall speed of the application, but makes sure the startup time doesn’t span several minutes or hours.
I’m not going to delve deep into this because I suspect this could turn into a case of arguing into absurdity; however, if you want to see the pros and cons first hand, go grab yourself a Java bitecode or MSIL compiled program and try running it, then try running a comparable and equally well written C++ program and see for yourself which runs faster. Here’s a hint, if they were equivalent programs and equally well written the C++ program should run faster, and the difference increases almost exponentially as you try it on older and older computers.
>20% with C#
Is there really that much .Net in Vista? I’ve seen reports that roughly transpose those two digits on the internet…
more than 80% of OS X is written in Objective-C again it avoids C++ completely even encouraged by Apple.
Pitty OS X is not a great place for alternative languages though, yes there are some but nowhere enough needed to encourage migration to OS X.
Im thinking you are confusing BBC Basic with C#, the first is interpreted and the latter is COMPILED either early or late compiled but still COMPILED.
The differences are:
* If you put in the time required, C++ will generate a much better product to the end-user. In particular, fast startup times and less weird dependencies. My friend wrote a bitTorrent client (uTorrent) that consists of a single 150kb exe file. Imagine ever doing that in Java: it’s just not technically possible.
* C++ requries you to keep your .h files in sync with your .cpp files which is a PITA, especially for rapid prototyping.
* Java editing tools are a lot better. For instance, once you have used the “organize imports” (in Eclipse etc) you will never ever use another IDE that lacks this feature.
* C++ takes ages to compile. While Eclipse will compile the code on the fly as you type and underline anything that contains a syntax error.
BitTorrent client was never technically possible in Java – http://azureus.sourceforge.net/
The future is NOT managed code, nope not an ounce, the trends towards managed code projects is not rising at all.
Of course a Bittorrent client exists in Java. He didn’t say otherwise. He did claim that you cannot create an application like that in Java, if the size must be within a 150 KB-limit.
You cannot write small, fast applications in Java as such, when compared with other languages.
Azureus (which I use on GNU/Linux as well as Windows) is slow, not just at startup, but generally slow. Try clicking on a button, or a tab, try change the sort order. Azureus is a all Java apps I’ve encountered the last 8 years painfully slow and resource hungry – especially when compared with what one can do with C++, Object Pascal, C# and what not (put in Object REXX if you like ;D )
I have a 160 GB HD in my laptop and Desktops are SUPERIOR to laptops, right? So why am I crying bloody rivers over 150 KB binaries LOL
Well, take around 50 applications, multiply the size of each with a factor of 50 (resulting in the size of a typical Java application), and you’ll see why it begins to become a problem.
Compare the gigantic memory consumption of Azureus ( >100 MB typically ) with the memory consumption of muTorrent. Now imagine several such applications and suddenly a 1 GB system can do nothing but show 4 monochrome icons and possibly a mouse pointer (if you’re using 3D hardware acceleration).
with windows Vista that will bring machines with min 2 GB ram and 4 possibly. I have enough memory and I do not run many apps at the same time. Im not a datacenter Next sad excuse for sticking to C++?
What about the 98% who have less than 512 MB of RAM?
Just because you’re going to have a machine with 4 GB of RAM, doesn’t mean the rest of us does. Or are we supposed to upgrade constantly just so YOU can produce sloppy code?
Fact is that developing in C++ takes no more time than developing in other languages.
If you do it right, you can easily and speedily create a great application with a minimal resource usage – if you want to. And many companies still developes in C++, no matter what a certain troll in here wants us to believe.
Unmanaged systems languages like C++ and managed lanaguages like Java and C# is much shorter which is what companies demand nowdays. Shorder dev cycles. C++ just does not come into the picture here.
With the right tools C++ is equally good.
Ever tried using a RAD-environment for C++ ?
Eclipse is not all that good. It does no more than what I’d expect. But it does it well, of course.
Java and C# (and managed code in general) is not all that fantastic. It’s basically just a lame excuse for sloppy code practices.
A bad programmer is a bad programmer in any language.
As for managed vs. unmanaged languages, I haven’t used a raw pointer in C++ for at least 6 months unless I was maintaining code from others or using a 3rd party library that required it. {even in those cases I get it into a scoped class ASAP}
Learn the std library & boost, it’s easy to write solid code.
I’ve seen a case where a protocol was implemented in C++ & C# at the same time. I saw the C++ code finished first, be more stable, and have better performance.
I’ve seen a case where a protocol was implemented in C++ & C# at the same time. I saw the C++ code finished first, be more stable, and have better performance.
That’s a highly trivial example. Which project had more coders? Whose coders had more experience/were better hackers? If C# is a better language but the better hackers on site are stubbornly clinging to C++, then C++ will come better out of any test. And vice versa.
I never code in Java, I hate the thing. I would like to see more Objective-C in windows but MS is on the C++ bandwaggon unfortunately, is there any objective-C compilers / debuggers that integrate with Visual Studio?
Well, lets see what I could run on my machine for my use, Applications possibly run at the same time.
OpenOffice Writer – not a problem I run maybe 2 or 3 documents.
BitTorrent client – Not a problem I only run one.
PDF reader – Not a problem
Browser – Not a problem I run tabs in a single instance maybe 2 instances
Email client – Yup only one needed there
Games – Well I can only play one at a time and usually its the only instance of any app running for speed and bandwidth.
Instant messenger – Not a problem I run one, some people run 3 still not a problem.
What 50 Applications do people use, inquiring minds wish to know
Don’t assume that everybody has the same application usage as you.
Don’t forget to count in services, and applets, JVM and so on.
Ok, What 50 Applications are YOU running at the same time?
thats APPLICATIONS not system services and runtimes
Ive seen cases where C++ was more unstable than C#. Manupulation. Fact is, alot use C++ inappropriately and cry but its 150kb in size! Then again those are the people who run Linux with bash and no UI and claim to live on 128MB machines with 2MB gfx ram. You are not my target audience for my applications.
Uuh?
muTorrent is a Windows-only app, with a GUI naturally. It’s what Azureus should’ve been.
When a P4 3200 with 1 GB of RAM isn’t enough to run an application well, then there’s something wrong with the application. That’ll even be true if it was a Duron 1600 with 512 MB.
If your app feels sluggish on such machines, your app is worth nothing.
Where can I download mOOtoolz from? I really could use a forum spammer and yours is the best on here!
I think every language has its place. I learned C, C++, Java and C# in that order and I use them all depending on the application and users being targeted. While C and C++ are very good development languages, I see the enterprise apps being ruled by Java. Desktop apps can be written in any of those languages mentioned, but I don’t see why we should argue whats slow, fast, small or large. If you don’t like just don’t use it, today their so much more alternatives when you speak of desktop apps. While some people may say azureus is slow, the speed is acceptable to me and I like the features, I’m not going to bitch and say it should have been written in C++. I’d just go find a C++ client and be happy. I don’t use C++ that much compared to C and Java, but at the same time I can’t argue that its not suitable for any particular purpose.
Is it just me or is the article about C++ exclusively? Where did the comparison with Java or any other language for that matter come in? If you want to use C++ or Java or C# or any other language, do so by all means. Arguing on here will not do you or your language of choice any favours. You won’t change anyone’s opinion about their favourite language. Why waste time trying to accomplish the impossible? Just use what you want and do not corrupt discussions by introducing malignant off topic and unreleated arguments.