Josh Posted July 19 Posted July 19 Please examine these two examples carefully, and tell me which one feels better to you? Option A --Get the displays local displays = GetDisplays() -- Create a window local window = CreateWindow("Leadwerks", 0, 0, 1280, 720, displays[1], WINDOW_CENTER + WINDOW_TITLEBAR) -- Create a world local world = CreateWorld() -- Create a framebuffer local framebuffer = CreateFramebuffer(window) -- Create a camera local camera = CreateCamera(world) SetCameraClearColor(camera, 0.125) SetEntityPosition(camera, 0, 0, -2) -- Create a light local light = CreateBoxLight(world) SetEntityRotation(light, 45, 35, 0) SetLightRange(light, -10, 10) SetEntityColor(light, 2) -- Create a model local model = CreateBox(world) SetEntityColor(model, 0, 0, 1) -- Main loop while not WindowClosed(window) and not KeyDown(window, KEY_ESCAPE) do TurnEntity(model, 0, 1, 0, true) UpdateWorld(world) RenderWorld(world, framebuffer) end Option B --Get the displays local displays = GetDisplays() -- Create a window local window = CreateWindow("Leadwerks", 0, 0, 1280, 720, displays[1], WINDOW_CENTER + WINDOW_TITLEBAR) -- Create a world local world = CreateWorld() -- Create a framebuffer local framebuffer = CreateFramebuffer(window) -- Create a camera local camera = CreateCamera(world) camera:SetClearColor(0.125) camera:SetPosition(0, 0, -4) -- Create a light local light = CreateBoxLight(world) light:SetRotation(45, 35, 0) light:SetRange(-10, 10) light:SetColor(2) -- Create a model local model = CreateBox(world) model:SetColor(0, 0, 1) -- Main loop while not window:Closed() and not window:KeyDown(KEY_ESCAPE) do model:Turn(0, 1, 0) world:Update() world:Render(framebuffer) end 3 Quote My job is to make tools you love, with the features you want, and performance you can't live without.
Yue Posted July 19 Posted July 19 23 minutes ago, Josh said: Please examine these two examples carefully, and tell me which one feels better to you? Procedural --Get the displays local displays = GetDisplays() -- Create a window local window = CreateWindow("Leadwerks", 0, 0, 1280, 720, displays[1], WINDOW_CENTER + WINDOW_TITLEBAR) -- Create a world local world = CreateWorld() -- Create a framebuffer local framebuffer = CreateFramebuffer(window) -- Create a camera local camera = CreateCamera(world) SetCameraClearColor(camera, 0.125) SetEntityPosition(camera, 0, 0, -2) -- Create a light local light = CreateBoxLight(world) SetEntityRotation(light, 45, 35, 0) SetLightRange(light, -10, 10) SetEntityColor(light, 2) -- Create a model local model = CreateBox(world) SetEntityColor(model, 0, 0, 1) -- Main loop while not WindowClosed(window) and not KeyDown(window, KEY_ESCAPE) do TurnEntity(model, 0, 1, 0, true) UpdateWorld(world) RenderWorld(world, framebuffer) end Object-oriented --Get the displays local displays = GetDisplays() -- Create a window local window = CreateWindow("Leadwerks", 0, 0, 1280, 720, displays[1], WINDOW_CENTER + WINDOW_TITLEBAR) -- Create a world local world = CreateWorld() -- Create a framebuffer local framebuffer = CreateFramebuffer(window) -- Create a camera local camera = CreateCamera(world) camera:SetClearColor(0.125) camera:SetPosition(0, 0, -4) -- Create a light local light = CreateBoxLight(world) light:SetRotation(45, 35, 0) light:SetRange(-10, 10) light:SetColor(2) -- Create a model local model = CreateBox(world) model:SetColor(0, 0, 1) -- Main loop while not window:Closed() and not window:KeyDown(KEY_ESCAPE) do model:Turn(0, 1, 0) world:Update() world:Render(framebuffer) end Personally, I enjoy programming a lot more when using an object-oriented approach. It just feels more natural for me to think in terms of entities that have both behavior and state, especially when I'm working on larger projects or systems with many interacting parts—like a video game. OOP helps me keep my code organized, scalable, and easier to maintain. I like being able to encapsulate logic, reuse functionality through inheritance, and structure things around how they relate and behave. I do appreciate the procedural style and its simplicity for smaller or more direct tasks. But when I have the choice, OOP is definitely where I feel most comfortable and creative. 2 Quote Murphy's Law: We don't fix bugs, we document them as features. – Murphy Games
Explorer Posted July 20 Posted July 20 As someone who uses Roblox a lot, option B feels more familiar, I like it. Quote
Mapledev Posted July 20 Posted July 20 i agree with explorer as a roblox dev too i'd prefer B 1 Quote
Josh Posted July 20 Author Posted July 20 Replies will be hidden, for now.I don't want to influence people's answers. 2 Quote My job is to make tools you love, with the features you want, and performance you can't live without.
Josh Posted July 22 Author Posted July 22 I asked my niece which one she liked better, and she chose the object / method style. I've made good progress with Lua Language Server, so I think the matter is settled, in favor of the object/method API design. Thanks everyone for your feedback. 3 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without.
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.