Golang vs Lua vs Javascript.
What should I use as a scripting language for side project?

I am writing a cli application in go which will generate boilerplate code from user defined templates. It’s very similar to hygen and plop, but I am focussed more on flexibility and portability.

Anyway, idea is to implement new format which would be composition of scripting language and template language, for example:
/*It’s front matter, where script should be written to prepare data for template*/
name := “world”
ctx.setVariable(“name”, name)
{{! Here goes mustache template engine }}

Hello, {{ name }}

Then command would be run like ‘gen template’, name would be prompted and then file generated at cwd.

For this format I see mustache as a perfect fit. Though, I can’t decide what to use for scripting language.

Currently my choices are:

golang (anko) - my favourite choice, but it’s statically typed and also slow to compile. Also, I don’t think it would be a good idea to use it for templating, something dynamic I would see as much better fit.

Lua - no experience with it, tried it only long time ago when I was 12 years old. Though it was designed specifically for scripting purposes and is widely used along C devs. Also, it’s the fastest scripting language compared to others implemented in go. Oh, and arrays start at 1 😂

Javascript (ES5 only a.k.a old javascript) - I really hate javascript, but yet I must to admit that it’s actually very easy to use and probably would be really good choice for templating purpose. There’s also fast implementation in go. On the other side, javascript could get messy really fast.

Also, what I need to take in consideration is plugins, that I would probably will implement in future.

Well, I hope to get some suggestions and opinions from you guys, that would be really helpful.

And yes, I am going to open source this project, anyway I would like to create proof of concept first and this thing is last left to implement.

  • 2
    Why not python? Go is not exactly scripting, lua is stupid and fuck javascript.
  • 1
    @sharktits yes, I also considered python as the best option, but in that case either I need to rewrite everything in python, but I am too lazy, or use cpython binding which would make final app attached with python executable. Third option is to implement interpreter myself, but that would take ages 😂
  • 3
    Go slow to compile? Unless you are writing something huge, and even then I can barely imagind it being slow since far bigger projects consider it fast.

    Python seems like a better choice as stated before. Buuuuut if you are looking at distributing executables there is always Java or .net

    Fuck Javascript for this and also Lua is very niche and I wonder if it would be worth learning it. Plus, damn near lack of packages would make it daunting. It is a nice language though.
  • 1
    I used Lua to script my raytracer, it was a very nice experience indeed. Wrapping your code in Python/JS is much more annoying.
    I would vote for Lua, even though I kinda dislike the language itself.
  • 1
    @AleCx04 I think you misunderstood my question. I just a need language to embed into application for scripting purposes, not to develop app itself with. And it will be compiled/interpreted during runtime. So go in this case (maintained existing implementation) is 200 times slower than javascript.

    @oudalally it’s something very universal I would like to use daily when finished. I was considering configuration option first, but eventually I came up with too much possible use cases, so decided that scripting would be the most flexible way to go and also least messy.

    @RememberMe is there any specific reason you dislike it? Or is it just syntax itself?
  • 0
    @gintko point taken my dude
Add Comment