4 ms·
Dart anybody?
by devxpy 8y ago
Dart anybody?
- redsolver 8y agoDart is amazing
- continuational 8y agoYes, Dart is amazingly broken for a modern language. This compiles: List<Animal> animals = [Dog()]; List<Cat> cats = animals; What is a static type system worth if it doesn't catch type errors at compile time?
- fcurts 8y agoDart 2 has a sound type system and catches this at compile time.
- cmmartin 8y agoGrain is quite different. Grain is more functional (no classes or context, tuples). Dart compiles to Javascript. Grain compiles to web assembly. Dart requires you to define types. Grain provides type safety and zero runtime errors without ever defining types manually.
- pmontra 8y agoThe documentation about types says to look at the Readme of the compiler, which is very short and doesn't tell anything about types. Same thing for many other entries in the side menu. The examples don't have any type declaration. So, type inference and no reuse of the same variable with a different type, even when forcing mutation? Unfortunately the documentation is still too skinny. A note to language designers: I can understand the { } but if you use them why do you also need the ( ) around the conditionals here? if (n <= 1) { n == 0 } else { isOdd(n - 1) } The parser can find where the condition starts (after the if) and ends (at the {) and we won't have to type two useless characters. It's ergonomics.
- andyonthewings 8y ago( ) are only optional if { } are mandatory, which is not true for some languages. e.g. in Haxe, one can write static function isEven(n) return if (n <= 1) n == 0; else isOdd(n - 1); static function isOdd(n) return if (n <= 1) n == 1; else isEven(n - 1); i.e. An if expression consists of other expressions that may or may not be a block expression ({ }).
- pmontra 8y agoThere is a great deal of variability in languages about that. Python ends if lines with a : which might help the parser, but maybe not because it was a late addition to help readability. For me it adds work when moving code around because I have to add or remove the : Ruby does totally without any terminator in that context (in other contexts it has its own {} or do...end). The parser keeps processing successive lines until it understands that what follows can't belong to the conditional. I prefer that approach because it's the language/compiler that has to help me, not the other way around.
- deleted 8y ago[deleted]
- cmmartin 8y agoWell if you are worried about those 2 characters, you should be stoked about Grain, because it gives you type safety without ever defining types. Think how many characters you will save in an application by never defining a type and at no cost.
- pmontra 8y agoWell, the languages I'm using are Ruby, Python, Elixir, JavaScript so I definitely like not to write types. Still, I don't know how types work in Grain. The documentation doesn't say anything about it or it's very well hidden.
- devxpy 8y agoSo it's more like elm then?
- cmmartin 8y agoMore like elm than Dart, but elm also compiles (transpiles?) to javascript and Grain compiles to web assembly