Forum

Kognitio Console issues, advice, etc.
Contributor
Offline
Posts: 184
Joined: Wed May 29, 2013 2:10 pm
Location: Bracknell

Why use Lua as the basis for Kog Scripts?

by MikeAtkinson » Tue Jun 04, 2013 9:44 am

We've been asked why use Lua as the basis for Kog Scripts? Why not a better known language or a PL/SQL clone?
Reply with quote Top
Contributor
Offline
Posts: 184
Joined: Wed May 29, 2013 2:10 pm
Location: Bracknell

Re: Why use Lua as the basis for Kog Scripts?

by MikeAtkinson » Wed Jun 05, 2013 8:11 am

About 18 months ago when I joined Kognitio, there was a requirement to have an updated script language. It would have to be easy to use, have "naked" SQL and a full range of control structures. By "naked" we mean that SQL statements may just be included in the script without any extra quotation or function calls. The simplest scripts would just consist of SQL statements(s).

Although not hard and fast requirements it was desirable to have classes, first class functions and iterators and allow functional style programming. Also highly desirable were the potential for tight integration with Qt and true multitasking.

I evaluated several languages, Perl, Python, Ruby and JavaScript among them and produced trial implementations of Ruby and Lua. The other languages were ruled out because it was not possible to add naked SQL to them.

Between Lua and Ruby it proved easier to have naked SQL with Lua. Only a few hundred lines of code were added to Lua for that purpose. It also proved easy to integrate Lua with Console to allow single stepping and SQL query history resultsets.

The choice of a scripting language was always going to be a compromise, Lua has two main faults:
it is not as popular as the other languages considered
there is no standard class library

Being a small language, Lua is very easy to learn which partly offsets the first disadvantage. I also plan to build up and maintain a standard set of libraries for Kog scripts, the first iteration of which is included in the Console installation in <installation directory>/lua/std and adds extra string, list and table functions and a class mechanism.

Console is written using Qt, it is desirable for scripts to be able to manipulate UI elements and to be connected to UI elements so that a script might be run when a UI button is clicked. For Qt integration with Lua I've got QtLua mostly working, but it will be several months before this is included in a Console release. It will however allow full manipulation of the Console UI, including adding new UI elements and querying the metadata and history trees.

LuaLanes may be used to add LINDA type multiprocessing to Kog scripts.
Reply with quote Top

Who is online

Users browsing this forum: No registered users and 1 guest

cron