[asterisk-dev] Why not C++?

Power, Paul C. ppower at integratelecom.com
Wed Nov 7 13:40:58 CST 2007


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

I agree, there would be many short term bugs raised and it would be a
huge amount of work.

It is a tough thing measure the worth of the effort. I honestly do not
know how to do that.

Thank you for your answer.

I will let this percolate in the back of my mind for a (long) while.
I do not know the code or the architecture well enough right now to do
anything else.

-PCPIII




More information about the asterisk-dev mailing list