Are get_node() and $ exactly equivalent?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ruckus T-Boom

An often recommended performance optimization is to remove get_node() calls from hot code paths and instead move them to an onready var. Does the same hold true for the $NodePath literal syntax, or is it somehow optimized away?

Basically, my question is, does


work exactly like


And, if so, is it recommended to use something like

onready var Cam = $Neck/Camera

:bust_in_silhouette: Reply From: kidscancode

Yes, those two statements are equivalent.

As for your performance question, this is something that can only be answered by profiling. In practice, for most scripts, the difference is negligible.