Skip to main content

Script Language Choice


[ NOTE: This page was copied whole from the old mediawiki is very old by now. To paraphrase Wikipedia, it has many problems, not the least of which is objectivity. Lua solves some problems, perl solves others, and so on. Use the best tool for the job. ]

The short answer: Lua.

The more in depth answer: Use what works for you, but be aware of the limitations.

JavaScript is very popular but that doesn't make it a great choice for embedded telephony programming. It is much heavier than Lua and it uses a completely different interface method to FreeSWITCH.

Python is very popular but that doesn't make it a great choice for embedded telephony programming. It does not embed nicely like Lua does. Furthermore, most of the FreeSWITCH developers are Perl fans. :)

Perl is still popular and it is a decent choice for embedded telephony programming. However, Lua is still lighter than Perl for this sort of thing and doesn't lack any features that Perl has, including regular expressions.

Bottom line: there's just no reason not to use Lua.


It may matter, so let's compare:

Lua vs. Javascript: Script with MySQL database lookup, some simple logical decisions, creation of channel variables.

For what it is worth, Lua was 50% faster than Javascript.


JS is heavier? 50% slower? Are there benchmarks to substantiate these claims? Posted by noliver at Feb 16, 2015 14:36
tl;dr: lua INITIATION time is about 60ms, mod_v8 init is about 80ms. I didn't benchmark running the scripts, I expect the main issue is from the init delay. On a test on FreeSWITCH (Version 1.4.15 -1 64bit) I got these results:I created a hello.lua file with: freeswitch.consoleLog("WARNING", "Ho!\n")and also hello.js with: console_log("WARNING", "Ho!\n"); Then I ran in fs_cli and compared the time stamps:log debug about to init lualuarun hello.lualog debug about to init jsjsrun hello.js(make sure to include an enter when you paste so it runs right away.) I did a 3-4 tests with each, and they are relatively consistent: .06 seconds for lua to print it's debug statement and .08 seconds for javascript. So I don't think you should be overly concerned about using javascript instead of lua. Posted by avimarcus at Aug 21, 2015 04:05
what about golang? erlang? java?And need compare not simple console_log but heavy and/or long operations, ie work with radius, mysql. Lua too much stupid, even "filesize" - need custom funcs.And what about many calls and python GIL? Posted by denis at Jul 08, 2016 07:37
Interested developers are welcome to publish abbreviated excerpts of their benchmark tests with links to their full test suite. Facts are better than opinions.Contact me via my Personal page here or e-mail to the FS-Docs mailing list for editor access. Posted by boteman at Dec 21, 2016 12:26