-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Enable Add Type Hints editor setting by default #88026
Enable Add Type Hints editor setting by default #88026
Conversation
Now that GDScript type hints improve performance since Godot 4.0 and the community is increasingly getting used to typed GDScript, it makes sense to add type hints by default. Official demos will also be moving to type hints at some point in the future, further increasing the relevance of enabling type hints out of the box.
399ef49
to
345f09d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in favour as part of a broader push to prefer static typing, and phrasing is good
Unless I'm mistaken editor settings are all stored so this won't affect existing users, so anyone can just disable it if they dislike it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with this. Although I have always felt like this option could use a bit more granularity to it.
Since this changes a default Editor Setting, I would encourage whoever is reading this to also check out #81906 |
I see little risk in this (unlike However, does this mean that our recommendations are shifting towards typed code, although we still use only untyped code in the documentation? Also, we recommend not mixing approaches, and changing the setting prevents users of untyped GDScript from sticking to one option. |
"Not mixing approaches" feels like a weird rule. I get it's meant to encourage consistency, but GDScript works completely fine with a mixed approach. In my personal opinion the documentation should still aim to be accessible and avoid static typing when possible, as it makes the code look more overwhelming than it actually is in practice. |
I'm a big fan of type hints and we use it nearly everywhere on Koira. We do have, as mentioned, a mixed approach though, because sometimes you are not 100% sure what type is coming in or you want to be able to support multiple types and switch within the function. Although type hints can seem overwhelming, it helps beginners a lot with autocompletion and finding bugs before you run the game. Enabling this feature by default gives a nudge towards good programming practices. |
Funny, I just fished this old related article back for a conversation I was having with a friend. From an educator perspective, my go-to recommendation is that dynamic typing should only be handled by experts, while beginners need explicit types. My personal anecdotal experience is that types are scary for newcomers, but once the hurdle passed, they are easier on the slightly longer term1. The concept of "this keywords is a filter that validates other values are acceptable to put in that box" is easy. The syntax is complicated. For that reason, I am all for types by default, but I am also in favor of leaving them out of at least the initial tutorials ( Footnotes
|
Thanks! |
Now that GDScript type hints improve performance since Godot 4.0 and the community is increasingly getting used to typed GDScript, it makes sense to add type hints by default in autocompletion and script templates.
Official demos will also be moving to type hints at some point in the future, further increasing the relevance of enabling type hints out of the box.
Additional context: https://twitter.com/reduzio/status/1754794206206239036 (although this has been a general trend since 4.0's release, and even before)