Lua Technical Discussion


Alistair Lowe
 

Hi guys,

I'm interested in the move to supporting Lua templates, is there a technical discussion or documentation discussing the reasoning behind Lua as a language choice?

I would like to put forward Squirrel-lang as a potencial alternative, it is easily embedded and small footprint like Lua but features a more familiar and intuative C-based syntax, very close to Java script and has native JSON support with good end-user documentation.

I'd like to understand more around the reasoning behind Lua and why it was selected to understand if this propos is a sensible one.

Many thanks


Matt Fisher <matt.fisher@...>
 

We were looking to use Lua as a pre- and post-hook event system when charts were being rendered.

The post-render hook introduced in Helm 3.1 seems to handle most of the use cases the Lua event system would enable, so the need to implement a Lua-based event model was de-prioritized.

Lua was chosen over other languages for the following reasons:
  • portability (can be used on all devices)
  • designed to be embedded in other programs (simple sandboxing model)
  • it's an incredibly simple language (usually means there are less security risks)
  • the compiler and runtime take up a very small footprint, both in terms of overhead performance and code size
  • it's free and open source
  • it's being used in production in many software projects. NGINX famously loads Lua modules, allowing users to extend its capabilities.
  • there are several reference implementations of Lua VMs written in Go:
More information on the implementation details (as well as the use cases we were targeting) can be found in the Helm 3 proposal for the event-driven model. The Lua plugin proposal was another potential area we could use Lua.

I guess I have two questions:
  • What use case are you attempting to solve with this proposal?
  • Are there any Squirrel VMs written in Go?

1504220459230_microsoft.png

Matthew Fisher

Caffeinated Software Engineer

Microsoft Canada


From: cncf-helm@... <cncf-helm@...> on behalf of Alistair Lowe via Lists.Cncf.Io <alistair=skyiot.co.uk@...>
Sent: Wednesday, March 11, 2020 4:42 PM
To: cncf-helm@... <cncf-helm@...>
Cc: cncf-helm@... <cncf-helm@...>
Subject: [cncf-helm] Lua Technical Discussion
 
Hi guys,

I'm interested in the move to supporting Lua templates, is there a technical discussion or documentation discussing the reasoning behind Lua as a language choice?

I would like to put forward Squirrel-lang as a potencial alternative, it is easily embedded and small footprint like Lua but features a more familiar and intuative C-based syntax, very close to Java script and has native JSON support with good end-user documentation.

I'd like to understand more around the reasoning behind Lua and why it was selected to understand if this propos is a sensible one.

Many thanks


Alistair Lowe
 

Hi Matt,

Thanks for the great briefing, it sounds like the biggest sticking-point in my suggestion is that AFAIK Squirrel doesn't have a Go implementation.

It shares a lot in common with Lua and was inspired by it but addressed a few key points at the time:
  • A much more familiar C-based syntax with native JSON notation support.
  • Better OO support.
  • Predictable Garbage Collection (was targeted at gaming).
You'll still find it today in Valve's Steam engine and Electric Imp's IoT platform and like Lua, it covers most of the points you've listed, it's portable, easily embeddable, small footprint, safer, free and open source.

My motivation for suggesting this was simply the familiarity of the syntax for an end-user, Lua may be 24th in the PYPL popularity list but that only accounts for a 0.31% share, which has been dropping each year, and its syntax style is fairly distant from the more popular languages. Squirrel is so close to Javascript and other C-based languages that a large number of users could run with it after a few minutes (once you realise 'local' instead of 'let'), much as I did when first picking it up. An example of the Syntax:

---
local myVar = 10.5;
local myString = "hi";
local myVerbatimString = @"Lots of escape characters will be printed \n\n\n\n\n\n";
local myTable1 = { test = 1, test2 = 2 };
local myTable2 = { "test": 1, "test2": "2" }; // JSON notation version (also note C-based comments, including block comments)
local myArray = [1, 2, 3, "hi"];

local myFunc = function(a,b) {
   if (a > b) {
      return 1;
   } else {
      return 0;
   }
}

local myLambda = @(a,b) a+b;

foreach (key, value in myTable1) {
   myTable[key] = value + 1;
}

function someFunction()
{
   return "hi";
}

class MyClass
{
   _privateParam = 10;

   constructor() { }

   function myFunc() { return _privateParam; }
}

local myInstance = myClass();
---


Many thanks,
Alistair Lowe


On Thu, Mar 12, 2020 at 6:10 PM Matt Fisher <Matt.Fisher@...> wrote:
We were looking to use Lua as a pre- and post-hook event system when charts were being rendered.

The post-render hook introduced in Helm 3.1 seems to handle most of the use cases the Lua event system would enable, so the need to implement a Lua-based event model was de-prioritized.

Lua was chosen over other languages for the following reasons:
  • portability (can be used on all devices)
  • designed to be embedded in other programs (simple sandboxing model)
  • it's an incredibly simple language (usually means there are less security risks)
  • the compiler and runtime take up a very small footprint, both in terms of overhead performance and code size
  • it's free and open source
  • it's being used in production in many software projects. NGINX famously loads Lua modules, allowing users to extend its capabilities.
  • there are several reference implementations of Lua VMs written in Go:
More information on the implementation details (as well as the use cases we were targeting) can be found in the Helm 3 proposal for the event-driven model. The Lua plugin proposal was another potential area we could use Lua.

I guess I have two questions:
  • What use case are you attempting to solve with this proposal?
  • Are there any Squirrel VMs written in Go?

1504220459230_microsoft.png

Matthew Fisher

Caffeinated Software Engineer

Microsoft Canada


From: cncf-helm@... <cncf-helm@...> on behalf of Alistair Lowe via Lists.Cncf.Io <alistair=skyiot.co.uk@...>
Sent: Wednesday, March 11, 2020 4:42 PM
To: cncf-helm@... <cncf-helm@...>
Cc: cncf-helm@... <cncf-helm@...>
Subject: [cncf-helm] Lua Technical Discussion
 
Hi guys,

I'm interested in the move to supporting Lua templates, is there a technical discussion or documentation discussing the reasoning behind Lua as a language choice?

I would like to put forward Squirrel-lang as a potencial alternative, it is easily embedded and small footprint like Lua but features a more familiar and intuative C-based syntax, very close to Java script and has native JSON support with good end-user documentation.

I'd like to understand more around the reasoning behind Lua and why it was selected to understand if this propos is a sensible one.

Many thanks