• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

How safe is use Lua?

Status
Not open for further replies.
Level 24
Joined
Jun 26, 2020
Messages
1,853
I'm not very into Lua yet so I have some doubts about using Lua, I mean, first since there is not values types is too easy call a function and add it illegal values like put a player where must be a unit, second since to declare an object like a variable or function I just put the name and there it is, I can call a "non existing" value or function and the code will compile normally, I know I can compare if the value isn't nil, but it was too tedious and less efficient and in other case, if I miss a charcater the code could compile normally; so what should I do?
 
Level 11
Joined
May 29, 2008
Messages
132
You're totally correct with the lack of types in Lua being dangerous. Lua is interpreted, not compiled so there's no checks on most things until you actually run the code.

I would highly recommend looking into using Typescript, which compiles to Lua, for type safety and a way better coding experience. There's a number of people doing thing, myself included, who really enjoy it.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,207
Lua is interpreted, not compiled so there's no checks on most things until you actually run the code.
Lua is compiled into bytecode and it can and will throw syntax errors during that stage. Lua is dynamically typed though (as opposed to JASS which is statically typed) so it cannot throw type related errors until the Lua bytecode is executed.
 
Status
Not open for further replies.
Top