• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Is parameter-based scripting at the expense of some performance?

X

XirmiX

Guest
With scripts, you can essentially create functions of your own in a way. I've thought of cool ways I could re-use some portions of my code instead of writing it all down to execute in one block. But isn't this at the expense of some performance? I know that GML itself is probably some-what resource intensive considering how simple it makes it for the programmer to code, but creating more functions to make it fun to put in parameters and have the re-usable code do the rest for you may require additional processing time/power.

What I thought of was a script which would write buffers, anywhere from sending just a few integers to huge blocks of data. I'm not here to ask how it could be done, I have a pretty good idea of my own, but what I was thinking was whether and how much would this affect the performance. Because at the end of the day, is it really worth it to save internal space at the cost of some chunk of performance?
 
The performance hit in almost all cases will be miniscule compared to the advantages of code reuse and reduction in debugging time.

General rule of thumb is that if you write (or copy\paste) the same chunk of code in more than one place, make it a function (put it in a script)

As already mentioned, if performance is a concern, use the profiler and inlining.
 
Top