Richard Bucker

Lua vs Tcl as a DSL

Posted at — Aug 3, 2020

I’m not sure what I know any more about DSLs. There is something to be said about a syntax that describes whatever you’re trying to say. Hello World is one of the easiest DSLs and it’s very clear but the challenge comes when you want to do some real work.

Right now I have a working tcl based DSL that is based on Picol and written in golang. I can do some basic math and database queries. I can do some advanced math too. I can send emails and read config files.

I started work on a lua based DSL also written and running in golang. The author is a wellknown e-store and I think they have abandonned the project. The project seems to work but there are some shortcommings that seem like dealstoppers.

And so here we go again… [1] interpreter vs compiled [2] this syntax the other syntax or the next? And so on.

Back in the day we used to evaluate Big-O and little-o. Now it’s not so important. Back in the day n was something we counted…. we also refined out assembly language to count cycles, nops on page boundaries, jumps and so on. Now many compilers are better than that as they predict branching. The problem remains, how to count n? This is further challenged when comparing strings instead of integers.

Here I am back and lua and tcl. The syntax is well known but once you get out of the syntax and start using the standard library it all falls apart. Picol does not have a std lib and lua has a weak one. Now I have to fill in all the gaps with an API wrapper to regular golang functions.

This is where state becomes a thing.