-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
int, double, and String have inconsistent capitalization #1410
Comments
Removed Type-Defect label. |
Issue #1411 has been merged into this issue. |
I think this is mostly an outgrowth of tradition. Types are usually uppercase, but int, double are too established. Where do we draw the line? At string? Or at list? Or map? All these have corresponding literals. So what's special about String? The only consistent decision would be to use upper-case throughout, and that won't fly. |
This comment was originally written by elliotprio...@gmail.com There's no such thing as "too established". There's no advantage to shackling yourself to established languages when designing a new one, it just hampers innovation. Also, it will upset people with OCD. |
This comment was originally written by eugen...@eugenkiss.com "The only consistent decision would be to use upper-case throughout [...]" There you said it. I understand that familiarity in general has a higher priority than innovation/experimental design in Dart, but wouldn't you say that consistency should be even more important than familiarity? Correct me if I am mistaken: Isn't the reason for using lowercase int, double etc. in Java that these are primitives (see also: http://stackoverflow.com/questions/4006302/why-is-java-string-type-written-in-capital-letter-while-int-is-not)? Other types in Java begin with an uppercase by convention. So Java's naming convention is in some way consistent. In Dart, however, int, double etc. are "first class types" which can be, among other things, assigned null. So using Java's naming convention which is both consistent and by definition (in the context of Dart) familiar would lead to be "upper-case throughout". Now I know that Java is not the sole inspiration (or counterexample :)) for Dart and frankly, I don't really care if int, double etc. are written lowercase. I just wanted to point out that it would be more consistent and not necessarily unfamiliar if they would begin with an uppercase letter. |
I may have OCD because this does upset me. I find it particularly confusing now because the lower case names to me imply that those types are not nullable, which isn't the case. Uppercase for everything would work fine. I don't think it's much of a typing tax since you can (and probably should) just use "var" or "final" for locals anyway. |
This comment was originally written by ladicek@gmail.com I'd like to point out that num, int and double (and also bool) are somewhat special -- they are interfaces that can't be implemented by user code. Well, I see that it applies to String too, so it's not much of an argument, but still. Lowercasing String looks to me like a viable route. |
This comment was originally written by andrew.pennebak...@gmail.com Inconsistency increases learning time, proliferation of bugs, and overall frustration with a language. Fix it. |
This comment was originally written by kale.s...@gmail.com +1 for consistency! lowercased string for dart. |
See my comments above. Added WontFix label. |
This comment was originally written by haaiee...@gmail.com Having uppercase String suggests to me that String is a constructor. I am used to lowercase someobject meaning an instance or a language construct and uppercase Someobject meaning a constructor. String looks very Javascripty which could make people coming from Javascript trying to use it in a Javascript way. |
This comment was originally written by bfitc...@gmail.com Being mildly autistic, I cringe every time I browse through the practice Dart code that I've written and see, for example, double.parse (instead of Double.parse). I have to treat the experience of using the language as a kind of "immersion therapy", or a character-building exercise in acceptance of decisions beyond my control that result in unnecessary inconsistency. In my mind, Dart is forever "the programming language in which int, double, num, and bool are lowercase for no logical reason while all other types are capitalized". The language is great otherwise. (Sigh) |
Why has this issue been closed? this leads to inconsistency in the language. |
There are millions of lines of Dart code inside Google and outside, so it is too costly of a change to make now compared to the value we would get in return. |
I was under the impression that Dart, being something new, would address inconsistencies better that other languages...was I so wrong? |
I like what C# does, you can use string or String |
I’m new to Dart but not programming. First question I have is “Why String isn’t string?” :) |
The real question, if you are going for consistency, is why So if you want consistency, we should make In Java, Or maybe there is one reason: The real reason Dart has those exceptions ( Making (If we get generalized type aliases, you can probably define your own |
In my opinion lower case types are primitives and capitalized types are not-primitives like classes. Ok I come from TypeScript. I'm new in Dart. The different capitalization of primitive types is not really intuitive and confusing. Bad user experience. It should be consistency. Why is |
I think it's not a question about how and why. There is no understandable reason to have inconsistent capitalization of the primitive types.
But why not "Hey, let us use lower case letters for the primitive types." Passed through reviewer, etc. Sorry it sounds amateurish. No offense. I just can't understand it. This could be a breaking change for the next major version. |
just do what c# did, and allow both upper and lower case versions of string ... (and anyone who actually used "string" for a variable name will have to change, but that's ok because they would deserve it) fun response to "what is the diff between string and String in C#" "String uses a few more pixels than string. So, in a dark room, it will cast a bit more light, if your code is going to be read with light-on-dark fonts. Deciding on which to use can be tricky - it depends on the price of lighting pixels, and whether your readership wants to cast more light or less. But c# gives you the choice, which is why it is all-around the best language." and later "saves on toner too" :) |
If/when we get type aliases (dart-lang/language#65), I'm sure a |
The only thing I found annoying about Dart is why String is not string...but why?????????? |
@devhammed Honest answer: Because that's what it is in Java. The original Dart design was deliberate in being "non surprising" to people coming from Java and JavaScript, and to some extent C#. If Java had had a (And again: Dart does not have any "primitive types". Any argument based on making a distinction between primitive types and non-primitive types does not apply to Dart. Dart has lower-case |
Why comparing languages? It's not a good idea to compare Java with JavaScript. You should not force Java conventions into JavaScript and vice versa. ... What was the goal? Why develop a new language? Do it better! A new language should make things better and go its own way. Especially when it comes to this issue. |
For all types that are lowercase (bool, int, double), dart should optionally also allow upper-case so people who value consistency can use all capitalized types, since capitalizing types is the standard, and bool, int, and double, are just exceptions without good merit. |
Why this is close? :D This is such inconsistency, really brings confusion if someone logically approach to a concept, that in Dart every type is an Object. People who also have experience in other languages like for example Java at first glance they will assume that those types works in the same way (and the int is not an actual Object). You should allow to define integer in both way (int and Int) if not deprecate the int declaration |
Forget about.
I thinks it is a reminder,that nothing in the world is perfect.
And there are things that will never change.
Dart has improved in such a way since 1.0 that I can forgive this one.
Em sex., 30 de jul. de 2021 às 16:37, tabks ***@***.***>
escreveu:
… Why this is close? :D This is such inconsistency, really brings confusion
if someone logically approach to a concept, that in Dart every type is an
Object. People who also have experience in other languages like for example
Java at first glance they will assume that those types works in the same
way (and the int is not an actual Object). You should allow to define
integer in both way (int and Int) if not deprecate the int declaration
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1410 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHGYQ32ILBP7YNDJV3YQBVTT2L5QFANCNFSM4B6QQ4PQ>
.
|
Is it possible to kindly fix this inconsistency in the next major version? May be allow both capital and small cases. It's a little bit weird. |
could somebody please fork dart and add this? you will get my star :) |
Type aliases have been released in dart 2.13. So now you can use typedef string = String; or typedef Int = int; |
This issue was originally filed by gundl...@gmail.com
Please consider renaming "String" to "string. I know, I'm mostly bikeshedding. But why isn't "String" "string" if "Int" and "Double" are also lowercased?
I get the impression you lowercased "int" and "double" to make them feel like primitives and to match Java. Perhaps String is capitalized to match Java, but it's lowercased in C#, so that's a weak argument.
The text was updated successfully, but these errors were encountered: