Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

For loops and Iterator speeds

To me, evaluating a condition (especially one that compare numbers) appears to be far simpler than iterating through an array that could be anything from a simple array to a linked list, which probably cause a bit of of overhead due to casting and polymorphism... But I do not know the inner working of the Ruby interpreter so I cannot be sure.

But Ruby was meant to be simple, not fast... and it will never really be fast no matter how optimised the scripts are. (Although for game logic and text parsing it is fast enough.) Optimizing Ruby code for speed is a waste of time if you ask me. And if it makes the script unreadable, it is actually very bad.

If you have slow code and you know it could be run faster, it might be a problem with the algorithm, not with the way it has been implemented.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top