I was wondering if Godot had a linter of some sort but never looked into because I’m usually pretty diligent in good formatting. This is good to know, thank you
How do I do that in Godot 4.3? is it the plugin gdLinter? they warn about when you save you might lose your code for it runs python script on the file an you might lose data
A tip from history from old C coder. Do not use any numeric values in the code, except 0 for initialization. When you use numeric values, then after you read the code, you don't know background of the value. It is self documentary to use constants all the time. When you need to edit your code, you just need to change the constant. This is the number one code cleaning tip when going professional.
You can also have your expression continue over multiple lines by writing a backslash \ at the end of the line. This doesn't look as clean as the brackets mentioned in the video though.
Thank you so much for talking about documentation comments :) i always wanted something like that in Godot, now i don´t have to keep going back to my own functions to remember how they work, i can just write documentation
Well, writing clear code is much, much more than just five tips. In this video, you don't even scratch the surface. You blew five tiny specks of dust from it.
Word wrapping isn't your friend, because you often need to use different lines for semantic reasons and readability. a quick example this: var dot := Vector2(offset.x + radius * cos(alpha + angle_offset), offset.y + radius * sin(alpha + angle_offset)) would look much better: var dot := Vector2(offset.x + radius * cos(alpha + angle_offset), offset.y + radius * sin(alpha + angle_offset)) Imagine the expression is much longer than that. Word wrapping can completely f it up: var dot := Vector2(offset.x + radius * cos(alpha + angle_offset), offset.y + radius * sin(alpha + angle_offset))
Very nice, some of these suggestions are good for any developer, game or otherwise. I'm a professional software engineer and my company uses lint to enforce some of these things for our frontend (built in React). With this your git pipeline will actually fail if you have any lint warnings regarding styling like this that weren't automatically formatted by our pre-commit hooks. Very helpful.
Most of these are things that should be handled by an auto formatter IMO. It would be awesome if Godot adds one but for now there is gdscript toolkit for linting and formatting
Any tips for grouping and naming for the filesystem? Like do you seperate scenes from scripts or do you save similar things (like an enemy scene and enemy scripts) in the same place for easier access?
I like keeping scripts together with their scenes and group scenes with folders. I've seen people just put all their scenes in one folder and scripts in another and that looks so messy to me.
@@charliegnu Yeah right now I do the same but I am always looking for the more efficient way. I wish the scenes with scripts were bundled together in the filesystem. (like next to each other) I also go between name sorting so the scripts that have the same name as the scenes are together but also tried by type which separates the scenes and scripts in 2 but keeps them in the same folder.
The comma at the end of elements for an array, dictionary is great for git repos. If you add an item to the array it's a single line change not 2 changes (1 for the comma and another for the new item). Great tips!
instead of doing if condition_A && condition_B && condition_C: i like to do one of these if condition_A: if !condition_B: return if !condition_C: return
hi sir i'm a new sub here hope you don't mind if i have a request i have a problem running my godot engine in forward and mobile renderer every time i try to run it, it just show black editor and i couldn't do any thing i hope you will see this and accept my request in return i will continue supporting your channel till the end of my life
The thing is that Godot is a game engine. To try to be an IDE too is a lot of work that is never going to come close to VSCode or Visual Studio. Just saying.
So u declare that "document comments" exist, but u never explained the difference between the 3 different comments u refer to. Comment where it's confusing. Use proper variable names so it's less confusing. Comments should be minimal.
Do you have your own tips when working with GDScript?
🔥 SUPPORT THE CHANNEL ►► www.patreon.com/StayAtHomeDev_
Use a linter - GDFormat is my preferred choice; it will format the document following the official style guide, including line-breaks
I just discovered gdtoolkit a few days ago and I'm loving it!
I was wondering if Godot had a linter of some sort but never looked into because I’m usually pretty diligent in good formatting. This is good to know, thank you
this is the real tip lol, I feel like "cleaner code" shouldn't just mean formatting
How do I do that in Godot 4.3? is it the plugin gdLinter? they warn about when you save you might lose your code for it runs python script on the file an you might lose data
Good tips for any language, but the last one specifically for GDScript made this really useful for me, I didn't realise you could do that
0:46 is new for me but soo intuitive. I always struggled to differentiate between "temporary comment", and "comment that is here to stay"
A tip from history from old C coder. Do not use any numeric values in the code, except 0 for initialization. When you use numeric values, then after you read the code, you don't know background of the value. It is self documentary to use constants all the time. When you need to edit your code, you just need to change the constant.
This is the number one code cleaning tip when going professional.
You can also have your expression continue over multiple lines by writing a backslash \
at the end of the line. This doesn't look as clean as the brackets mentioned in the video though.
your channel is becoming more a more a huge goldmine. Heavily underrated!
for the last tip, you can use "\" for multiple lines
Thank you so much for talking about documentation comments :) i always wanted something like that in Godot, now i don´t have to keep going back to my own functions to remember how they work, i can just write documentation
Basically, this is the video about code style )
Simple but never gets old )
Well, writing clear code is much, much more than just five tips. In this video, you don't even scratch the surface. You blew five tiny specks of dust from it.
Great tips! That last one was new for me!
I'm a big fan of using Word Wrap for long lines. It's simple and works well when I resize the window for whatever reason.
Word wrapping isn't your friend, because you often need to use different lines for semantic reasons and readability.
a quick example
this:
var dot := Vector2(offset.x + radius * cos(alpha + angle_offset), offset.y + radius * sin(alpha + angle_offset))
would look much better:
var dot := Vector2(offset.x + radius * cos(alpha + angle_offset),
offset.y + radius * sin(alpha + angle_offset))
Imagine the expression is much longer than that. Word wrapping can completely f it up:
var dot := Vector2(offset.x + radius * cos(alpha
+ angle_offset),
offset.y + radius * sin(alpha
+ angle_offset))
@@Rai2M - I just put both examples that in my editor, it seems fine.
@@computersciencestudentriverbat Whatever works for you, buddy.
Good tips, I Iearned something new!
1:00 how can you write the hashtags before the marked text?
Is there a place I can learn more about 4? I struggle with naming stuff all the time and would love to see a full writeup.
Very nice, some of these suggestions are good for any developer, game or otherwise.
I'm a professional software engineer and my company uses lint to enforce some of these things for our frontend (built in React).
With this your git pipeline will actually fail if you have any lint warnings regarding styling like this that weren't automatically formatted by our pre-commit hooks.
Very helpful.
there should be something similar to prettier in VSCode within Godot which adds a default code style.
Uhh.. why does keeping a trailing comma help to add items?
It doesn't. I was also baffled by this.
Most of these are things that should be handled by an auto formatter IMO. It would be awesome if Godot adds one but for now there is gdscript toolkit for linting and formatting
Any tips for grouping and naming for the filesystem?
Like do you seperate scenes from scripts or do you save similar things (like an enemy scene and enemy scripts) in the same place for easier access?
I like keeping scripts together with their scenes and group scenes with folders. I've seen people just put all their scenes in one folder and scripts in another and that looks so messy to me.
@@charliegnu Yeah right now I do the same but I am always looking for the more efficient way. I wish the scenes with scripts were bundled together in the filesystem. (like next to each other)
I also go between name sorting so the scripts that have the same name as the scenes are together but also tried by type which separates the scenes and scripts in 2 but keeps them in the same folder.
I wish godot had an opinionated autoformatter like many other modern languages have out of the box. Spend less time formatting and more time coding.
I do number 2 because it looks nicer in the code, I had no idea it was a coding rule
The comma at the end of elements for an array, dictionary is great for git repos. If you add an item to the array it's a single line change not 2 changes (1 for the comma and another for the new item). Great tips!
every time he says godot I listen "el gato"
godot editor editor need a little some code editor feature that all editor comes with nowadays like format on save
I wish the GDScript lang server would add a linter to do this like rustfmt in Rust.
Thank you
instead of doing
if condition_A && condition_B && condition_C:
i like to do one of these
if condition_A:
if !condition_B: return
if !condition_C: return
Actually it's called SCREAMING_SNAKE_CASE
write more code to have better lighting ;)
hi sir i'm a new sub here hope you don't mind if i have a request
i have a problem running my godot engine in forward and mobile renderer every time i try to run it, it just show black editor and i couldn't do any thing i hope you will see this and accept my request in return i will continue supporting your channel till the end of my life
The thing is that Godot is a game engine. To try to be an IDE too is a lot of work that is never going to come close to VSCode or Visual Studio.
Just saying.
So u declare that "document comments" exist, but u never explained the difference between the 3 different comments u refer to.
Comment where it's confusing.
Use proper variable names so it's less confusing.
Comments should be minimal.
Some expressions won’t work with a trailing comma. Most will, but not all. Just be warned.