[SSSD] Embedding Lua into SSSD

Nikolai Kondrashov Nikolai.Kondrashov at redhat.com
Tue Aug 25 18:26:17 UTC 2015


On 08/25/2015 08:48 PM, Simo Sorce wrote:
> On Tue, 2015-08-25 at 16:14 +0300, Nikolai Kondrashov wrote:
>> On 08/24/2015 11:54 AM, Pavel Březina wrote:
>>> On 08/21/2015 07:01 PM, Nikolai Kondrashov wrote:
>>>> I might be in a strange and careless mood today, but here is something I
>>>> wanted to suggest since the time I saw the amount of logic that goes into
>>>> SSSD and is implemented in C.
>>>>
>>>> What if we implement some of the complicated logic inside SSSD in Lua [1]?
>>>
>>> can you tell us what features of Lua do you like and might help simplify
>>> SSSD? I don't know the language, just fast scrolled over the manual and seen
>>> few examples. It seems to be similar to javascript.
>>
>> Most of all, I like its simplicity, then flexibility. And then how easy it is
>> to embed. The latter comes from simplicity, first of all.
>>
>> I listed the features I think will help us in the other message in this
>> thread, but here they are again and then some:
>>
>>       * exception handling
>>         (somewhat rudimentary, but workable)
>
> This may be interesting, but we are pretty diligent I think, thanks to
> the tevent_req design pattern, at surfacing error

Main benefit of exceptions to me is not to have to propagate errors
explicitly.

>>       * automatic memory management
>>         (incremental mark-and-sweep with good controls, customizable allocator)
>
> This is not really interesting as we already have talloc that does a
> great job at keeping track of memory allocations and cleanups (esp if we
> stop using the anti-pattern of allocating on NULL as discussed a few
> times already).

You still need to do it explicitly and think about it. Not that much, of
course, and it's not that you don't have to think about it with a
mark-and-sweep GC at all. Still, in the majority of cases you don't have
to think about it, and you certainly don't have to assign memory to contexts
and keep them, nor pass them around.

>>       * easier data massaging
>>         (string operations, built-in (limited) regexes, etc.)
>
> We do some limited string manipulation but not really much, what other
> kind of data massaging does Lua provide that makes it worth ?

Well, can't think of many specifics, ATM, but let's say easier structure
creation for example. Just stuff data into tables in any place with a succinct
syntax. Especially useful for ad-hoc single-use structuring, where writing
constructor functions is not worth it, and allocating a structure and then
assigning fields in place is a pain.

>>       * brevity
>>         (implicit dynamic typing, syntax sugar)
>
> brevity is good for long-winded functions indeed.

Well, it kind of works all through the code.

>>       * OOP support
>>         (there are several libraries to choose from)
>
> This may be good or bad, it all depends on what you need to do.

Sure. Although having something is better than not having, theoretically.
Except diseases, of course :)

> How does Lua work with asynchronous operations ? We have a ton of that
> and unless Lua has native support it would be a huge mismatch.

Now this is a good question. It depends on what you mean. If you mean central
loop with state machines underneath, then coroutines is an awesome solution.

If you mean OS threads, then there are several libraries that support it,
AFAIK. I haven't looked into them though.

We'll have to try it to really know. If you can give me an example, I can try
thinking about it.

>> I don't know enough JavaScript to really compare, but to me knowing that it
>> has two pairs of equality operators [1] is quite off-putting.
>
> I hope it doesn't compare much because javascript is awful, especially
> for anything security oriented.

Now, this is interesting. Care to elaborate? Is there anything really in the
language itself and not the browser parts? Not that I like JavaScript myself,
just curious.

>> There is, however, a seemingly good comparison, which should give the general
>> idea:
>>
>>       http://stackoverflow.com/a/1022683/1161045
>
> To be honest a Javascript to Lua comparison doesn't really help much
> understanding if Lua could be an asset for SSSD or not.

Sure, I was answering the specific question from Pavel of how it compares to
JavaScript.

I think a lightweight embeddable language could be an asset to SSSD, in
general. It doesn't have to be Lua. I think Lua is a good candidate, but there
are other similar languages around, although probably not of such extended
vintage.

> See above questions.

Thanks!

Nick



More information about the sssd-devel mailing list