5
Parzi
4y

Wow, i've been gone a while, huh?

I partly refactored that shitty emulator of mine, and after some tweaking and such, got it using a class and such instead of a bunch of global vars. However, it runs slower and got 1KB larger... how did practicing "better" coding habits make it worse?

Comments
  • 4
    Well, depending on the language and compiler, you should always remember that such a simple thing as a function call for example is expensive.

    Getters and setters which are doing nothing but setting and returning are pretty bullshit when thinking about this. Only if your language interpreter or compiler does not optimize these things, that is.

    Garbage Collection can be a bitch too, so instantiating new objects is expensive twice. Once when making the object, once when freeing the object.
  • 2
    Global mutable state is always perfect for performance. See OpenGL for example.
  • 2
    Best practice is often more about readability, extension, speed to develop and maintenance than performance.
  • 1
    @craig939393 exactly. As soon as performance is key you got an own compiler for stuff (see facebook back in the days) or bad maintainability / ugly code (see twitch: ballast for a very good example)
  • 0
    @nitwhiz it's not really key, just Python. You feel any slowdown s lot more.
Add Comment