As a roblox developer, currently it is IMPOSSIBLE to make your code look attractive!
When doing an operation on a variable and using that variable in the operation, it makes sense to only have to type the variable on the left side, but NOOOOO, WE CANT DO THAT IN THIS ROBLOX LUA!
Other languages have operators such as:
x+=5 – adds 5 to x
x*=5 – multiplies x by 5
x-=5 – subtracts 5 from x
x/=5 – divides x by 5
This would turn code like:
game.ReplicatedStorage.All.PlayerStats[tostrong(player.TeamColor)].Money.Value = game.ReplicatedStorage.All.PlayerStats[tostrong(player.TeamColor)].Money.Value + 5
Sure you could just set that object as a variable, BUT UR CREATING ANOTHER VARIABLE AND THATS INNEFFICIENT!!!
ARGH THE DILEMMA: BEAUTIFUL CODE OR EFFICIENT CODE! THIS IS AN ISSUE WE DEVELOPERS FACE EVERY FRAME ROBLOX!!
Furthermore these hot operators should be added too:
++x – increases x by 1 and returns the increased value
x++ – increases x by 1 and returns the original value
–x – decreases x by 1 and returns the decreased value
x-- – decreases x by 1 and returns the original value
This would turn:
game.ReplicatedStorage.All.PlayerStats[tostrong(player.TeamColor)].Kills.Value = game.ReplicatedStorage.All.PlayerStats[tostrong(player.TeamColor)].Kills.Value + 1
AS YOU GUYS CAN SEE THE PERFORMANCE GAINS ARE HUGE (BECAUSE ROBLOX CAN PORT THESE OPERATIONS TO C++ WHICH IS WAY MORE EFFICIENT)! THIS NEEDS TO BE ADDED ASAP!!
Eh, assigning to a variable looks better tbh, but sure.
In bytecode it would probably do the same as just assigning a variable and doing var.field = var.field + whatever. For C++ instances, they could add “native” support, but that would be tricky, annoying and wouldn’t have that much effect.
It’s more efficient because C++ gets compiled and optimized by the compiler and it has direct access to memory. Not to mention, the checks for checking whether it’s a C++ instance to take the more efficient approach will slow everything down, including the efficient and non-efficient path.
Can’t really argue against the “makes code cleaner and easier to read”, but then again, it’s a big deviation from Lua. Technical aspects aside, that’s not something that’s easily done (from a mental perspective, but also a technical one)
I’m not 100% sure it’s more efficient either, but it wouldn’t be too hard to implement would it? I know I’m C++ it’s very easy to make your own custom operators.