Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

Statically typed variables = SPEED! (Godot)

Автор: Hyper Game Dev!

Загружено: 2024-08-14

Просмотров: 80605

Описание:

Someone in the Hyper Game Dev community, ‪@precipire1025‬, posted a great article that convinced me to avoid leaving my variables untyped. Here's the article:
https://www.beep.blog/2024-02-14-gdsc...

Previously, I had enjoyed the convenience Godot affords devs by allowing us to type variables without clarifying what type of variable it is. That is to say, if it's a boolean (true/false), Godot doesn't require us to clarify that this is a "bool". There are lots of different types that variables can be assigned to, and it is an extra step that sometimes is nice to skip. Other common variable types are integer (if the variable is a whole number), or float (if it's a decimal), or any of the many Node types that Godot offers.

But this practice of avoiding the type clarification comes at a performance cost, especially when we consider just how many variables a single project can have.

Shaving off even those fractions of a second can really add up, so now I make a point to statically type my variables wherever I can.

The simple explanation for why this helps, is that Godot has to actually figure out what the variable type is if we don't explicitly tell it. This is called Static Typing, or Declaring the variable.

Thanks to some tests run by ‪@Riazey‬, I know now that a colon and an equal sign, or ":=" is often as fast as static typing! (Though there are some edge cases where it's a tiny bit slower). At that point, it may come down to personal preference if you'd rather use := or explicitly statically type the variable.

To statically type your variables, add a colon, and the variable type, before your equal sign (eg, ": bool ="), and you'll give Godot a break from having to sort it out itself. := despite only rarely being slower works too, but I still prefer typing it all out.

I hope this information was helpful or useful to you!
By the way, I do livestream pretty often here on YouTube, so I hope you'll consider subscribing to see me continue learning Godot in public.
   / @hypergamedev  

Also also, you can join this channel too, and get access to some pretty dope perks (like an exclusive livestream, and me singing you songs when you join chat)
   / @hypergamedev  

Oh, and shout-outs are due to ‪@DungeonMartian‬ and ‪@Dr4g0nBlade‬ for the feedback while I recorded this!

Chapters & Tags:
#gdscript #godot #coding
00:00 - Static Variables Make Your Game Faster
00:06 - Untyped Variable VS Statically-Typed Variable
00:18 - Inferred Variable and Untyped Variables are Slow
00:25 - Make Godot Force Statically-Typed Variables

Statically typed variables = SPEED! (Godot)

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

array(10) { [0]=> object(stdClass)#5513 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "cTSrjN_2qDI" ["related_video_title"]=> string(55) "save hours of programming using curves | Godot Tutorial" ["posted_time"]=> string(27) "6 месяцев назад" ["channelName"]=> string(10) "AceSpectre" } [1]=> object(stdClass)#5486 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "2ifq1k-B0oY" ["related_video_title"]=> string(54) "the godot game development tutorials you need to watch" ["posted_time"]=> string(27) "6 месяцев назад" ["channelName"]=> string(8) "Deeteeee" } [2]=> object(stdClass)#5511 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "3Xk2I7Gjdy0" ["related_video_title"]=> string(34) "I Like Coding By CHARISE AGUINALDO" ["posted_time"]=> string(24) "10 минут назад" ["channelName"]=> string(8) "ProjectX" } [3]=> object(stdClass)#5518 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "ccgl0vh8es8" ["related_video_title"]=> string(31) "Why I'm Moving To Godot In 2025" ["posted_time"]=> string(27) "6 месяцев назад" ["channelName"]=> string(7) "Acerola" } [4]=> object(stdClass)#5497 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "iaVuagsoZIY" ["related_video_title"]=> string(29) "Godot Is DESTROYING Itself..." ["posted_time"]=> string(27) "9 месяцев назад" ["channelName"]=> string(15) "Cube Dimensions" } [5]=> object(stdClass)#5515 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "cYPaZnB0VWI" ["related_video_title"]=> string(79) "В моей НАСТОЯЩЕЙ ОС теперь есть звук | x16-PRos" ["posted_time"]=> string(23) "1 месяц назад" ["channelName"]=> string(36) "PRoX (Фаддей Кабанов) " } [6]=> object(stdClass)#5510 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "wR4LAq8ihOo" ["related_video_title"]=> string(39) "Why You Should NOT Use the Godot Engine" ["posted_time"]=> string(27) "9 месяцев назад" ["channelName"]=> string(13) "StayAtHomeDev" } [7]=> object(stdClass)#5520 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "192KLouTZMA" ["related_video_title"]=> string(90) "Игра, опередившая время на десятилетия | The Movies 2005" ["posted_time"]=> string(22) "12 дней назад" ["channelName"]=> string(7) "Amytrip" } [8]=> object(stdClass)#5496 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "4MuKDE9z7cQ" ["related_video_title"]=> string(121) "Я СДЕЛАЛ ИДЕАЛЬНЫЙ ШАР ИЗ ОБЫЧНОЙ ЗЕМЛИ - ДРЕВНЯЯ ЯПОНСКАЯ ТЕХНИКА" ["posted_time"]=> string(24) "14 часов назад" ["channelName"]=> string(10) "SlivkiShow" } [9]=> object(stdClass)#5514 (5) { ["video_id"]=> int(9999999) ["related_video_id"]=> string(11) "iLtSguWuUt4" ["related_video_title"]=> string(157) "Симпсоны — идеальная семья? | Почему сегодня не рожают, как 50 лет назад (English sub) @Max_Katz" ["posted_time"]=> string(23) "7 часов назад" ["channelName"]=> string(19) "Максим Кац" } }
save hours of programming using curves | Godot Tutorial

save hours of programming using curves | Godot Tutorial

the godot game development tutorials you need to watch

the godot game development tutorials you need to watch

I Like Coding By CHARISE AGUINALDO

I Like Coding By CHARISE AGUINALDO

Why I'm Moving To Godot In 2025

Why I'm Moving To Godot In 2025

Godot Is DESTROYING Itself...

Godot Is DESTROYING Itself...

В моей НАСТОЯЩЕЙ ОС теперь есть звук  |  x16-PRos

В моей НАСТОЯЩЕЙ ОС теперь есть звук | x16-PRos

Why You Should NOT Use the Godot Engine

Why You Should NOT Use the Godot Engine

Игра, опередившая время на десятилетия  | The Movies 2005

Игра, опередившая время на десятилетия | The Movies 2005

Я СДЕЛАЛ ИДЕАЛЬНЫЙ ШАР ИЗ ОБЫЧНОЙ ЗЕМЛИ - ДРЕВНЯЯ ЯПОНСКАЯ ТЕХНИКА

Я СДЕЛАЛ ИДЕАЛЬНЫЙ ШАР ИЗ ОБЫЧНОЙ ЗЕМЛИ - ДРЕВНЯЯ ЯПОНСКАЯ ТЕХНИКА

Симпсоны —  идеальная семья? | Почему сегодня не рожают, как 50 лет назад (English sub) @Max_Katz

Симпсоны — идеальная семья? | Почему сегодня не рожают, как 50 лет назад (English sub) @Max_Katz

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]