Discussion:
[asterisk-users] Why write your dialplan using Lua?
José Pablo Méndez Soto
2012-01-06 18:51:36 UTC
Permalink
Hello,

Reading through the Wiki:

"Asterisk supports the ability to write dialplan instructions in the Lua
programming language. This method can be used as an alternative to or in
combination with extensions.conf and/or AEL. PBX lua allows users to use
the full power of lua to develop telephony applications using Asterisk"

My question is, what is the benefit of using Lua? I recently noticed that
OpenSIPS added a compatibility module to use Lua as well. However, where is
the real advantage here?

I mean, you have all these pieces in Asterisk like Lego blocks: AGI
Commands, AMI Actions, Dialplan Applications, Dialplan Functions which I
think are the ones that really limit what the PBX can do right?

What's the difference between calling them out from extensions.conf or even
from extensions.ael and calling them from extensions.lua? What else can you
do writing you dialplan in Lua? Could I maybe program N-Way calling* with
it?

Are we talking about expanding Asterisk capabilities a huge deal? Or just
performance wise during dialplan execution?

With OpenSIPS I understand its power because you may affect the SIP
behavior based on db queries performed by Lua scripts, or modify the next
message to be sent, but with Asterisk, you wouldn't be able to modify an
ongoing session through Lua based on, e.g., an incoming INVITE to establish
a new conference room, would you? Or tell Asterisk to save the
Register-CallID of an endpoint as part of the sip peer settings in memory,
like the contact ID field.

Regards,

*José Pablo Méndez


**By N-Way calling I mean having one party on hold, calling another party,
and immediate (ad-hoc) invoke a conference bridge to join the 3 parties.
Just like Cisco phone systems do. *
*****
Steve Edwards
2012-01-06 19:12:36 UTC
Permalink
Post by José Pablo Méndez Soto
My question is, what is the benefit of using Lua?
I've never used Lua, but I also have a curiosity about it.

A couple of years ago, I wrote my first dialplan in AEL. Some bits were
clumsy, minor syntax errors caused major parts of my dialplan to
disappear, and I discovered a bunch of bugs*.

But, many parts were elegant. Bits that would have been an ugly mess in
'plain dialplan' seemed obvious and clear.

I would expect a similar experience with Lua. Kind of an opposite '1984**'
experience.

If you take the jump, please post your experiences.

*) This was in 1.2 so there was no benefit in reporting the bugs.

**) In Orwell's 1984, the 'scope' of language was reduced to eliminate the
ability to express subversive thoughts.
--
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards ***@sedwards.com Voice: +1-760-468-3867 PST
Newline Fax: +1-760-731-3000
José Pablo Méndez Soto
2012-01-06 19:33:07 UTC
Permalink
I wouldn't jump to a whole different language just to have an elegant
script plan. There must be another reason why Lua is being so widely
implemented than elegance and execution performance.

Anyone?

*José Pablo Méndez
*********
Post by José Pablo Méndez Soto
My question is, what is the benefit of using Lua?
I've never used Lua, but I also have a curiosity about it.
A couple of years ago, I wrote my first dialplan in AEL. Some bits were
clumsy, minor syntax errors caused major parts of my dialplan to disappear,
and I discovered a bunch of bugs*.
But, many parts were elegant. Bits that would have been an ugly mess in
'plain dialplan' seemed obvious and clear.
I would expect a similar experience with Lua. Kind of an opposite '1984**'
experience.
If you take the jump, please post your experiences.
*) This was in 1.2 so there was no benefit in reporting the bugs.
**) In Orwell's 1984, the 'scope' of language was reduced to eliminate the
ability to express subversive thoughts.
--
Thanks in advance,
------------------------------**------------------------------**
-------------
Newline Fax: +1-760-731-3000
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
http://www.asterisk.org/hello
asterisk-users mailing list
http://lists.digium.com/mailman/listinfo/asterisk-users
Steve Edwards
2012-01-06 20:55:57 UTC
Permalink
Post by José Pablo Méndez Soto
I wouldn't jump to a whole different language just to have an elegant
script plan.
I would and probably will.

Maybe it's just me, but I look at a dialplan filled with database access,
conditional gotos and priority labels and my eyes just glaze over. Rarely
do people write dialplans with consistent and sufficient whitespace.

The ability to express a 'program' or concept clearly (elegance is a bit
more subjective) is IMO one of the attributes that 'separates the men from
the boys' as far as programmers are concerned.

If you place any value in the old axiom that 80% of a program's life cycle
cost is in maintenance, anything that eases "the next guy's" burden is a
win.

Even though I am usually 'the next guy' on my own code, being able to
quickly see what was intended a couple of years ago and make changes
without destroying the original flow is a big win.

Being able to use if, while, switch, etc. allows me to clearly express
myself. I'm looking forward to see what Lua brings to the party.
--
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards ***@sedwards.com Voice: +1-760-468-3867 PST
Newline Fax: +1-760-731-3000
Danny Nicholas
2012-01-06 20:58:37 UTC
Permalink
Not to "purposely" open a flame war here, but is lua preferable to ael?
Aren't we better off just properly documenting our original conf files since
new changes often introduce "bad opportunities"?

-----Original Message-----
From: asterisk-users-***@lists.digium.com
[mailto:asterisk-users-***@lists.digium.com] On Behalf Of Steve Edwards
Sent: Friday, January 06, 2012 2:56 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] Why write your dialplan using Lua?
Post by José Pablo Méndez Soto
I wouldn't jump to a whole different language just to have an elegant
script plan.
I would and probably will.

Maybe it's just me, but I look at a dialplan filled with database access,
conditional gotos and priority labels and my eyes just glaze over. Rarely do
people write dialplans with consistent and sufficient whitespace.

The ability to express a 'program' or concept clearly (elegance is a bit
more subjective) is IMO one of the attributes that 'separates the men from
the boys' as far as programmers are concerned.

If you place any value in the old axiom that 80% of a program's life cycle
cost is in maintenance, anything that eases "the next guy's" burden is a
win.

Even though I am usually 'the next guy' on my own code, being able to
quickly see what was intended a couple of years ago and make changes without
destroying the original flow is a big win.

Being able to use if, while, switch, etc. allows me to clearly express
myself. I'm looking forward to see what Lua brings to the party.

--
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards ***@sedwards.com Voice: +1-760-468-3867 PST
Newline Fax: +1-760-731-3000
Steve Edwards
2012-01-06 21:28:27 UTC
Permalink
Post by Danny Nicholas
Not to "purposely" open a flame war here, but is lua preferable to ael?
Aren't we better off just properly documenting our original conf files
since new changes often introduce "bad opportunities"?
One of the advantages of Lua is that it is embedded in other applications
so you can 'leverage' the learning investment.

Kind of like why you write your AGIs in Perl and I do in C. It's what we
already know and we don't have to overcome 'yet another language' inertia.

AEL was a big win for me over 'conf.' I'm hoping that Lua will be a big
win over AEL.

One thing does concern me...

Here we are all discussing something we don't know anything about and
nobody has chimed in with their experiences. If nobody is using it, how
many 'arrows' will I get in my back when I blaze that trail?
--
Thanks in advance,
-------------------------------------------------------------------------
Steve Edwards ***@sedwards.com Voice: +1-760-468-3867 PST
Newline Fax: +1-760-731-3000
José Pablo Méndez Soto
2012-01-06 23:06:05 UTC
Permalink
Ok so its not a cosmetic thing only. I eases your administration. Do a
point for performance.

Now, what about my questions regarding extending the systems caps by
building things asterisk could not build by itself. does it hold true?
Post by Danny Nicholas
Not to "purposely" open a flame war here, but is lua preferable to ael?
Post by Danny Nicholas
Aren't we better off just properly documenting our original conf files
since new changes often introduce "bad opportunities"?
One of the advantages of Lua is that it is embedded in other applications
so you can 'leverage' the learning investment.
Kind of like why you write your AGIs in Perl and I do in C. It's what we
already know and we don't have to overcome 'yet another language' inertia.
AEL was a big win for me over 'conf.' I'm hoping that Lua will be a big
win over AEL.
One thing does concern me...
Here we are all discussing something we don't know anything about and
nobody has chimed in with their experiences. If nobody is using it, how
many 'arrows' will I get in my back when I blaze that trail?
--
Thanks in advance,
------------------------------**------------------------------**
-------------
Newline Fax: +1-760-731-3000
--
______________________________**______________________________**_________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
http://www.asterisk.org/hello
asterisk-users mailing list
http://lists.digium.com/**mailman/listinfo/asterisk-**users<http://lists.digium.com/mailman/listinfo/asterisk-users>
Loading...