Discussion:
[dart-misc] Dart 2.0: Standard Nomenclature for Core Classes of Types (int, num, bool, double)
Samuel Schwebel
2018-04-09 14:53:19 UTC
Permalink
Hi,

Dart is a very nice language. I'm pretty glad to see the revisions that are
occurring in Dart 2.0. This clearly shows that there was learning in the
early years of language and that to grow it is necessary to consider this
learning and to make improvements.

Besides other activities I am also a teacher. And I see that wherever there
are patterns there is the idea that it was well designed and students learn
much more quickly.

A standard nomenclature convention that I understand Dart applies to object
classes, they should *start with a letter uppercase*.

As in one of the last revisions of Dart 2.0, I saw was the revision of the
nomenclature pattern for constants, *eg JSON for json*., I am here as a
suggestion, proposing a revision of names of the core classes, to *follow a
naming pattern for classses*. Here are some examples:

*double* would be *Double*
*num* would be *Num *or *Number*
*int* would be *Int* or *Integer*
*bool* would be *Bool* or *Boolean*

Perhaps the two forms of nomenclature could coexist for some time together,
because of the impact magnitude of this great change.

Anyway, it's the suggestion!

Best Regards,
Samuel.
--
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/CAHo81rKJdgg87eHsXs-HBGcvAiP%2Bv8Qo0GFPrp6GfKu%3DEcLU7w%40mail.gmail.com.
'Florian Loitsch' via Dart Misc
2018-04-09 14:57:34 UTC
Permalink
The main reason for this discrepancy was that we just couldn't let go of
`for (int i = 0; ...)`.
Remember, that with Dart 1, this code wasn't equivalent to `for (var i = 0;
...)` and that, for many of us, this was common code.

With Dart 2, `var i = 0` is the exact equivalent and would thus work.
The easiest solution is to make `int` a typedef-alias for `Int` or
`Integer`. For that to happen we first need typedef-aliases.
Post by Samuel Schwebel
Hi,
Dart is a very nice language. I'm pretty glad to see the revisions that
are occurring in Dart 2.0. This clearly shows that there was learning in
the early years of language and that to grow it is necessary to consider
this learning and to make improvements.
Besides other activities I am also a teacher. And I see that wherever
there are patterns there is the idea that it was well designed and students
learn much more quickly.
A standard nomenclature convention that I understand Dart applies to
object classes, they should *start with a letter uppercase*.
As in one of the last revisions of Dart 2.0, I saw was the revision of the
nomenclature pattern for constants, *eg JSON for json*., I am here as a
suggestion, proposing a revision of names of the core classes, to *follow
*double* would be *Double*
*num* would be *Num *or *Number*
*int* would be *Int* or *Integer*
*bool* would be *Bool* or *Boolean*
Perhaps the two forms of nomenclature could coexist for some time
together, because of the impact magnitude of this great change.
Anyway, it's the suggestion!
Best Regards,
Samuel.
--
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/a/dartlang.org/d/msgid/misc/CAHo81rKJdgg87eHsXs-HBGcvAiP%2Bv8Qo0GFPrp6GfKu%3DEcLU7w%40mail.gmail.com
<https://groups.google.com/a/dartlang.org/d/msgid/misc/CAHo81rKJdgg87eHsXs-HBGcvAiP%2Bv8Qo0GFPrp6GfKu%3DEcLU7w%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
--
Give a man a fire and he's warm for the whole day,
but set fire to him and he's warm for the rest of his life. - Terry
Pratchett
--
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/CAGhYCvBR701TdUdVUHi_UJ1_SKO8T3-w83Q98kRKWG00Hk_Cgg%40mail.gmail.com.
tatumizer-v0.2
2018-04-09 22:30:07 UTC
Permalink
Post by 'Florian Loitsch' via Dart Misc
The main reason for this discrepancy was that we just couldn't let go of
`for (int i = 0; ...)`.

Not sure I understand the argument. You can still write `for (var i = 0;
...)` in dart2, and 'var' will be treated as int (in dart2, the type is
inferred from assignment, unless I got something completely wrong).
So if dart2 just deprecates int in favor of "Int" or "Integer", then the
above 'for' loop won't even be affected by this renaming.

Or maybe you mean that there's too much core written already with `for
(int i = 0; ...)`. So what? just rename int to Int everywhere in the
program (it can be done by the simple script).
Sure, full-blown "Integer" might look awkward in this context, but I think
it will look awkward in any context. "Int" is a better choice IMO. You can
consider it a special case where abbreviation is justified by convenience.
--
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/94931fd5-6878-40d2-adc0-2e949db60aac%40dartlang.org.
'Florian Loitsch' via Dart Misc
2018-04-10 09:40:24 UTC
Permalink
Sorry. I wasn't clear.
I explained why `int` was called `int` in the first place (and not
`Integer`). We didn't just miss this inconsistency, but explicitly opted
for `int` instead of `Integer`.
Some of the reasons behind this choice are now gone, so we could
theoretically change the name from `int` to `Integer` now. However, as you
mention, this would be a big change. Personally, I don't think the benefits
are worth the cost of migration and churn.
Post by 'Florian Loitsch' via Dart Misc
Post by 'Florian Loitsch' via Dart Misc
The main reason for this discrepancy was that we just couldn't let go of
`for (int i = 0; ...)`.
Not sure I understand the argument. You can still write `for (var i = 0;
...)` in dart2, and 'var' will be treated as int (in dart2, the type is
inferred from assignment, unless I got something completely wrong).
So if dart2 just deprecates int in favor of "Int" or "Integer", then the
above 'for' loop won't even be affected by this renaming.
Or maybe you mean that there's too much core written already with `for
(int i = 0; ...)`. So what? just rename int to Int everywhere in the
program (it can be done by the simple script).
Sure, full-blown "Integer" might look awkward in this context, but I think
it will look awkward in any context. "Int" is a better choice IMO. You can
consider it a special case where abbreviation is justified by convenience.
--
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/a/dartlang.org/d/msgid/misc/94931fd5-6878-40d2-adc0-2e949db60aac%40dartlang.org
<https://groups.google.com/a/dartlang.org/d/msgid/misc/94931fd5-6878-40d2-adc0-2e949db60aac%40dartlang.org?utm_medium=email&utm_source=footer>
.
--
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/CAGhYCvBsNnyeUOOVQHs%3Dxha%2BVxR71LBzozHTUFwoJUQ7M10HTQ%40mail.gmail.com.
Samuel Schwebel
2018-04-10 13:39:13 UTC
Permalink
Just reinforcing one of the arguments.

I understand the change would be quite large.

I think most people who have been using these Classes (lowercase) in Dart
for some time or those who see similarities with other languages do not
care about these differences, although in Java, e.g., are primitive types,
not objects. (even though I've been using it for some time, I personally do
not feel comfortable!)

However, if we consider that new people want to learn a programming
language and the first language is Dart, it will be clearer to them that*
all Dart classes begin with the capital letter, without exception*.

best regards!

Em ter, 10 de abr de 2018 às 06:40, 'Florian Loitsch' via Dart Misc <
Post by 'Florian Loitsch' via Dart Misc
Sorry. I wasn't clear.
I explained why `int` was called `int` in the first place (and not
`Integer`). We didn't just miss this inconsistency, but explicitly opted
for `int` instead of `Integer`.
Some of the reasons behind this choice are now gone, so we could
theoretically change the name from `int` to `Integer` now. However, as you
mention, this would be a big change. Personally, I don't think the benefits
are worth the cost of migration and churn.
Post by 'Florian Loitsch' via Dart Misc
The main reason for this discrepancy was that we just couldn't let go
of `for (int i = 0; ...)`.
Not sure I understand the argument. You can still write `for (var i = 0;
...)` in dart2, and 'var' will be treated as int (in dart2, the type is
inferred from assignment, unless I got something completely wrong).
So if dart2 just deprecates int in favor of "Int" or "Integer", then the
above 'for' loop won't even be affected by this renaming.
Or maybe you mean that there's too much core written already with `for
(int i = 0; ...)`. So what? just rename int to Int everywhere in the
program (it can be done by the simple script).
Sure, full-blown "Integer" might look awkward in this context, but I
think it will look awkward in any context. "Int" is a better choice IMO.
You can consider it a special case where abbreviation is justified by
convenience.
--
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/a/dartlang.org/d/msgid/misc/94931fd5-6878-40d2-adc0-2e949db60aac%40dartlang.org
<https://groups.google.com/a/dartlang.org/d/msgid/misc/94931fd5-6878-40d2-adc0-2e949db60aac%40dartlang.org?utm_medium=email&utm_source=footer>
.
--
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/a/dartlang.org/d/msgid/misc/CAGhYCvBsNnyeUOOVQHs%3Dxha%2BVxR71LBzozHTUFwoJUQ7M10HTQ%40mail.gmail.com
<https://groups.google.com/a/dartlang.org/d/msgid/misc/CAGhYCvBsNnyeUOOVQHs%3Dxha%2BVxR71LBzozHTUFwoJUQ7M10HTQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
--
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/CAHo81rLyWR72%3DSe3vgWPe%3DDE29tz65jy%2Bgvo9omfYc5M4muy-g%40mail.gmail.com.
Randal L. Schwartz
2018-04-10 14:10:54 UTC
Permalink
Florian> I explained why `int` was called `int` in the first place (and
Florian> not `Integer`). We didn't just miss this inconsistency, but
Florian> explicitly opted for `int` instead of `Integer`.

I may be wrong but one interesting similarty about the four core
lowercase classes (bool, int, double, num) is that there are no mutator
methods (that I saw), so you can consider them as "pass by
value"... there's nothing a called method can do that will change "1" to
"2" out from under you. That's not true with the remaining
classes... nearly everything has the potential of being mutated in the
invoked method, so it's closer to "pass by reference".

Hmm. Maybe String is also immutable... looks like all the methods
return a copy.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<***@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/Dart consulting, Technical writing, Comedy, etc. etc.
Still trying to think of something clever for the fourth line of this .sig
--
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/867epfrw29.fsf%40red.stonehenge.com.
'Lasse R.H. Nielsen' via Dart Misc
2018-05-02 19:46:44 UTC
Permalink
Post by Randal L. Schwartz
Florian> I explained why `int` was called `int` in the first place (and
Florian> not `Integer`). We didn't just miss this inconsistency, but
Florian> explicitly opted for `int` instead of `Integer`.
I may be wrong but one interesting similarty about the four core
lowercase classes (bool, int, double, num) is that there are no mutator
methods (that I saw), so you can consider them as "pass by
value"... there's nothing a called method can do that will change "1" to
"2" out from under you. That's not true with the remaining
classes... nearly everything has the potential of being mutated in the
invoked method, so it's closer to "pass by reference".
Hmm. Maybe String is also immutable... looks like all the methods
return a copy.
String is immutable, but string objects still have a meaningful *identity*.

For bool and num classes, if `a == b` then `identical(a, b)`. In that sense
the classes behave more like *value types*, rather than object types.
You cannot create a *new* integer, they all exist already. You can create a
new unique String object that is detectably distinct from all other strings
(well, unless you compile to JavaScript, then you can't because JavaScript
treats strings as value types).
That's the same reasoning that made String an object in Java, but int and
bool primitive types.

/L
--
Lasse R.H. Nielsen - ***@google.com
'Faith without judgement merely degrades the spirit divine'
Google Denmark ApS - Frederiksborggade 20B, 1 sal - 1360 KÞbenhavn K
- Denmark - CVR nr. 28 86 69 84
--
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/CA%2BeWuVB_cExtFHbMp6ChUpcHPtq%3DSJ-YgnRhJ-ooJjWyrbWJEQ%40mail.gmail.com.
tatumizer-v0.2
2018-05-03 15:46:24 UTC
Permalink
I have an alternative theory: lowercase classes are called this way because
intuitively, they are small (atomic), as opposed to "real" classes, which
are intuitively big (complex).
It's also a matter of habit and tradition.

I find arguments based on mutability/equality/identity too complicated and
vulnerable to counterexamples.
@Lasse: in java, there're more "things" for which equality and identity is
the same: enum values, classes (llke String.class)
--
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/e1e13807-1278-48ce-abcd-090866c83354%40dartlang.org.
Jan Mostert
2018-05-04 16:19:06 UTC
Permalink
The argument is that in other language like Java, primitives are lowercase
and that these are like primitives to Dart
So they are kept like this for the sake of familiarity:
https://github.com/dart-lang/sdk/issues/1410

Although I disagree with this, you can't do this with a primitive in Java:
double.parseDouble("12.3") or int.parseInt("23")
Kotlin just made them all uppercase for consistency's sake and since all
objects starts in uppercase: Double.MAX_VALUE, Int.MAX_VALUE ( parsing is
done via extensions here, "12.3".toInt() )

In Dart, even the primitives are objects ... which IMO means they're no
longer primitives and should be uppercase

Kotlin has something called typealias which if Dart had it, could allow us
to "typedef Double double"
typedef in Dart could probably achieve the same thing if it was supported
Post by tatumizer-v0.2
I have an alternative theory: lowercase classes are called this way
because intuitively, they are small (atomic), as opposed to "real"
classes, which are intuitively big (complex).
It's also a matter of habit and tradition.
I find arguments based on mutability/equality/identity too complicated and
vulnerable to counterexamples.
@Lasse: in java, there're more "things" for which equality and identity is
the same: enum values, classes (llke String.class)
--
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/a/dartlang.org/d/msgid/misc/e1e13807-1278-48ce-abcd-090866c83354%40dartlang.org
<https://groups.google.com/a/dartlang.org/d/msgid/misc/e1e13807-1278-48ce-abcd-090866c83354%40dartlang.org?utm_medium=email&utm_source=footer>
.
--
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/CAKkrQ9svO%2B97iMLP8bOyShXNvgqpUgzQ76%3DVhdbBHsJ%2BJ2-pgw%40mail.gmail.com.
Loading...