[asterisk-dev] Why not C++?
Dmitry Andrianov
dimas at dataart.com
Wed Nov 7 13:53:44 CST 2007
> relying on stuff like this just adds SOOOO much overhead to code that
> needs to be fast its unreal.
No idea where you got this number.
>it also hides a lot of the stuff a good programmer likes to have
>control of like making sure startup and cleanup are actually symetric,
I would say exactly opposite - making proper cleanup IS problem in C
because from time to time developer forgets freeing ont of resources
when he does return from the middle of big function where C++
destructors work like a charm.
>and knowing that there is no hidden stuff around structures that need
>to be exactly as they are laid out to map onto something else.
Again, if you want plain struct you can laid it out any way you want. If
you talking about classes, then of course they get extra.
C++ just makes _some_ aspects simpler. It does not remove from developer
the responsibility to understand what he writes and what that code
translates into.
-----Original Message-----
From: asterisk-dev-bounces at lists.digium.com
[mailto:asterisk-dev-bounces at lists.digium.com] On Behalf Of Jon Pounder
Sent: Wednesday, November 07, 2007 10:31 PM
To: asterisk-dev at lists.digium.com
Subject: Re: [asterisk-dev] Why not C++?
Quoting Matthew Nicholson <mnicholson at digium.com>:
> On Wed, 2007-11-07 at 12:21 -0600, Power, Paul C. wrote:
>> All-
>>
>> I was wondering why Asterisk is not written in C++ or if
>> there is any interest in having Asterisk written in C++.
>>
>> I have been watching the list of bugs and other proposed
>> changes to asterisk (fast-ast2).
>> It has occurred to me there may be great values in leveraging
>> something like the BOOST libraries to take care of some of
>> the minutiae that seems to cause problems.
>>
>> I am thinking mostly collecitons, threading, string processing.
>>
>> If this have been discussed before, could some one direct me to it?
>>
>> I am interested in hearing any and ALL opinions!
relying on stuff like this just adds SOOOO much overhead to code that
needs to be fast its unreal.
it also hides a lot of the stuff a good programmer likes to have
control of like making sure startup and cleanup are actually symetric,
and knowing that there is no hidden stuff around structures that need
to be exactly as they are laid out to map onto something else.
the problem is everyone learning to program in the last 10-15 years
relies on this stuff so heavily the art of really programming is
becoming lost, and no one knows how to make something more efficient
when they need to since they didn't write 90% of the code or even know
how it works internally.
>
> I ask myself the same question every time I have to write asterisk
code.
> We use C macros where C++ templates could go, we use C structs and a
> collection of functions where a C++ class could go, we write our own
> string manipulation library where the std::string class could be used,
> and lots of other stuff. Over time I have thought of several reasons
> why asterisk is not written and should not be rewritten in C++ (of
> course there are a lot of reasons why it should be written in C++ but
> I'll leave those out).
>
> 1. Most of the developers know C better then they know C++ (if they
know
> it at all) and can probably write better code in C because of that
> knowledge.
>
> 2. Rewriting asterisk in C++ would probably introduce more bugs then
it
> would fix in the short run, and the tremendous effort to accomplish
this
> is not worth the cost IMO.
>
> 3. When the asterisk project was started, g++ was not nearly as good
as
> it is today, causing people to shy away from it (see number 4).
>
> 4. C++ has a bad rep (mostly unjustified). For some examples of this
> google for "linux kernel C++".
>
>
> Theoretically you could slowly rewrite asterisk in C++, but whenever I
> catch myself thinking like that I always conclude that it is not worth
> the effort. Hope this helps. :)
> --
> Matthew Nicholson
> Digium
>
>
> _______________________________________________
> --Bandwidth and Colocation Provided by http://www.api-digital.com--
>
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-dev
>
Jon Pounder
_/_/_/ _/ _/ _/ _/_/_/ _/ _/ _/_/_/_/
_/ _/_/ _/ _/ _/ _/_/ _/ _/_/
_/ _/ _/_/ _/ _/ _/ _/_/ _/
_/_/_/ _/ _/ _/_/_/_/ _/_/_/ _/ _/ _/_/_/_/
Inline Internet Systems Inc.
Thorold, Ontario, Canada
Tools to Power Your e-Business Solutions
www.inline.net
www.ihtml.com
www.ihtmlmerchant.com
www.opayc.com
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-dev
More information about the asterisk-dev
mailing list