6 ms·
> Present your complaints as though Dart is missing basic functionality In many peoples opinions, it is. Your opinion is no more fact than mine. > Assume your
by d2p 12y ago
> Present your complaints as though Dart is missing basic functionality
In many peoples opinions, it is. Your opinion is no more fact than mine.
> Assume your use case is representative for a significant amount of other developers
I can assume what I want. I believe it's true. It might not be; but it seems like a pretty basic requirement; and there are many other people in that thread that share the opinion.
> Extend your entitlement to the HN front page.
I didn't put it there, the people did.
> you are very free to make a Dart library that does exactly that
That's the whole point - there is no sensible way to implement this from the outside; that's the whole point of my thread. All of the ways of achieving this suck for one reason or another. Doing this well needs better support from the language/Dart tools.
> the problem you are complaining about simply isn't as big as you think it is
I've still yet to see anyone anywhere post a small code sample showing a Dart class and some simply JSON that works, without a hand-coded mapping from a Map. Is this really what we should be spending our time doing using Google's "new language for the web"?
- DCKing 12y ago> Your opinion is no more fact than mine. You've got that right. My problem is that you framed your thread title and general discussion so that it implies that Dart is lacking in JSON support. It's not; Dart's JSON support is better than or on par with almost all other languages out there (including JavaScript). The problem for you is that it lacks a certain style of JSON support, which I think you'll find a hard time arguing why it's basic functionality. > I didn't put it there, the people did. Come on. You submitted it, and did not want it on the front page? > That's the whole point - there is no sensible way to implement this from the outside; that's the whole point of my thread. All of the ways of achieving this suck for one reason or another. Doing this well needs better support from the language/Dart tools. Yes there is. Dart's reflection APIs are more than adequate for you to implememt such a thing. Reflection is the way to go in these statically typed languages; it's how Java libraries do it, and it's how C# does it. It's the only way to dynamically construct classes. > I've still yet to see anyone anywhere post a small code sample showing a Dart class and some simply JSON that works, without a hand-coded mapping from a Map. Is this really what we should be spending our time doing using Google's "new language for the web"? If you choose to spend your time on that, that's your choice. Why do you find it necessary? Do you really want to use a web service as an ORM? Web applications come with no obligation to have a direct JSON <-> typesafe class mapping. Such mappings are ill-defined and bug prone if done automatically or with runtime reflection, and open to different styles of implementation. I don't think it's the job of the core library to solve that problem for you, not if it already allows you to work with JSON in other ways. Many people are fine to just use the Maps without the unjustified pretense of type safety, and other people are fine with manual mapping and validation. Considering the problems of reflective mapping and the availability of plenty of other solutions, I think you are being overzealous in your complaining.
- d2p 12y ago> Come on. You submitted it, and did not want it on the front page? I never said I didn't want it there; I said I didn't put it there. You can't tell me I have no right to put something on the homepage when it ended up there because of HN's algorithm (which suggests that others did want it there). > Yes there is. Dart's reflection APIs are more than adequate for you to implememt such a thing I was told by someone on the Dart Team: "using mirrors just isn't practical for real applications". If that's not actually true, great! However I suspect if it wasn't, then there would be a Dart-Team owned mirror-based implementation? > Do you really want to use a web service as an ORM? My data store is on a server; not in your browser. I need to get data (or some form) from the client back to the server, and vice versa. This is nothing to do with using a web service as an ORM, this is how web apps work - code runs in your browser, and needs to communicate with a server where I can retrieve or persist things. How do you think Gmail marks an email as Read when you open it? Fetches your email? etc. > Web applications come with no obligation to have a direct JSON <-> typesafe class mapping. Such mappings are ill-defined and bug prone if done automatically or with runtime reflection This is nonsense. Pulling data from a server into a Map is bug-prone, because if you use it as a map, all of your code can be wrong. If it's converted to a type, then only the mapping can be wrong, and the rest of the code can have static analysis. This is one of the selling points of Dart, and it's totally stupid to throw it away. People are "ok" without the type safety because they have no other option. This is supposed to be one of the advantages of Dart over JS!
- DCKing 12y ago> I never said I didn't want it there; I said I didn't put it there. You can't tell me I have no right to put something on the homepage when it ended up there because of HN's algorithm (which suggests that others did want it there). Don't confuse the argument. If you wanted it on the front page then you wanted to drag your entitlement beyond the original discussion onto the HN front page. You have many rights to do all sorts of things, but exercising it in this case just makes you seem entitled to me. > This is nothing to do with using a web service as an ORM, this is how web apps work - code runs in your browser, and needs to communicate with a server where I can retrieve or persist things. How do you think Gmail marks an email as Read when you open it? Fetches your email? etc. Don't strawman my argument. You need data client side, why is it necessary that they need to take the specific form of your own custom Dart classes mapping exactly to the shape of your JSON? > This is nonsense. Pulling data from a server into a Map is bug-prone, because if you use it as a map, all of your code can be wrong. If it's converted to a type, then only the mapping can be wrong, and the rest of the code can have static analysis. Maps have no pretense of type safety. Manual mappings have actual type safety. Reflection based automated mappings only have the pretense of type safety with a whole lot of problems. I'm not saying reflection based mappings don't have merits. They do. But in a context where mapping-to-classes is not shown to be a necessity ("99% of all webapps" don't do that) and where there are plenty of alternatives, you are blowing up the problem. > This is one of the selling points of Dart, and it's totally stupid to throw it away. Except for the fact you're not really arguing for real type safety, I do agree. It is a missed opportunity in the Dart ecosystem. Does that really equate to Dart missing basic functionality? I think it just shows that it would be nice if there was a library for that. In the meantime, there are plenty of other things you can use.