Side Effect
2025/12/27
- Type
- Learning Resource
- Format
- Glossary Article
- Version
- General
- Subject Tags
- Created
- Updated
- 2026/02/16
- 2025/12/27
We say that a function has side effects when it changes the state of the program. This includes any action your code performs that affects data outside of the function itself, like:
Side effects make changes in the program's data harder to track. They're error-prone because different parts of the code can end up modifying the same data, leading to unexpected results.
For that reason, it is considered a general good practice to avoid too many side effects in your code and make side effects explicit when possible. Proponents of functional programming, a programming paradigm, will enforce a style where as many functions as possible are pure. In this style, if there are errors in the code, they are easier to track down because the functions are isolated and don't depend on external data. Programs with the functional programming style still have side effects, but they're isolated and reduced to a minimum.
In games, this is often not possible, as games need to respond to player input and constantly update the game world accordingly. Plus, they need to do that fast. So, we tend to follow different programming styles. For example, Godot and GDScript are primarily imperative and object-oriented, like most game engines. In the imperative paradigm, we write instructions that the computer follows step by step. In the object-oriented paradigm, we organize our code around objects that have properties and methods.
Don't stop here. Step-by-step tutorials are fun but they only take you so far.
Try one of our proven study programs to become an independent Gamedev truly capable of realizing the games you’ve always wanted to make.
Get help from peers and pros on GDQuest's Discord server!
20,000 membersJoin ServerThere are multiple ways you can join our effort to create free and open source gamedev resources that are accessible to everyone!
Sponsor this library by learning gamedev with us onGDSchool
Learn MoreImprove and build on assets or suggest edits onGithub
Contributeshare this page and talk about GDQUest onRedditYoutubeTwitter…