Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > C++: The Good and Bad

Reply
Thread Tools

C++: The Good and Bad

 
 
Kevin Hall
Guest
Posts: n/a
 
      01-26-2007
C++ is one of my favorite languages to work in. This is because it has
so many differrent strengths. But there is also a number of blemishes
in the language -- some could potentially be fixed, others are not
likely. I wanted to open a discussion on what people think are the
good and bad things about C++. Here are my lists:

Good things about C++
---------------------
- multi-paradigm language.
- const-specifications
- deterministic destruction
- semi-strong typed (since there are some implicit conversions allowed)
- preprocessor -- it's powerful not evil. Powerful things just often
can be used for evil purposes -- and unfortunately, the preprocessor
sometimes is used in evil ways.
- Real multiple inheritance. Again, it's powerful, not evil.
- templates -- more powerful than generics provided by other languages.
- partial template specialization.
- template meta-programming.
- SFINAE, RAII, CRTP
- Is portable to more platforms than most other languages. (This is
due in part to having fewer standard libraries.)


Bad things about C++
--------------------
- Some 'baggage': throw specifications, std::vector<bool>, 'export',
some C-baggage
- No true-typedefs; typedefs are really type aliases.
- A lot of things to learn
- Due to the way C++ has evolved, some things are more complicated than
they need to be.
- Too much undefined behavior.
- No support for properties.
- No standard for name mangling.
- No reflection capabilities.
- No garbage collection. Though, GC is often used incorrectly like the
preprocessor and multiple-inheritance. Also note that there are GC
libraries for C++ -- but there are potentially some advantages to be
gained if GC were added to the language.
- Missing libraries: (though, there are many widely available
cross-platform libraries that do fill in the gaps)
* No standardized threading model/library
* No standard GUI library. However, we should note that standard
GUI's are typically not used for state-of-the-art, fancy looking apps.
The Java standard doesn't support the newest GUI features of OSX,
Windows Vista, OpenGL, or DirectX.
* The standard libraries don't cover some very common things, like
decimal and large-integer types, the ability to handle directory
structures, etc....
* No standard way to obtain stack-traces.

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      01-27-2007
Kevin Hall wrote:
> C++ is one of my favorite languages to work in. This is because it
> has so many differrent strengths. But there is also a number of
> blemishes in the language -- some could potentially be fixed, others
> are not likely. I wanted to open a discussion on what people think
> are the good and bad things about C++. Here are my lists:
>
> Good things about C++
> ---------------------
> - multi-paradigm language.
> - const-specifications
> - deterministic destruction
> - semi-strong typed (since there are some implicit conversions
> allowed)


Is that a good thing? If it is, why is "semi-" a good thing? Would
plain strong typing with all conversions explicit be a better thing?

> - preprocessor -- it's powerful not evil. Powerful things just often
> can be used for evil purposes -- and unfortunately, the preprocessor
> sometimes is used in evil ways.


I don't believe the preprocessor is powerful enough.

> - Real multiple inheritance. Again, it's powerful, not evil.


Is there any other kind besides "real"? What other multiple inheritance
can there be?

> - templates -- more powerful than generics provided by other
> languages.


Oops... Did you mean to compare languages here? Read the FAQ.

> - partial template specialization.
> - template meta-programming.
> - SFINAE, RAII, CRTP
> - Is portable to more platforms than most other languages. (This is
> due in part to having fewer standard libraries.)


Not only libraries. Absence of explicitly sized types plays big part
in that too.

> Bad things about C++
> --------------------
> - Some 'baggage': throw specifications, std::vector<bool>, 'export',
> some C-baggage


Hos is C baggage a bad thing? Have you any idea how much code was
possible to simply bring over, compile and never worry?

> - No true-typedefs; typedefs are really type aliases.


Not sure what you mean here. What "true" typedefs do you need?

> - A lot of things to learn


You don't need a lot of things to learn. See advantage #1, you only
need to learn what you're going to apply.

> - Due to the way C++ has evolved, some things are more complicated
> than they need to be.


Like what? Keep in mind the need to provide backward compatibility.

> - Too much undefined behavior.


What would you do instead? Define it and limit the chances for
optimizers to work, or define it and limit the number of platforms
C++ would be possible to implement on?

> - No support for properties.


What do you mean?

> - No standard for name mangling.


Why would you need it? C++ is source-code portable. Why would you
need standard in name mangling?

> - No reflection capabilities.


You mean, built-in, right? Well, how much do you need provided for
you? After all, what are the programmers for?

> - No garbage collection. Though, GC is often used incorrectly like
> the preprocessor and multiple-inheritance. Also note that there are
> GC libraries for C++ -- but there are potentially some advantages to
> be gained if GC were added to the language.


Like what, for example?

> - Missing libraries: (though, there are many widely available
> cross-platform libraries that do fill in the gaps)
> * No standardized threading model/library


There isn't any across as many platforms as C++ covers.

> * No standard GUI library. However, we should note that standard
> GUI's are typically not used for state-of-the-art, fancy looking apps.
> The Java standard doesn't support the newest GUI features of OSX,
> Windows Vista, OpenGL, or DirectX.


Again, it would only be applicable to a very few platforms. Why
would you want to define something that cannot be used everywhere
where the language can be used?

> * The standard libraries don't cover some very common things, like
> decimal and large-integer types, the ability to handle directory
> structures, etc....


What's a decimal type? Large-integer types are platform-specific,
and C++ doesn't prohibit their existence. Most implementations have
some additional types provided, and they work just fine. Making
those part of the language is simply impossible without sacrificing
the ability of the compilers to do what they need to optimize the
programs.

> * No standard way to obtain stack-traces.


And why do you need that? Isn't that what the debuggers are for?

It all sounds like you've lived too much in <insert your interpreted
language here> land. Snap out of it!

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      01-27-2007
Victor Bazarov wrote:
> Kevin Hall wrote:
>
>>- No standard for name mangling.

>
> Why would you need it? C++ is source-code portable. Why would you
> need standard in name mangling?
>

I can go along with this one, try linking library X built with compiler
A into an application built with compiler B.

<OT> As a real example, look at KDE, a great desktop, but if you want to
build something to link into its libraries, or Qt, you have to use the
same compiler that was used to build them. </OT>

--
Ian Collins.
 
Reply With Quote
 
Kevin Hall
Guest
Posts: n/a
 
      01-27-2007
Victor Bazarov wrote:
> Kevin Hall wrote:
> > - semi-strong typed (since there are some implicit conversions
> > allowed)Is that a good thing?

> If it is, why is "semi-" a good thing? Would
> plain strong typing with all conversions explicit be a better thing?


There are some implicit conversions which are OK (integer to double
conversion for example). But I appreciate the strong typing elsewhere.

> > - preprocessor -- it's powerful not evil. Powerful things just often
> > can be used for evil purposes -- and unfortunately, the preprocessor
> > sometimes is used in evil ways.

> I don't believe the preprocessor is powerful enough.


Yes, it can be more powerful. C99 brings a tiny bit more power. But
something more powerful that is standardized would be nice.

> > - Real multiple inheritance. Again, it's powerful, not evil.

> Is there any other kind besides "real"? What other multiple inheritance
> can there be?


Yes, there are many people that say inheriting multiple interfaces is a
type of MI and is good enough (some even say it's better). I disagree.

> > - templates -- more powerful than generics provided by other
> > languages.

> Oops... Did you mean to compare languages here? Read the FAQ.


Not in the sense of 'what is better -- language X or C++'. But if
something can be learned from features implemented in other languages,
then so be it. (Besides, there is no 'official' FAQ for this
unmoderated group -- despite what some FAQs claim. This was discussed
not too long ago in this forum.)

> > - Is portable to more platforms than most other languages. (This is
> > due in part to having fewer standard libraries.)Not only libraries.

> Absence of explicitly sized types plays big part in that too.


True. C99's <stdint.h> will help a little bit when C++0x standardizes
C++'s use of it.

> > - Some 'baggage': throw specifications, std::vector<bool>, 'export',
> > some C-baggage

> Hos is C baggage a bad thing? Have you any idea how much code was
> possible to simply bring over, compile and never worry?


Please note that I said 'some' -- not all. I think that backwards
compatibility with C is a wonderful thing. But as we all know, C++ is
not 100% compatible with C. '\0' is a char in C++, whereas it is a int
in C.

Anyway, I'm having trouble thinking of the examples of the top of my
head, but there are some things inherited from C that are more vexing
(to me anyway) than if that compatibility had been dropped.

> > - No true-typedefs; typedefs are really type aliases.

> Not sure what you mean here. What "true" typedefs do you need?


"true typedefs" means that a typedef and its base type are different
types in the language type-system. In otherwords: 'bar Foo(bar);' and
'int Foo(int);' describe two different functions if bar is typedef'ed
as an int.

There are many articles online and parts of books written about "true"
typedefs. Here's one online reference (look halfway down the page):
http://www.artima.com/cppsource/typesafety3.html

> > - A lot of things to learn

> You don't need a lot of things to learn. See advantage #1, you only
> need to learn what you're going to apply.


True.

> > - Due to the way C++ has evolved, some things are more complicated
> > than they need to be.

>
> Like what? Keep in mind the need to provide backward compatibility.


I understand backward compatibility is a good thing. Nevertheless,
there are downsides to it too. std::vector<bool>. is one such example.
As far as I can tell, it was known before the standard was finally
released that std::vector<bool> could not fully act like a container,
but it was kept anyway. And if you really need a genuine vector of
booleans then you have to jump through hoops to get one.

> > - Too much undefined behavior.

> What would you do instead? Define it and limit the chances for
> optimizers to work, or define it and limit the number of platforms
> C++ would be possible to implement on?


I said 'too much', not 'C++ has UB'. Even people on the standards
comittee and other people commonly held up as C++ experts like
Alexandrescu say there is *too much* UB.

I don't argue that some UB is needed.

> > - No support for properties.

> What do you mean?


See MS's __declspec(property):
http://msdn2.microsoft.com/en-us/lib...hd(VS.80).aspx

Again, there are many articles and chapters of books written on how to
simulate properties to C++.

> > - No standard for name mangling.

> Why would you need it? C++ is source-code portable. Why would you
> need standard in name mangling?


To support inter-compiler libraries, a standard way for other languages
to tap into C++'s APIs. Other languages usually can only tap into
functions declared as 'extern "C"'. If there were a standard for name
mangling, then it would be easier to tap into C++ interfaces.

> > - No reflection capabilities.

> You mean, built-in, right? Well, how much do you need provided for
> you? After all, what are the programmers for?


Yes, I meant built-in. Reflection would make some things a lot easier
-- for example finding the names of enumeration values.

> > - No garbage collection. Though, GC is often used incorrectly like
> > the preprocessor and multiple-inheritance. Also note that there are
> > GC libraries for C++ -- but there are potentially some advantages to
> > be gained if GC were added to the language.

> Like what, for example?


COW strings (and other COW objects) would be easier to implement.

> > - Missing libraries: (though, there are many widely available
> > cross-platform libraries that do fill in the gaps)
> > * No standardized threading model/libraryThere isn't any across as many platforms as C++ covers.

>
> > * No standard GUI library. However, we should note that standard
> > GUI's are typically not used for state-of-the-art, fancy looking apps.
> > The Java standard doesn't support the newest GUI features of OSX,
> > Windows Vista, OpenGL, or DirectX.

> Again, it would only be applicable to a very few platforms. Why
> would you want to define something that cannot be used everywhere
> where the language can be used?


There are advantages to defining something that can't be used
everywhere. If you need to do something, and that something is
available, then there is a standard way to use it. The POSIX standard
is very popular, but it can't be used everywhere.

Some other languages have thrived on having standard GUIs -- even
though the look and feel of those GUIs seem quite dated.

> > * The standard libraries don't cover some very common things, like
> > decimal and large-integer types, the ability to handle directory
> > structures, etc....

> What's a decimal type?


http://www.google.com/search?hl=en&p...a+type&spell=1.

> Large-integer types are platform-specific,
> and C++ doesn't prohibit their existence. Most implementations have
> some additional types provided, and they work just fine. Making
> those part of the language is simply impossible without sacrificing
> the ability of the compilers to do what they need to optimize the
> programs.


Why would it sacrifice the ability of compiler to do what they need to
optimize the programs?

std::complex<> was standardized. The STL was standardized. Why can't
we have a large integer template?

> > * No standard way to obtain stack-traces.

> And why do you need that? Isn't that what the debuggers are for?


*sigh*... stack-traces are very useful for logging in applications that
are released to customers. When attached to exceptions, they are also
very useful in tracking down intermittent errors customers experience.

 
Reply With Quote
 
Pete Becker
Guest
Posts: n/a
 
      01-27-2007
Ian Collins wrote:
> Victor Bazarov wrote:
>> Kevin Hall wrote:
>>
>>> - No standard for name mangling.

>> Why would you need it? C++ is source-code portable. Why would you
>> need standard in name mangling?
>>

> I can go along with this one, try linking library X built with compiler
> A into an application built with compiler B.
>


Which is why having different name mangling is good. Unless, of course,
you also want to standardize object layout. That's a much bigger job.

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
 
Reply With Quote
 
Cesar Rabak
Guest
Posts: n/a
 
      01-27-2007
Pete Becker escreveu:
> Ian Collins wrote:
>> Victor Bazarov wrote:
>>> Kevin Hall wrote:
>>>
>>>> - No standard for name mangling.
>>> Why would you need it? C++ is source-code portable. Why would you
>>> need standard in name mangling?
>>>

>> I can go along with this one, try linking library X built with compiler
>> A into an application built with compiler B.
>>

>
> Which is why having different name mangling is good. Unless, of course,
> you also want to standardize object layout.
>

Yes! Why not?
> That's a much bigger job.


But worth of it!
 
Reply With Quote
 
Noah Roberts
Guest
Posts: n/a
 
      01-27-2007
Cesar Rabak wrote:
> Pete Becker escreveu:
>> Ian Collins wrote:
>>> Victor Bazarov wrote:
>>>> Kevin Hall wrote:
>>>>
>>>>> - No standard for name mangling.
>>>> Why would you need it? C++ is source-code portable. Why would you
>>>> need standard in name mangling?
>>>>
>>> I can go along with this one, try linking library X built with compiler
>>> A into an application built with compiler B.
>>>

>>
>> Which is why having different name mangling is good. Unless, of
>> course, you also want to standardize object layout.

> Yes! Why not?


Because, the C++ standard makes a great point of not standardizing too
much. If object layout was standardized, beyond the minimum that it is,
then first of all the standard would become much larger and it would
take longer to release. Second, and more importantly, if the object
layout was specified by the standard then that is the object layout
everyone would have to use...whether it is good for the platform or not.
With the additional time it would take to specify a standard we would
have a situation in which we're stuck with an object layout based on
obsolete understandings and hardware for 20+ years.

By specifying such details the C++ standard would quickly become rigid
and unresponsive to change. The language would become obsolete very
quickly.
 
Reply With Quote
 
.rhavin grobert
Guest
Posts: n/a
 
      01-27-2007
On 27 Jan., 00:55, "Kevin Hall" <kevindhall.j...@yahoo.com> wrote:
> Bad things about C++

i would add the fact i can ask whether a definition is defined but
cant ask if a type is defined ... really nasty and senseless.

 
Reply With Quote
 
Grizlyk
Guest
Posts: n/a
 
      01-27-2007
Kevin Hall wrote:
> C++ is one of my favorite languages to work in. This is because it has
> so many differrent strengths.


This is because no other languages in the world, that can be used as C++ and
because it is easyer to everybody to continue apply old language instead of
new one.

> But there is also a number of blemishes
> in the language -- some could potentially be fixed, others are not
> likely. I wanted to open a discussion on what people think are the
> good and bad things about C++.


C++ has many "holes" and "bad places", and at least ten big of them known
for me. All of them can be easy eliminated.

--
Maksim A Polyanin


 
Reply With Quote
 
Grizlyk
Guest
Posts: n/a
 
      01-27-2007
> C++ has many "holes" and "bad places", and at least ten big of them known
> for me. All of them can be easy eliminated.


Ņan be easy eliminated by C++ standard and compiler improvements, not by
programmers.

--
Maksim A Polyanin


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
integer >= 1 == True and integer.0 == False is bad, bad, bad!!! rantingrick Python 44 07-13-2010 06:33 PM
Bad media, bad files or bad Nero? John Computer Information 23 01-08-2008 09:17 PM
ActiveX apologetic Larry Seltzer... "Sun paid for malicious ActiveX code, and Firefox is bad, bad bad baad. please use ActiveX, it's secure and nice!" (ok, the last part is irony on my part) fernando.cassia@gmail.com Java 0 04-16-2005 10:05 PM
24 Season 3 Bad Bad Bad (Spoiler) nospam@nospam.com DVD Video 12 02-23-2005 03:28 AM
24 Season 3 Bad Bad Bad (Spoiler) nospam@nospam.com DVD Video 0 02-19-2005 01:10 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57