User:SuzannaLinn Resident/LuaHistory

From Second Life Wiki
Jump to navigation Jump to search

History

Currently, we only have LSL, but soon we’ll have two options: LSL and Lua.


There are two Lua-related projects in Second Life:

  • Lua server-side: This will allow us to write scripts in Lua similarly to how we currently use LSL.
  • Lua client-side: This will enable scripting within the viewer itself, allowing for customization and enhancements to improve the user experience.


Server-side Lua will be available first, with client-side Lua coming later.


What is Lua?

Lua (pronounced LOO-ah) is a scripting language designed for embedding into other applications.

Its name means "Moon" in Portuguese. It was developed in Brazil in 1993.

It's designed focusing on speed and security, to be integrated into other applications and to be extensible adding new functions.


Why Lua?

Lindens have evaluated C#, Javascript, Python and Lua.

Perhaps we would have chosen one of the other three languages. And we had been hearing about C# for years and years... but... it's Lua.

Lua is much more powerful than LSL script, but less powerful than the others. Disappointing? I was... until I learned Lua and understood why.


Let's look at the advantages of Lua compared to other languages:

  • Optimized for efficiency: Lua is designed for fast execution and low memory usage. Its concise set of instructions and data structures helps scripts run quickly and efficiently.
  • Seamless integration: Lua is built to be embedded in virtual environments, allowing it to interact easily with the platform. It can respond to events and call functions effortlessly, while also being easily restricted to prevent unauthorized access to system resources.
  • User-friendly learning curve: Lua is easy to learn, featuring a small set of keywords and data types. Its simple syntax can be mastered quickly, and its flexibility allows beginners to progressively explore more complex uses.


And to the advantages of Lua compared to LSL:

  • Flexible Data Types: Lua supports various data types, providing more versatility in scripting.
  • Powerful Tables: Lua’s tables allow for lists of lists, enabling complex data structures that are easy to manipulate.
  • Object-Oriented Programming: Lua supports classes, objects, and inheritance, making it easier to structure and reuse code.
  • Enhanced Performance: Lua scripts typically execute faster and use less memory than LSL scripts, resulting in a smoother experience in virtual environments.


In brief: the main advantage is that Lua will work.


Which Lua?

Since Lua is very adaptable, there are various implementations for different programs.

Lindens have chosen Luau (pronounced LOO-ow, "ow" like in "how" or "now").

It's the scripting language used in Roblox, a platform for games developing, with more than 100 million users.

Luau is also the name of a traditional Hawaiian party.

So Lua is the language, and Luau is the implementation of the language. Probably we will be seeing both names indistinctly.

Luau was developed in 2006, when Lua was at version 5.1. Since then, Luau has introduced its own new features, along with incorporating some of the updates from Lua, though not all. Standard Lua is currently at version 5.4.