[nim-dev] Re: Using Nimscript as an embedded scripting language?

  • From: flyx <nim@xxxxxxxx>
  • To: nim-dev@xxxxxxxxxxxxx
  • Date: Mon, 5 Dec 2016 12:56:27 +0000

Is it possible to use Nimscript as an embedded scripting language

In theory: Yes, of course. Why shouldn't it?

In practice: Since the compiler and the standard library are rather modular, 
you can include parts of it in your project. However, there is no API dedicated 
to what you want to do, so you would need to extend and modify quite a bit of 
the current code.

I believe that Lua's API for embedding the interpreter would still be superior 
as it was designed with embedding in mind. Not mentioning the restrictions of 
Nim's VM (for example, using ``ref`` variables is still buggy). Lua's embedding 
API is also designed for safety as you can tightly control which parts of the 
standard library will be available. It would be a lot of work to reimplement 
that for Nim â€“ for example, you would need to split up the ``system`` module 
since it contains a lot of stuff you may not want to make available (like File 
I/O), while other things are absolutely necessary (basic types and procs, e.g. 
for strings, arrays and seqs).

Other related posts: