Linked by Eugenia Loli on Sun 16th Apr 2006 19:56 UTC
General Development 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.
Order by: Score:
v Wow
by mmebane on Mon 17th Apr 2006 03:26 UTC
v Why C++?!
by hraq on Mon 17th Apr 2006 06:12 UTC
RE: Why C++?!
by cm__ on Mon 17th Apr 2006 06:35 UTC in reply to "Why C++?!"
cm__ Member since:
2005-07-07

> 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.

Reply Score: 3

v RE[2]: Why C++?!
by mOOzilla on Mon 17th Apr 2006 08:31 UTC in reply to "RE: Why C++?!"
RE[3]: Why C++?!
by MORB on Mon 17th Apr 2006 10:01 UTC in reply to "RE[2]: Why C++?!"
MORB Member since:
2005-07-06

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++.

Reply Score: 2

RE[3]: Why C++?!
by mmebane on Mon 17th Apr 2006 14:58 UTC in reply to "RE[2]: Why C++?!"
mmebane Member since:
2005-07-06

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.

Reply Score: 1

v RE[2]: Why C++?!
by hraq on Tue 18th Apr 2006 09:35 UTC in reply to "RE: Why C++?!"
RE[3]: Why C++?!
by BryanFeeney on Tue 18th Apr 2006 11:10 UTC in reply to "RE[2]: Why C++?!"
BryanFeeney Member since:
2005-07-06

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

Reply Score: 3

RE: Why C++?!
by Celerate on Mon 17th Apr 2006 08:33 UTC in reply to "Why C++?!"
Celerate Member since:
2005-06-29

"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.

Reply Score: 4

v RE[2]: Why C++?!
by mOOzilla on Mon 17th Apr 2006 08:40 UTC in reply to "RE: Why C++?!"
RE[3]: Why C++?!
by dylansmrjones on Mon 17th Apr 2006 09:09 UTC in reply to "RE[2]: Why C++?!"
dylansmrjones Member since:
2005-10-02

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#.

Reply Score: 5

v RE[2]: Why C++?!
by mOOzilla on Mon 17th Apr 2006 08:41 UTC in reply to "RE: Why C++?!"
v RE[2]: Why C++?!
by mOOzilla on Mon 17th Apr 2006 08:42 UTC in reply to "RE: Why C++?!"
RE[3]: Why C++?!
by Celerate on Mon 17th Apr 2006 18:10 UTC in reply to "RE[2]: Why C++?!"
Celerate Member since:
2005-06-29

"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.

Reply Score: 3

RE: Why C++?!
by smitty_one_each on Mon 17th Apr 2006 09:52 UTC in reply to "Why C++?!"
smitty_one_each Member since:
2005-07-07

>20% with C#
Is there really that much .Net in Vista? I've seen reports that roughly transpose those two digits on the internet...

Reply Score: 3

v OS X
by mOOzilla on Mon 17th Apr 2006 08:28 UTC
v Modern interperted languages
by mOOzilla on Mon 17th Apr 2006 08:43 UTC
Re: Java vs C++ flamefest
by mnem0 on Mon 17th Apr 2006 10:16 UTC
mnem0
Member since:
2006-03-23

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.

Reply Score: 3

v RE: Re: Java vs C++ flamefest
by mOOzilla on Mon 17th Apr 2006 10:41 UTC in reply to "Re: Java vs C++ flamefest"
dylansmrjones Member since:
2005-10-02

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 )

Reply Score: 5

v RE[3]: Re: Java vs C++ flamefest
by mOOzilla on Mon 17th Apr 2006 11:09 UTC in reply to "RE[2]: Re: Java vs C++ flamefest"
dylansmrjones Member since:
2005-10-02

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).

Reply Score: 3

v RE[5]: Re: Java vs C++ flamefest
by mOOzilla on Mon 17th Apr 2006 11:40 UTC in reply to "RE[4]: Re: Java vs C++ flamefest"
dylansmrjones Member since:
2005-10-02

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.

Reply Score: 4

v Time required to develop
by mOOzilla on Mon 17th Apr 2006 10:43 UTC
RE: Time required to develop
by dylansmrjones on Mon 17th Apr 2006 10:59 UTC in reply to "Time required to develop"
dylansmrjones Member since:
2005-10-02

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.

Reply Score: 3

RE: Time required to develop
by twowheels on Mon 17th Apr 2006 14:31 UTC in reply to "Time required to develop"
twowheels Member since:
2005-07-06

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.

Reply Score: 4

RE[2]: Time required to develop
by Ronald Vos on Mon 17th Apr 2006 18:25 UTC in reply to "RE: Time required to develop"
Ronald Vos Member since:
2005-07-06

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.

Reply Score: 1

C++ vs Objective-C :)
by mOOzilla on Mon 17th Apr 2006 11:14 UTC
mOOzilla
Member since:
2006-04-11

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?

Reply Score: 0

v Memory consumption for large binaries
by mOOzilla on Mon 17th Apr 2006 11:43 UTC
dylansmrjones Member since:
2005-10-02

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.

Reply Score: 2

v 50 Applications
by mOOzilla on Mon 17th Apr 2006 14:37 UTC
v C++ vs C#
by mOOzilla on Mon 17th Apr 2006 14:39 UTC
RE: C++ vs C#
by dylansmrjones on Mon 17th Apr 2006 15:05 UTC in reply to "C++ vs C#"
dylansmrjones Member since:
2005-10-02

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.

Reply Score: 4

RE: C++ vs C#
by Get a Life on Mon 17th Apr 2006 18:39 UTC in reply to "C++ vs C#"
Get a Life Member since:
2006-01-01

Where can I download mOOtoolz from? I really could use a forum spammer and yours is the best on here!

Reply Score: 4

Ever Language Has its Place.
by Leoandru on Mon 17th Apr 2006 14:52 UTC
Leoandru
Member since:
2006-01-15

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.

Reply Score: 1

What is going on here?
by CaptainFlint on Mon 17th Apr 2006 19:39 UTC
CaptainFlint
Member since:
2006-01-24

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.

Reply Score: 3