It’s all about the idioms.
🙄Ok… the title sounded good in my head anyway.
I keep hearing how GDScript is almost like Python… then I learn GDScript has no exceptions. Exceptions aren’t bad or good; the thing is, Python is idiomatically very RAII-centric. RAII USUALLY requires something rather exception-like. So, most Python idioms don’t necessarily work. I could allocate then initialize, internally… or I can use a factory externally and get much the same effect, but how do I do this in a way that’s obvious to other GDScript developers? Godot isn’t big enough to have GDScript idioms well documented in the wild outside Godot forums, so they really need to be driven home hard in the docs that DO exist. I see some evidence that returning a dictionary to convey an error may be a “popular” convention, but I’m unsure if this is real, or something ChatGPT is hallucinating? This unfortunately seems a bit more dangerous in a dynamically typed language. Nothing wrong with dynamic typing, but strong types, even if they are optional, can offer some nice guardrails, like knowing I’m looking at an error status rather than a value. I understand that dictionaries provide nice clear string names for things, but they are at least an order of magnitude slower than an array with enum indices ERROR_IDX, VALUE_IDX, or even a purpose-built ValueOrError class. All these are possible to do in almost any language, but any semblance of a standard return an error or value idiom in GDScript seems muddy at best.
I happen to like exceptions in this context as they are much less ambiguous. I don’t mind Go’s error value type, but without type inference, this is an accident waiting to happen. I like templates or other generics as they enable a more expressive type system, but GDScript’s doesn’t seem well developed enough for templates to bring anything to the table.
GDScript seems like a perfectly reasonable and capable little language, even if it lacks a few creature comforts… but it seems to be missing the boat a bit in well-established and documented standard conventions. Please point me at some more rigorous documentation?
Thanks,
-Loren