Josh Posted December 26, 2018 Share Posted December 26, 2018 In the next engine, should the Lua API be procedural? I have watched beginners trying to program, and they have NO IDEA what functions are available for an object. A dynamically typed language can't provide a reliable set of OOP style commands because the functions on an object can change. I know we worked hard to make Lua act sort of C++, but is this really desirable or are we just trying to satisfy some obscure pedantic decree? OO: local window = CreateWindow() local context = CreateContext() local world = CreateWorld() local camera = CreateCamera() camera:SetPosition(0,0,-5) local box = CreateBox() while window:KeyHit(KEY_ESCAPE)==false do box:Turn(0,1,0) world:Update() world:Render(context) end Procedural: local window = CreateWindow() local context = CreateContext() local world = CreateWorld() local camera = CreateCamera() SetEntityPosition(camera,0,0,-5) local box = CreateBox() while KeyHit(window,KEY_ESCAPE)==false do TurnEntity(box,0,1,0) UpdateWorld(world) RenderWorld(world,context) end I know the OO approach should mean less typing, but it might actually mean MORE typing because the intellisense hints for procedural commands would be much more reliable. As soon as you enter "sete..." you have only the entity commands that set a value to choose from, and from there it is just a few arrow key presses to get the one you want. What do you think? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
catch22 Posted December 26, 2018 Share Posted December 26, 2018 I'm not sure designing an API around how intellisense works makes any sense whatsoever. The engine is C++ and thus object oriented, there's no reason the scripting language for the engine shouldn't reflect that. I wouldn't go out of my way to obfuscate it. At the end of the day you can just provide both, if it really concerns you? Both of your examples are procedural anyway, one just uses methods/properties and the other has standalone functions, so you're basically talking a style thing -- which should strictly be up to programmer using it, I'd think. Ultimately you'd need to decide if you want to groom people into a C++ way of thinking, or add the confusion layer of making program flow work a bit differently between your C++ core and your LUA API (for the simplicity sake of super-newbs). I'd go with the former and tell people to git gud. Quote Coding for Christ. Link to comment Share on other sites More sharing options...
Josh Posted December 27, 2018 Author Share Posted December 27, 2018 That's a good point. I think that you are right. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Yue Posted December 27, 2018 Share Posted December 27, 2018 I think I'd rather do this. cube.SetPosY(10) For some reason I perceive that the code is more organized. Quote Link to comment Share on other sites More sharing options...
Josh Posted December 28, 2018 Author Share Posted December 28, 2018 Thanks for the feedback. I agree. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.