Skip to main content

Coding Style

Every developer has opinions about the way they want their code to look: tabs vs spaces, single quotes vs double quotes, 80 char line length vs 120. Languages often provide guides on how you're meant to style your code.  Python has "PEP 8" and GDScript has a style guide.

The problem with these languages is that they don't enforce their own code styles. This means, every developer on a team will probably have slightly different styles. This is a problem,problem when working with a version control system like Git,Git. everyEvery change is tracked, no matter how minor. If three developers touch the same script, we wantneed to be able to see the meaningful diff between the changes, notwithout conflateconflating those changes with style choices.changes. Style changes create really nasty diffs, seeSee why this matters here: Bad Diff vs Good Diff

For this reason, among other benefits, weBUGJam will require the use of automatic code formatting tools. Formatting tools are designed to automatically fix all of these style choices so that they adhere to the style guide of the language. Modern implementations of these tools run incredibly fast, and can be configured to automatically format your code upon saving the file, so you'll never end up in a situation where your code is unformulated. The remove all opinions from the style of the code and allow you to focus on just the functionality. This also reduces the learning curve for these programming languages. Just imagine never needing to commit a single brain cell to this question: "Should the space come before or after the colon in the function signature?". The answer is: "I don't know, the formatter will fix it".

GDScript

Godot does not have an official formatter, but luckily GDQuest built a formatter that they've been using in production for a few years, and my short experience with it so far has been great.

TODO put in setup instructions and features you have to turn on

Python

Similarly, Python has turned to the community to create their formatting tools. Many tools have come and gone, but the modern standard is a suite of tools from Astral in particular the Ruff formatter. Their other tools are phenomenal too.

TODO put in setup instructions and features you have to turn on