cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Why thingworx uses LUA scripts as instructor script in software content management?

magrawal
2-Explorer

Why thingworx uses LUA scripts as instructor script in software content management?

Hi guyz,


I would like to know why thingworx uses LUA scripts as instructor script in software content management.
Thanks!

3 REPLIES 3
rupadhyay
12-Amethyst
(To:magrawal)

Hi Meenakshi Agrawal​,

Lua is a powerful, efficient, lightweight, embeddable scripting language. It supports procedural programming, object-oriented programming, functional programming, data-driven programming, and data description.

Apart from above mentioned features , Thingworx developments solely holds right to use latest tool and technologies that can help them develop faster and better Products. And till here I have been generally talking about Lua and why its being used by Thingworx development team.

Having part of your code logic implemented using Lua code has several advantages:

Lua is simpler (less tricky) to learn and use than C, and it is much more high-level. It supports powerful abstractions, such as function closures and object orientation (in a peculiar way, using Lua tables and metamethods).

  1. Lua is a dynamic language: it requires no "off-line" compilation. You can modify the text of your Lua script and that's all you need to modify your application behavior (no additional compilation+linking steps needed). This simplifies application development and debugging.
  2. Lua is a safer language than C: it is really difficult to write Lua code that exhibit undefined behavior, as intended in the context of C/C++. If a Lua script fails, it fails "loudly". Moreover Lua supports an exception mechanism (although with a different syntax than C++) which can be employed to implement error management in a much easier way compared to C.
  3. Lua, as most dynamic languages, is garbage collected. This means that the programmer is spared the pain of manually managing dynamic memory, which is a major cause of bugs, leaks, instability and security loopholes in languages that lack garbage collection.
  4. Lua can "eat its own dog food", i.e. you can build a string at runtime (even in Lua itself) and if it is valid Lua code, your program can execute it on the fly. This is something not frequently seen even in other dynamic languages (still it is not LISP, but it gets closer, and with much more readable syntax). This enables Lua scripts to:
  5. employ powerful text-based metaprogramming techniques, where Lua code can generate other Lua code and execute it on the fly;
  6. implement domain specific languages (DSLs) in an easy way; Lua code can load at runtime other Lua code that is crafted so as to reflect the specific problem domain in which it is used (Lua syntax is simple, yet flexible enough to allow such things);
  7. be used as a configuration language with ease: your application (written in a mix of C and Lua) can use some lua files as configuration files without the need to craft an ad-hoc parser for a specific configuration file format. Therefore you don't need to parse *.properties, *.csv, *.ini, or whichever other format you would choose if you hadn't the option of using Lua files for that purpose.
  8. Lua engine has a very small memory footprint (some hundreds kBs), packing powerful capabilities. With very few C code lines and a bunch of Lua files you could create a complete application that would require thousands of C code lines otherwise. The standard Lua standalone interpreter can be seen as just an example of embedding Lua in a C application!
  9. Lua has a very liberal open-source license, which enables its use even in commercial applications without much hassle. This also allows the modification of its source code to adapt it to special needs.
  10. Small memory footprint and easily tweakable C sources make Lua a perfect candidate for porting it on embedded systems or small microcomputer systems (microcontrollers, etc.). Many parts of the standard Lua distributions can be stripped off, reducing the core Lua engine in the ~100kB range.

Moreover , I would love to hear and understand about your actual concerns.  Is there any  issue , which you are facing with Lua Scripts or you are not expecting Lua Scripts as instructor script in SCM . Please add more detail and explanation , for us to be able to clarify the query.

Sincerely

Ravi Upadhyay

Hi Ravi Upadhyay,

Thanks for such a brief explanation, it's really Helpful as it gave me basic idea about Lua.

I am not very much familiar with Lua script so I wanted to know its use and benefits of using it in Thingworx.

I'll do more r&d on it.

Regards,
Meenakshi

rupadhyay
12-Amethyst
(To:magrawal)

You are welcome  Meenakshi Agrawal​ , Do let me know if you need any further help on this topic.

And I also hope your basic query is resolved and you are good to go ahead with your learning of Lua Scripts.

Announcements


Top Tags