[asterisk-dev] Why not C++?

Jon Pounder JonP at inline.net
Wed Nov 7 13:30:49 CST 2007


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.





More information about the asterisk-dev mailing list