-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent type styling in Godot editor #44922
Comments
This has nothing to do with consistency and not the same as PHP's problems. Primitive types are not capitalized in most C-like languages, while classes can be capitalized as per individual style guide. If anything, |
int, float and bool are plain old data types (Edit: primitive types is more correct, POD types is a wider and potentially more confusing concept). Array and String are templates, which are not trivial. So it makes sense for templated types to be capitalized like other non trivial types (e.g. Object). |
I would ask you both: from the end user's perspective do they care whether something is a primitive type or a class type? That seems like an academic difference that's only pertinent to the engine devs, not to the vast majority of game developers. In python behind the scenes everything is a Class, but to the users they see types, classes, even functions. The built-in types are all consistently lower-case (str, dict, tuple...) with the exception of It's hard to understate the value of consistency for a developer. |
It's not a matter of engine devs, it's very common in most programming languages that primitive types are identified as such with their case, as they typically have properties which different from non-primitive types (passing by value vs reference, copy/clone, etc.). For example, C# uses Another example: Rust primitive data types are lowercase: https://learning-rust.github.io/docs/a8.primitive_data_types.html There's no inconsistency here, this is on purpose, and this has not been a problem in the past 6 years for Godot users, whether experienced or beginners. |
I second Akien about capitalization, but I want to remind everyone that the first part of this issue is about syntax highlight 🙂 So to address that... Of the top of my head I cannot remember if any other language in any other editor highlighted primitive types the same as keywords or not, but this can probably be arranged anyway on our end. We can make a color for primitives a separate setting and let users decide if they want it to be the same as keywords, as classes, or have a unique color all together. |
@akien-mga - I see your C#/Rust examples, but isn't Godot meant to be Python like?
Is this distinction a thing in Godot? As far as I can see the Class types are a mixture of Reference (i.e. Array) and Value (i.e. PoolStringArray). As a end-user why do I care about whether something is primitive or classed? I can't see much of any difference, and if there is a different I'd suggest it should be explicitly documented in the docs rather than hoping the dev intuits it from capitalisation.
PyCharm groups all built-ins which includes types ( |
I've already suggested. Also, it would solve the first problem automatically.
No, there is inconsistency with the following naming conventions: var name: Name
func name(name: Name) -> Name
name is Name
name as Name All types except these three have a capitalized name. Any exception is inconsistency. The only question is whether there are any advantages to having the exception.
This is only because this inconsistency affects only appearance, but not behavior. Just like the fact that these types are highlighted in a different color than the rest.
Sorry, but in my opinion this is useless. All types should be highlighted with the same color. Otherwise it will be too colorful: primitive types - in one color, built-in types - in another, classes - in a third, custom classes - in the fourth, 2D types - in the fifth, 3D types - in the sixth, etc.
Absolutely agree. What does knowing whether the type is primitive or not? What is the difference between a primitive type and a non-primitive type? I could understand if types passed by value were written with a small letter, and types passed by reference with a capital letter. Or built-in types with small, and classes with capital. The only reason these three types are written with small letters is tradition, habit, and blind copying of C/C ++.
Yes, you are right, it is, although it is absolutely pointless. But in some languages (Kotlin, Haxe, Ada, etc) all types (even "primitive" ones) start with a capital letter, and this warms my perfectionist soul. But since it does not affect behavior, this is not a change I would fight for. It's just a little annoying that people think in such fictitious categories as “primitive” types. In comparison, the illogical and counter-intuitive behavior of the division operator creates much bigger problems, but people don't want to notice them and react extremely negatively due to the strength of their habits. |
In this regard, in GDScript |
No, it wouldn't. The way GDScript tokenizer works in terms of syntax highlight has nothing to do with the capitalization.
This is not what was suggested. I only propose we solve the problem presented here with a separate option for primitive types. By default, it would be the same color as keywords, as it is now, but whoever would like to highlight them differently, be it matching the color of classes or another color, would be able to do so. In the end, it will be as colorful as each individual user wants, which is fitting, as this issue is about individual user's preferences. |
Again, there's two things in this issue:
|
As far as I know, the problem is not in the tokenizer, but in the mechanism for highlighting the code of the There are no This is just a note, actually the problem is broader, for example
Does the user have a real need for this? Why do we need to provide the user with the ability to highlight "primitive" types with a different color than non-primitive ones? Maybe we need to add an option to change the color for each type? I mean, primitive types aren't that different from non-primitive types that they deserve a separate color. |
@akien-mga I respect your efforts to maintain order in discussions, but the two issues are related. I tried to count the differences between primitive types and non-primitive types and counted two differences:
I did not find any more differences (maybe someone will find it). Please note that both differences concern only appearance (color and case). |
Primitive data types have a few properties different from other data types:
Also, I was just messing around in GDScript, and it seems anything inheriting from |
@name-here These are not significant differences, just implementation details. In JavaScript, for example, you can do Once again, this is not a thing that I would fight for. I refer to it as "It would be nice." I just wanted to show that "primitive" types are a strange tradition. But I face the objection that there are some real reasons to classify primitive types into a separate category. It surprises me. |
It GDScript really all that high-level? It basically just interfaces with Godot's built-in C++ classes (a limited subset, at that), with python-like syntax and a few handy shortcuts like iterating over arrays more easily. And since GDScript does not exist outside of Godot—and never will—implementation details are important, since GDScript is its implementation, nothing more. There is nothing outside of the implementation that dictates what GDScript is supposed to be, or how it is supposed to work (the docs are only meant to describe what it is). This is a major difference between GDScript and "mainstream" languages. GDScript has a lot of ties to the C++ of the engine it interacts with—those "implementation details" being some of them. If Godot used semicolons and braces instead of line breaks, colons and indents, would you feel the same way about this? The real problem, though, is that any potential benefits of a change do not outweigh the obvious costs. True, there's no reason GDScript has to use " In general, I'd say the engine's syntax highlighting (and, relatedly, which things in GDScript are reserved words) is a little strange in |
GDScript is a high-level language because there are no pointers or other low-level memory manipulations. In terms of design and syntax, GDScript is a mixture of Python, JavaScript, and C++. But some things taken from C++ don't fit well with the fact that GDScript is a language whose goal is to be simple for beginners. I disagree with the opinion that GDScript should look familiar to C++ developers. This change is highly optional and insignificant, as most people don't care. But even if it were accepted, the old code would be easy to fix automatically, unlike some of the other recent GDScript changes. To summarize: in GDScript, primitive types are written in lowercase only because they are written this way in C++. There is no other reason. |
@akien-mga - I disagree that there are two things here. There's two flavours of the same thing. Put simply: Are primitives a special type of Type? This is not a "perfectionism" thing. This is a consistency thing. It's in the same vein of why Godot has a contributors style guide: Because anything that reduces the cognitive load on a developer is a good thing and consistency does that. Now personally I don't see how primitives are special to GDScript users, but @dalexeev has done a better job covering that than I did. |
For the last time: YES, they are a "special type of type". I'm tired of this bikeshedding. I tried to advocate for keeping this issue focused on the actual bug that can be fixed (syntax highlighting), but you keep bringing it back to advocating for breaking compatibility in the language design as if this was the same level of implication. |
Godot version:
3.2.3
Issue description:
The types:
int
,bool
, andfloat
are all styled as keywords rather than types in the editor:This introduces confusion to new users.
I'd also suggest int, bool, and float should be capitalised to be consistent with the rest of the types. One of the reasons that PHP has such a poor reputation in many circles is because of its lack of consistency. For example its naming of
substr
orstr_replace
and countless other string functions.Edit:
enum
type too?The text was updated successfully, but these errors were encountered: