More operators!

Not sure if I missed it, but I didn’t see how lua actually interprets the “+”.

If it’s not in there, can’t you just call the first function, “Arith”, with the case to add the two numbers together?

Well, Lua first gets interpreted into bytecode. The + operation gets bytecode ADD, which in the VM calls arith_op(lua_addthingy,TM_ADD) (it’s a macro, so not really a call but something more efficient, but whatever).

To add +=, you’d have to alter the interpreter to recognize that, turn it into a (new) bytecode and implement the bytecode in the VM. Unless + which is just doing a sum between two values, for += you’d have to first figure out if you’re altering a variable or a field. In case of a variable whether it’s local and global, then add the calculated value of everything behind the + to it. In case of a field, you’d first have to get the table/instance/whatever-gets-indexed, store it in the stack, index the field, store it in the stack, calculate the stuff after the += and add it to that field stack, then write everything back to the indexed thing in the first stack.

altering/creating languages isn’t easy

12 Likes

Rip I guess no new operators :confused:

(maybe we could just get C# support)

9 Likes

Would be amazing but that’s a huge time commitment on roblox’ part

1 Like

they could just use reflections to inject custom methods into classes, without overriding the base lua class. This would allow for them to incorporate custom math operators such as +=, -=, ++, and –
unfortunately though, those math operators are not a part of the base lua library.

1 Like

I think you would like Moonscript.

4 Likes

Syntax wise that’s really far from C++ (my favorite language), so I don’t think I’d personally use it

Although it is very interesting xd

+=, -=, *=, and /= would probably be implemented as syntactic sugar. There’s no need for extra complexity/new bytecodes.
I don’t think this should happen for the time being, though.

6 Likes

i agree. still though it would save a few seconds on typing a large script :stuck_out_tongue:

Syntactic sugar or just flat out implementing moonscript/both would be pretty amazing quality of life improvements I think.

at that point, they might as well just implement a proper scripting language, like javascript or python.

I disagree. Lua is an extremely simple and compact language with lots of flexibility. I struggled with Lua when I was younger so a harder or more complicated language is a bad idea. Lua is perfect for young new programmers. Maintaining two languages is very tedious.

Moonscript compiles to Lua so maintainability efforts are kept at a minimum and offers a slightly more power user approach with more syntax features.

1 Like

lua and python offer a lot of power for their language, and they both are relatively easy to implement, in fact it wouldnt even take much work at all to incorporate it into roblox. there are a few javascript libraries that will let you just tap into classes that you specify, without much work at all. honestly, i think it would be even easier than lua as well in terms of making api features, because with javascript you can declare custom math operators from within javascript itself, as well as javascript being more performance freindly than lua, it would bring a LOT to the table. Javascript itself isnt really that hard, it is just as easy to get into as lua.

example syntax:
javascript:

var someVar = "123";
function test() {
console.log("test");
}

lua:

local someVar = "123"
function test()
print("test")
end

its really not much different. I just prefer javascript over lua, due to javascript supporting actual classes :wink:

16 Likes

rightclick → Inspect
rightclick html → delete

DONE!

No, that’s not easy.
Where are you getting this

7 Likes

from experience with implementing it in some test projects in the past. i mean it wasnt c++, it was in java/c#, but it was still pretty easy.

I’m not saying Javascript and Python aren’t hard languages, but you have to remember these languages will be extremely confusing and complicated to your new young programmer and its why Lua is much more appealing because Lua does simplicity as a scripting language while having a perfect balance of flexibility and is overall the best choice for new ROBLOX devs. Remember that things are much harder to those who are inexperienced and if people struggle with Lua then certainly Python or Javascript would increase that complexity.

I tend to lean more into moonscript in this case because it still leans more into ROBLOX’s Lua roots and feels like the most natural addition. Which would also be easy to implement given in the end its quite literally Lua and is just Lua abstracted to support more syntax features.

I would think the ROBLOX staff would deviate more towards Moonscript than Python or JS because of this.

fair enough. Lua is also mod freindly as well, i just love using classes, oop is drilled into my head lol