Lua from Other Languages: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Ozzypig
No edit summary
>TheDarkFireDragon
No edit summary
 
(9 intermediate revisions by 3 users not shown)
Line 14: Line 14:
===Differences===
===Differences===
* '''null''' is known as '''nil'''.
* '''null''' is known as '''nil'''.
* '''else if''' is combined into one keyword '''elseif'''
* Lua is dynamically typed (rather than statically), so you do not need to declare the type of variable before you can use it. You can change variables from being tables to numbers.
* Lua is dynamically typed (rather than statically), so you do not need to declare the type of variable before you can use it. You can change variables from being tables to numbers.
* Lua uses different arrays that are known as tables. Tables have numerical, string and table indexes. Strings in Lua are not tables.
* Lua uses different arrays that are known as tables. Tables have numerical, string and table indexes. Strings in Lua are not tables.
Line 20: Line 21:
* Lua does not use braces for opening and closing blocks of code. It uses the '''end''' statement.
* Lua does not use braces for opening and closing blocks of code. It uses the '''end''' statement.


<!--
==Lua from Python==
==Lua from Python==
===Similarities===
===Similarities===
===Differences===
===Differences===
 
More info at http://lua-users.org/wiki/LuaVersusPython
-->
==Lua from Haskell==
==Lua from Haskell==
===Similarities===
===Similarities===

Latest revision as of 13:56, 9 July 2011

If you have experience in other programming or scripting languages, you can easily take the shortcut to learning the similarities and differences of the two programming or scripting languages.

Lua from C, C++ and C#

Similarities

  • Lua uses very similar control structures (such as if, else, while, for, repeat, break, return and function).
  • Lua uses statements and expressions.
  • Lua can overload operators with the use of metatables.
  • Lua can overload functions, but you don't have to restate the entire function.
  • Lua does not have a class system, but using metatables you can get a very similar effect.

Differences

  • null is known as nil.
  • else if is combined into one keyword elseif
  • Lua is dynamically typed (rather than statically), so you do not need to declare the type of variable before you can use it. You can change variables from being tables to numbers.
  • Lua uses different arrays that are known as tables. Tables have numerical, string and table indexes. Strings in Lua are not tables.
  • Lua has no headers, and there is no function to start the code. It all begins from the top and ends at the bottom.
  • Lua is embedded into host/parent applications. The compilation process is done on-the-fly, and you cannot get stand-alone executables from Lua.
  • Lua does not use braces for opening and closing blocks of code. It uses the end statement.

Lua from Haskell

Similarities

  • Lua is dynamically typed as well.

Differences

  • Lua is not a function based language, although functions are a big part of it. Most function calling requires parenthesis.