Cristian Garcia
2015-08-22 14:00:39 UTC
I was looking into some Elixir videos and saw a Ceylon hangout video, got
me curious because I'd heard Ceylon was very close to Dart.
I poked around Ceylon's page and decided to code a simple class on their
online editor, here is what I coded.
class Person (name, age) {
variable String name;
variable Integer | String age;
shared String toString => "Name ``name``, Age ``age``";
}
Person person1 = Person ("Cristian", 26);
Person person2 = Person ("Mike", "Twenty three");
print (person1.toString);
print (person2.toString);
The other day Bob mentioned how maybe Dart should become more attractive by
standing out of the crowd by adding "cool" features at the risk of being
less familiar. Id like Dart to have these two features with are not really
wild changes, already exist in other languages, and should be the future.
1. Optionally remove the "new" keyword. Because we don't care about
memory allocation in Dart, period. It does nothing and factory constructors
might not even create "new" objects so the word is in fact lying.
2. Union types. Because while we could use "dynamic" and check for all
the cases ourselves, we also like type safety in Dart. Plus they are really
cool and play well with the Non-null proposal. In fact, in Ceylon types
cannot be null unless they are declared as SomeType? or SomeType| Null.
3. Primary constructor. Because record-like structures are "Ã la mode"
because of FP, but in reality they are pretty useful for classes with few
code. Might avoid the need to define a constructor at all.
Id like to write this code in Dart like this someday.
class Person (this.name, this.age) {
String name;
Integer | String age;
String toString () => "Name $name, Age $age";
}
var person1 = Person ("Cristian", 26);
var person2 = Person ("Mike", "Twenty three");
print (person1);
print (person2);
Looks sexy doesn't it? And the changes are minimal.
me curious because I'd heard Ceylon was very close to Dart.
I poked around Ceylon's page and decided to code a simple class on their
online editor, here is what I coded.
class Person (name, age) {
variable String name;
variable Integer | String age;
shared String toString => "Name ``name``, Age ``age``";
}
Person person1 = Person ("Cristian", 26);
Person person2 = Person ("Mike", "Twenty three");
print (person1.toString);
print (person2.toString);
The other day Bob mentioned how maybe Dart should become more attractive by
standing out of the crowd by adding "cool" features at the risk of being
less familiar. Id like Dart to have these two features with are not really
wild changes, already exist in other languages, and should be the future.
1. Optionally remove the "new" keyword. Because we don't care about
memory allocation in Dart, period. It does nothing and factory constructors
might not even create "new" objects so the word is in fact lying.
2. Union types. Because while we could use "dynamic" and check for all
the cases ourselves, we also like type safety in Dart. Plus they are really
cool and play well with the Non-null proposal. In fact, in Ceylon types
cannot be null unless they are declared as SomeType? or SomeType| Null.
3. Primary constructor. Because record-like structures are "Ã la mode"
because of FP, but in reality they are pretty useful for classes with few
code. Might avoid the need to define a constructor at all.
Id like to write this code in Dart like this someday.
class Person (this.name, this.age) {
String name;
Integer | String age;
String toString () => "Name $name, Age $age";
}
var person1 = Person ("Cristian", 26);
var person2 = Person ("Mike", "Twenty three");
print (person1);
print (person2);
Looks sexy doesn't it? And the changes are minimal.
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.