4 ms·
> That's garbage; it's not done now, because there's no ability to do that. One of the selling points of Dart is having typing; nobody would turn this down if i
by DCKing 12y ago
> That's garbage; it's not done now, because there's no ability to do that. One of the selling points of Dart is having typing; nobody would turn this down if it was easy and possible.
You assert that Dart has, in principle, the ability to do that. But it doesn't. Not in the general case. No class-based programming language can solve this problem in general. You can have a close-to-complete solution (like C# and Java do), but that complexity is very unwanted for a language running in the browser.
Adding a language feature to Dart does not solve this problem either. Fitting dynamic data such as JSON or some other interchange format into a compiled definition in a typesafe way is just very hard. Writing validating mapping code really is the most robust thing to do.
So you end up with a fragile solution of large complexity. Or you can just write the mapping code yourself if you really really need it.
> Rubbish. You can crash if the string doesn't deserialise exactly as expected;
I'm going to use your own quote here: this "is not a viable solution for any reasonable sized application". Dart is made for large projects where type safety guarantees imply your project has a certain degree of correctness. If you want to undermine that by introducing crashes on bad mappings, then you have to do it yourself.
> Manual mapping is not a viable solution for any reasonable sized application.
There are plenty of "viable" projects out there with manual mapping of reasonable size. It's understandable that you don't feel particularly excited about writing that code. But don't blame that on the Dart developers. No other class based+statically typed+compile-to-JS language has the feature you desire, and I'm trying to tell you why.