Dynamic vs. static languages
Contents
Lua is a dynamic language. This means that a variable can point to any type of object at runtime. Other dynamic languages are python, ruby, perl and javascript (ECMA script).
This is different to static languages like C#, Java and C++. These languages define the type of an object at compile time.
Historically static languages compiled into machine code would run a lot faster than dynamic languages. However with advances in Just In Time (JIT) compiler technology this distinction has become less important. In the Iguana Translator for instance we make use of the LuaJIT implementation of Lua.
Dynamic languages are usually faster to develop in than their strongly typed cousins. This is because most static languages:
- Have a compile and linking cycle that is quite slow.
- Require defining classes and objects explicitly before you can use them.
Usually one has to write a lot more code in a static language than a dynamic language to achieve the same tasks.
Dynamic languages require a lot more regression testing when the logic becomes complex – because bugs only become apparent at runtime. Auto-completion is more of challenge since an editor cannot tell the type of an object from the code. To see why consider this C++ function vs. an equivalent Lua function:
void HelloWorld(const string& Message){ // do stuff }
vs. in Lua:
function HelloWorld(Message) -- do stuff end
In C++ we know that the Message variable will always have the type “string”. It is defined at compile time. In Lua the Message variable could contain anything. We can only know what it contains by running the code.
That is exactly how we solve the problem in the Translator. It is a technique which only works because of the nature of middleware – we always know what the input data is. At the same time this resolves the major headache with dynamic languages – regression testing – our built in sample data provides the perfect regression testing framework to maintain code written in a dynamic language.
Because of that the Translator provides an exceptionally productive environment for programming deterministic business logic. i.e. data in–> data out in a fraction of a second.