Is Lua an object-oriented language?

2020-07-23 08:43发布

问题:

Is this language an OO language? Is it often used as OO language?

回答1:

Lua is fully capable of prototype-based object-oriented programming similar to JavaScript.

Prototype-based programming is a style of object-oriented programming in which classes are not present, and behavior reuse (known as inheritance in class-based languages) is performed via a process of cloning existing objects that serve as prototypes. This model can also be known as class-less, prototype-oriented or instance-based programming. Delegation is the language feature that supports prototype-based programming.

For more information, see Chapter 16 - Object-Oriented Programming of the Programming in Lua book.



回答2:

It does support object oriented programming with some difficulty. This chapter in the official guide explains http://www.lua.org/pil/16.html



回答3:

Lua it's not an OO language "per-se" but offers mechanisms to implement different styles of Object Orientation.

There are a lot of libraries that implement OO for lua. A look at lua.org (the main Lua site) or lua-users (the Lua Community Wiki) will be helpful.

Even more helpful would be to ask in the Lua Mailing list.



回答4:

Lua is a powerful, fast, lightweight, embeddable scripting language.

Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode for a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping.

~ Lua: about



回答5:

It's mostly used as a scripting tool in Apps, to extend or implement functionalities.



标签: lua