Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 10

Qt-interest Archive, March 2002
[OT] Disadvantages of C++ over C...


Message 1 in thread

Hello all,

	Can n1 list out the disadvantages of C++(or even OOPS) over 
C? Further, is there any analysis carried out on the performance of Qt and 
Gtk libraries on a standard environment. Also, why do one often encounter 
linker error(s) when static data members are used in a class?

	Thanx in advance.

regards,
vivek.

web: http://gdit.iiit.net/~vivek/


Message 2 in thread

Dnia śro 27. marzec 2002 10:20, napisałeś:
> Hello all,
>
> 	Can n1 list out the disadvantages of C++(or even OOPS) over
> C? Further, is there any analysis carried out on the performance of Qt and
> Gtk libraries on a standard environment. Also, why do one often encounter
> linker error(s) when static data members are used in a class?

There are no such things. Those "disadvantages" are simple "urban legends" 
said by people who have no idea how compiler might work. Those legends
had sense in deep past when C++ compiler was not a real compiler but 
simple preprocessor translating C++ to C.

While programming in OO programming language you're more likely to forget
thinking "how CPU will handle this code" and that might be the only reason
for slowing down the code comparing to non-OO programming language.

-- 
 [ signature omitted ] 

Message 3 in thread

>>	Can n1 list out the disadvantages of C++(or even OOPS) over
>>C?

Mariusz Lotko wrote:

> There are no such things. Those "disadvantages" are simple "urban legends" 

IMHO I find debugging C++ with complex behaviour in constructors or 
destructors, non-intuitive overloaded operators, or template classes is 
more difficult than debugging the equivalent C. When it works well, C++ 
is great, but when things don't work you might wish it was C.

All IMHO :)

-Cam


-- 
 [ signature omitted ] 

Message 4 in thread

Well, with C++ you loose binary compatibility between any two version of a
library for example, it is almost impossible to make any kind of larger
update to a C++ library and still keep it binary compatible with an older
version.

Mikael

----- Original Message -----
From: "Mariusz Lotko" <mariusz.lotko@pruftechnik.com.pl>
To: <qt-interest@trolltech.com>
Sent: Wednesday, March 27, 2002 10:55 AM
Subject: Re: [OT] Disadvantages of C++ over C... [EOT]


> Dnia śro 27. marzec 2002 10:20, napisałeś:
> > Hello all,
> >
> > Can n1 list out the disadvantages of C++(or even OOPS) over
> > C? Further, is there any analysis carried out on the performance of Qt
and
> > Gtk libraries on a standard environment. Also, why do one often
encounter
> > linker error(s) when static data members are used in a class?
>
> There are no such things. Those "disadvantages" are simple "urban legends"
> said by people who have no idea how compiler might work. Those legends
> had sense in deep past when C++ compiler was not a real compiler but
> simple preprocessor translating C++ to C.
>
> While programming in OO programming language you're more likely to forget
> thinking "how CPU will handle this code" and that might be the only reason
> for slowing down the code comparing to non-OO programming language.
>
> --
> Mariusz Lotko
> http://www.lotko.magma-net.pl/
>
> --
> List archive and information: http://qt-interest.trolltech.com


Message 5 in thread

On Wed, Mar 27, 2002 at 11:37:08PM +0100, Mikael Aronsson wrote:
> Well, with C++ you loose binary compatibility between any two version of a
> library for example, it is almost impossible to make any kind of larger
> update to a C++ library and still keep it binary compatible with an older
> version.

Nah, that's not true in my opinion. Trolltech itself shows that it's
possible to perform larger updates on qt without breaking binary
compatibility. Think for example of the introduction of Qt
properties in Qt 2.2 which were a major new feature but still
everything was binary compatible.

KDE's libraries are another example.

In fact there's quite a lot you can do to code while still
maintaining binary compatibility. Matthias Ettrich wrote a nice
summary of what's allowed and what's not allowed:
http://webcvs.kde.org/cgi-bin/cvsweb.cgi/*checkout*/developer.kde.org/documentation/kde2arch/devel-binarycompatibility.html?rev=HEAD&content-type=text/html

(sorry for the longish URL, but the original document is on a server
that just got shut down)

Simon


Message 6 in thread

On Wed, 27 Mar 2002, vivek wrote:

> 	Can n1 list out the disadvantages of C++(or even OOPS) over 
> C?

At the moment, there are 2 disadvantages of C++ (but they won't stay much 
longer):
- The ABI (binary interface) is not defined, and can vary between 
  different compiler versions (e.g. you can't compile Qt with gcc 2.96 
  and then build kdelibs with gcc 3.0).

  This disadvantage will be fixed with gcc 3.1, which finally stabilizes 
  the C++ ABI.

- Some compilers are horrible at optimizing C++ code.
  There's no such thing as "C++ is slower than C" the way some people 
  claim, but there still is a "your C++ compiler is crap and fails to
  optimize code" thing.

  This, too, is mostly fixed in the gcc 3.1 branch.

> Further, is there any analysis carried out on the performance of Qt and 
> Gtk libraries on a standard environment.

Their performance is similar and not really relevant (do you really notice 
if the pushbutton in a dialog is drawn a millisecond faster)?
The important thing is that Qt allows MUCH faster development of code.
I'd dare to bet that, if you give a Qt programmer and a gtk programmer the 
same task, the Qt programmer will need about a third of the time.

gtk's attempt at providing "classes" in a language that can't handle them 
is plain sick, and so is the fact that the functions doing the same thing 
usually have different names (e.g. read the text from a widget comes as 
widget_get_text, widget_get_label, widget_text or widget_label depending 
on what widget you're using).

> Also, why do one often encounter linker error(s) when static data 
> members are used in a class?

Never happened to me - guess you're using a broken compiler.

LLaP
bero

-- 
 [ signature omitted ] 

Message 7 in thread

On Wednesday 27 March 2002 11:38, Bernhard Rosenkraenzer wrote:
> On Wed, 27 Mar 2002, vivek wrote:
> >  Can n1 list out the disadvantages of C++(or even OOPS) over C?
>
> At the moment, there are 2 disadvantages of C++ (but they won't stay much
> longer):
> - The ABI (binary interface) is not defined, and can vary between
>   different compiler versions (e.g. you can't compile Qt with gcc 2.96
>   and then build kdelibs with gcc 3.0).
>
>   This disadvantage will be fixed with gcc 3.1, which finally stabilizes
>   the C++ ABI.
>
> - Some compilers are horrible at optimizing C++ code.
>   There's no such thing as "C++ is slower than C" the way some people
>   claim, but there still is a "your C++ compiler is crap and fails to
>   optimize code" thing.
>
>   This, too, is mostly fixed in the gcc 3.1 branch.

There is another 'disadvantage' of C++: it requires us developers to
read two additional books.

The good news is that these books are extremely helpful.
The bad news is that many previous C hackers think they don't need to
read them since they are smart enough to code in C++.

Titles:
        Effective C++
        More Effective C++

Author: Scott Meyers

Price:  unimportant, since it will save you ages of debugging and bumping
        your head against the wall...

Cheers,

  Karl-Heinz

-- 
 [ signature omitted ] 

Message 8 in thread

Bernhard Rosenkraenzer wrote:
> 
> Their performance is similar and not really relevant (do you really notice 
> if the pushbutton in a dialog is drawn a millisecond faster)?
> The important thing is that Qt allows MUCH faster development of code.
> I'd dare to bet that, if you give a Qt programmer and a gtk programmer the 
> same task, the Qt programmer will need about a third of the time.
> 

As someone who has programmed in Gtk extensively, I
can attest to this. I rewrote a program in Qt that I
had originally written in Gtk because I wanted the
cross-platform features of Qt. Writing the program in
Gtk took almost a year. Writing the same program in Qt
took 3.5 months and I'm a C++ newbie.

-- 
 [ signature omitted ]