C or C++ Development for Freeswitch Modules
Hi All, I am working on a module for Freeswitch which could benefit from C++. I have written modules before in C++ and didn't find any particular problem. However, I can't help but notice that the majority of the modules that come with Freeswitch are written in C. Is there a compelling reason to choose C over C++ for Freeswitch module development? I realise that C can produce more efficient binaries and is better suited for low latency tasks but are there any reasons aside from this? Kind Regards, Aaron
Here are some that are written in or use C++ mod_stress mod_mongo mod_mp4 mod_h323 mod_soundtouch mod_komp mod_opal mod_lua (wrapped switch_cpp + swig) mod_event_zmq mod_v8 mod_managed (wrapped switch_cpp + swig) mod_java (wrapped switch_cpp + swig) mod_perl (wrapped switch_cpp + swig) mod_python (wrapped switch_cpp + swig) So use what you want really. -- Brian West brian@freeswitch.org FreeSWITCH Solutions, LLC PO BOX 2531 Brookfield, WI 53008-2531 Twitter: @FreeSWITCH , @briankwest http://www.freeswitchbook.com http://www.freeswitchcookbook.com T: +1.918.420.9001 | F: +1.918.420.9002 | M: +1.918.424.WEST iNUM: +883 5100 1420 9001 ISN: 410*543 Skype:briankwest PGP Key: http://www.bkw.org/key.txt (AB93356707C76CED) On Mar 4, 2014, at 8:36 PM, Aaron Scott <rony@botl.au.com> wrote:
Hi All,
I am working on a module for Freeswitch which could benefit from C++. I have written modules before in C++ and didn't find any particular problem. However, I can't help but notice that the majority of the modules that come with Freeswitch are written in C. Is there a compelling reason to choose C over C++ for Freeswitch module development? I realise that C can produce more efficient binaries and is better suited for low latency tasks but are there any reasons aside from this?
Kind Regards,
Aaron
Is there a particular reason why you would favor C++ over C? I was not aware the modules Brian West pointed out were written in C++ I looked over mod_v8 source and it doesn't look any different than C Thanks. On Tue, Mar 4, 2014 at 11:56 PM, Brian West <brian@freeswitch.org> wrote:
Here are some that are written in or use C++
mod_stress mod_mongo mod_mp4 mod_h323 mod_soundtouch mod_komp mod_opal mod_lua (wrapped switch_cpp + swig) mod_event_zmq mod_v8 mod_managed (wrapped switch_cpp + swig) mod_java (wrapped switch_cpp + swig) mod_perl (wrapped switch_cpp + swig) mod_python (wrapped switch_cpp + swig)
So use what you want really.
-- Brian West brian@freeswitch.org FreeSWITCH Solutions, LLC PO BOX 2531 Brookfield, WI 53008-2531 Twitter: @FreeSWITCH , @briankwest http://www.freeswitchbook.com http://www.freeswitchcookbook.com
T: +1.918.420.9001 | F: +1.918.420.9002 | M: +1.918.424.WEST iNUM: +883 5100 1420 9001 ISN: 410*543 Skype:briankwest PGP Key: http://www.bkw.org/key.txt (AB93356707C76CED)
On Mar 4, 2014, at 8:36 PM, Aaron Scott <rony@botl.au.com> wrote:
Hi All,
I am working on a module for Freeswitch which could benefit from C++. I have written modules before in C++ and didn't find any particular problem. However, I can't help but notice that the majority of the modules that come with Freeswitch are written in C. Is there a compelling reason to choose C over C++ for Freeswitch module development? I realise that C can produce more efficient binaries and is better suited for low latency tasks but are there any reasons aside from this?
Kind Regards,
Aaron
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
The most common reason to write a module in C++ is probably that the external libraries used are written in C++. However, those modules usually use the good-old C API for FreeSWITCH. So you usually see quite a mix of C++/C in the actual code - but it is still compiled as C++. 2014-03-05 14:09 GMT+01:00 Vik Killa <vipkilla@gmail.com>:
Is there a particular reason why you would favor C++ over C? I was not aware the modules Brian West pointed out were written in C++ I looked over mod_v8 source and it doesn't look any different than C Thanks.
On Tue, Mar 4, 2014 at 11:56 PM, Brian West <brian@freeswitch.org> wrote:
Here are some that are written in or use C++
mod_stress mod_mongo mod_mp4 mod_h323 mod_soundtouch mod_komp mod_opal mod_lua (wrapped switch_cpp + swig) mod_event_zmq mod_v8 mod_managed (wrapped switch_cpp + swig) mod_java (wrapped switch_cpp + swig) mod_perl (wrapped switch_cpp + swig) mod_python (wrapped switch_cpp + swig)
So use what you want really.
-- Brian West brian@freeswitch.org FreeSWITCH Solutions, LLC PO BOX 2531 Brookfield, WI 53008-2531 Twitter: @FreeSWITCH , @briankwest http://www.freeswitchbook.com http://www.freeswitchcookbook.com
T: +1.918.420.9001 | F: +1.918.420.9002 | M: +1.918.424.WEST iNUM: +883 5100 1420 9001 ISN: 410*543 Skype:briankwest PGP Key: http://www.bkw.org/key.txt (AB93356707C76CED)
On Mar 4, 2014, at 8:36 PM, Aaron Scott <rony@botl.au.com> wrote:
Hi All,
I am working on a module for Freeswitch which could benefit from C++. I have written modules before in C++ and didn't find any particular problem. However, I can't help but notice that the majority of the modules that come with Freeswitch are written in C. Is there a compelling reason to choose C over C++ for Freeswitch module development? I realise that C can produce more efficient binaries and is better suited for low latency tasks but are there any reasons aside from this?
Kind Regards,
Aaron
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
My recommendation is just to use those parts of C++ that make sense to use. In any modules that I've ever worked on that were in C++, I avoided using exceptions, for example. You can allocate new C++ objects onto memory pools in FS (see the SwitchToMempool class in switch_cpp.h), but when you destroy the memory pools, you will need to explicitly call up a dtor on the objects if you have any further cleanup that you need to do at that point. If you inherit from this class, it will *not*, however, implicitly overload new for any type of member objects that you may need to new. -Yossi On 03/04/2014 08:36 PM, Aaron Scott wrote:
Hi All,
I am working on a module for Freeswitch which could benefit from C++. I have written modules before in C++ and didn't find any particular problem. However, I can't help but notice that the majority of the modules that come with Freeswitch are written in C. Is there a compelling reason to choose C over C++ for Freeswitch module development? I realise that C can produce more efficient binaries and is better suited for low latency tasks but are there any reasons aside from this?
Kind Regards,
Aaron
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
participants (5)
-
Aaron Scott
-
Brian West
-
I put the Who? in Mishehu
-
Peter Olsson
-
Vik Killa