dear,
i try to understand the overall design. would you kindly help me to understand what are the feature scopes should be covered by lua layer? I just hardly draw a clear line between lua app and c++ class. thanks in advance.
no comment in past 20 hour. it seems to be a bad question. i will hold this topic for 2 more days... but if anyone have some thoughts about this, will be deeply appreciated!!
I don't think there's a definition of what goes to Lua and what stays in C++.
I would say that anything that's really useful to have in Lua, should be in Lua. Such as behavior modifiers (Player.onMoveItem, onStepIn, Creature.onTargetCombat, etc)
In general, I'm seeing a lot of stuff being moved to Lua to make the engine more flexible. You can tweak a lot of stuff without having to rebuild the server. What still needs to be in C++ is performance critical stuff (e.g. map spectators).
It's really a matter of who codes, but in overall: source = core and lua the extensions. Now what is core and what is extensions varies to each programmer, I've seen people making scripts in source alleging a better performance and I already know guys who did everything in Lua and have their server up and running.
Again: the source is immutable, once is compiled you can't go back (until you compile again), so this is a very good tip on what you should do on each scope. The performance of Lua is very very good, the difference to C++ is trivial (you can code two equal algorithms in Lua and C++ and check the difference) but the thing is that is way easier to change something, specially in runtime while dealing with Lua.
Most of the things were made in C++ a long time ago because people didn't know how to code in Lua properly and because they didn't expect that someone would ever want to change those things.
(I'll mention utevo res and exiva here as example of what I'm saying);
Now with the recents versions of TFS is being way more easier to get information of source and change those things to Lua. To newcomers of TFS, they find if very confusing that our community is making PR's to change things to Lua but it's not confusing at all. Hope I solved your matter.
I've seen people making scripts in source alleging a better performance
I'd argue that this is not true for anything that matters
regards to the performance, my perception is c/c+ has much better performance than lua. but has similiar performance with luajit. is this similar as your understanding?
No, it really depends on the code. LuaJIT can be faster than C++ for very specific stuff, but in general is 2 to 3 times slower or more. That's the point: when you think on speeding up code, is it really worth it?
Imagine a Lua code that spends 0.05% of CPU time only, is it worth it moving to C++, reducing maintainability, to use use 0.03%? In my opinion and generally with TFS, no.
thanks all the reply. the answer has drived my queries.
Most helpful comment
It's really a matter of who codes, but in overall: source = core and lua the extensions. Now what is core and what is extensions varies to each programmer, I've seen people making scripts in source alleging a better performance and I already know guys who did everything in Lua and have their server up and running.
Again: the source is immutable, once is compiled you can't go back (until you compile again), so this is a very good tip on what you should do on each scope. The performance of Lua is very very good, the difference to C++ is trivial (you can code two equal algorithms in Lua and C++ and check the difference) but the thing is that is way easier to change something, specially in runtime while dealing with Lua.
Most of the things were made in C++ a long time ago because people didn't know how to code in Lua properly and because they didn't expect that someone would ever want to change those things.
(I'll mention utevo res and exiva here as example of what I'm saying);
Now with the recents versions of TFS is being way more easier to get information of source and change those things to Lua. To newcomers of TFS, they find if very confusing that our community is making PR's to change things to Lua but it's not confusing at all. Hope I solved your matter.