0
\$\begingroup\$

So I'm still new to making games that have a baseline for computer resource usage and I'm confused with my question. I can't find an answer anywhere on the internet so I'm here.

Simple Question: Which uses more resources? x10 small scripts or x1 mega script?

Detailed Question: Would x10 small scripts that consist of about 70 - 100 lines of code, be more resource comsuming than x1 mega script containing about 700 - 1000 lines code?

\$\endgroup\$
  • 2
    \$\begingroup\$ Hi Black Cat, unfortunately this question doesn't seem to be about game development, but about programming in general. A good rule of thumb is not to worry about resources until you've actually encountered a problem while developing a game. Also when writing code, you should focus on making the code readable, instead of making it run fast. You'd be surprised how many more projects have been abandoned for being unmaintainable, than the number of projects that were abandoned for being slow. \$\endgroup\$ – TomTsagk Oct 8 at 15:46
  • \$\begingroup\$ This sounds like a question you can answer for yourself by creating 10 small scripts and one mega script (or downloading free scripts documented online so you don't even have to invent the placeholder code), and measuring the RAM use when each is in play. What do you need from us that you can't determine for yourself in this way? Also, are you sure this is even a concern? The code itself will hardly ever be the main culprit for memory use. A single texture or music file might take up more RAM than the entire executable segment of your game attributable to scripts. Why does this matter? \$\endgroup\$ – DMGregory Oct 8 at 17:20
1
\$\begingroup\$

Scripts themselves take almost no RAM. You pretty much only have the cost of storing the CPU instructions (a few kilobytes at most, if your script is massive) and that's only once, it doesn't matter how many times the script is duplicated.

For comparison, a single bitmap sprite can to take up several megabytes. It's your assets that are going to be taking up RAM.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.