-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a line length guideline to the GDScript style guide #2567
Comments
When it comes to programming video games, some things can get unavoidably long, or at least would look less clear if they were shortened. I think it should be a loose guideline for sure, but recommending a maximum amount of columns is a good idea. 80 seems too short, 90 sounds better. EDIT: But I could be wrong, y'all have probably written a lot more GDScript than I have. By the way, this could also be added to the C# style guide, but C# code tends to be slightly longer and I'd recommend no less than 100 columns for C#. We could also include a colored line in the editor, as some other editors do, to visually show a recommended maximum width. |
I don't think 80 is unreasonable. It's not supposed to be a hard limit - the purpose is to let you know that you might be trying to do too much on one line. It's a visual reminder to the programmer that "hey, you're getting a bit long there, buddy." It's perfectly acceptable to go past it when necessary. I did a quick survey of the docs and there isn't much code that goes past it. Even in the VR tutorial, which has some of the deepest nesting, there's only a handful of lines like
that blow well past any reasonable limit. I would vote for sticking with 80, but I'd be fine with 88 if that were the consensus too.
This is a good suggestion.
FYI, this can be enabled in the editor here: (Note that 80 is already the default.) And "Line Length Guideline Color" can be set in the "Highlighting" section. |
Unlike many other languages, the GDScript style guide currently doesn't recommend a maximum line length. We should probably adopt a guideline for this, so that people can write code more consistently across projects.
Values around 80 seem to be quite common in most high-level languages, but in my experience, it tends to feel a bit short when indenting code with tabs (or 4 spaces). This is why some Python formatters such as Black default to 88 characters:
If we recommend a line length in the style guide, we can then enable the line length guideline in the script editor by default 🙂
The text was updated successfully, but these errors were encountered: