When I had Godot auto-complete the
func it only had
delta as a parameter
From what I understand, the only difference between the two ways is that the way you do it in the video, forces a specific type, right?
What is the purpose of the return type of
For the functionality of your code (whether it works or not), the requirement does not exist. In the future (Godot 4.0+), we will have strongly typed instructions, so there will be a performance benefit, but there is no benefit for the game engine to have type hints on or using them.
They are, however, in my opinion, an invaluable programming tool, because they help prevent mistakes. Godot will complain if you try to stick a Node inside of an integer. But with the normal, dynamic language without hints, that is perfectly allowed (they are both of type "Variant" which can hold anything), which can lead to hard to trace bugs if you're not careful.
They are optional, but we use them all the time because they are great and useful. It also explicitly tells the type of the function and what it's supposed to return (or not return, as in void) at a glance without having to look through the function and check if anything is returned, why and when. Same with parameters.
If you want your auto-complete to add them for built-in functions like physics process or process, you can go into Editor -> Editor Settings -> Text Editor -> Completion and tick Add Type Hints.
I'll make those changes to my editor, and do my best to treat GDScript as a strongly typed language when I can. I will say, I still enjoy weakly typed languages <3
I don't know who said this, but this is very true! If anyone else stumbles on to this thread, enjoy:
Would you rather have "silly" errors during development, or insanity-inducing errors in production?