4 ms·
You just need to look one or two pages in to see why DART, and therefore Flutter is a waste of time. Here is how we make an HTTP request in react-native: fe
by jbob2000 9y ago
You just need to look one or two pages in to see why DART, and therefore Flutter is a waste of time.
Here is how we make an HTTP request in react-native:
fetch('https://facebook.github.io/react-native/movies.json');
And here is how we do it in Flutter:
import 'dart:io';
var url = 'https://httpbin.org/ip';
var httpClient = new HttpClient();
await httpClient.getUrl(Uri.parse(url));
Why does the HTTP package need to be imported? Every single mobile app worth its salt makes HTTP requests, I shouldn't have to think about importing it, this is just more yak-shaving. And parsing a url to an URI? Fuck off fake-Java, just let me tell you the damn location of my resource, I don't care about the leaky abstraction of URIs.
Sure, I could write a wrapper and create myself a helper method. So could 100,000 other developers. Why not just include first-class functionality out of the box? The further I go into Dart, the more I realize it's just a slimmer java. I don't want slimmer java, I want better javascript. (And don't go asking your most experienced, most technical developers what "Better" means. Go and ask the thousands of shitty developers who barely have a handle on it, my coworkers still have trouble with "this" for godsakes).
- deleted 9y ago[deleted]
- saagarjha 9y agoNot every mobile app needs to perform HTTP requests; many games don't, for example. JavaScript is a language for web development, so it makes sense that HTTP requests come "for free"; Dart is a general purpose language and so importing this for programs that don't need isn't a great idea.
- jbob2000 9y agoYour counter argument doesn't make sense in the context of Flutter; it's not a tool you would use for mobile game development. The world is an interconnected place these days. I am tempted to say that there are fewer apps that don't need HTTP than apps that do. Find me a top 10 app that doesn't make HTTP requests. Interconnectivity is where it's at right now, it's the internet.
- whalabi 9y agoSo type import whatever. It's really, really not that hard.
- Hixie 9y agoThe problem with your argument is that "every single mobile app worth its salt" will want to handle slow networks by showing pretty progress indicators, and just calling a single method won't do that. Having said that, we definitely need to make Flutter's network story better. This isn't one of our near-term priorities, but medium term I plan to implement a library that abstracts away issues like unreliable networks, offline, etc, and has a very simple API.
- jbob2000 9y ago> showing pretty progress indicators, and just calling a single method won't do that. No of course not, but let's not go down that road because Dart loses that battle too. With fetch, I just attach the .finally() callback and set my loading flag to false. It's one extra line. Showing an error state is also one extra line using .catch(). > we definitely need to make Flutter's network story better You can try, but it'll just end up looking like fetch, it doesn't get any simpler than that. The fetch spec has been discussed on end, you're just going to have the same conversations they did. And lo, when you have undergone all the work of making Flutter a first class package, you will step back and say "huh, our view layer looks just like HTML and CSS, and our logic looks just like JavaScript... we recreated Web!"
- Hixie 9y agoWell hopefully I won't make the same mistakes this time. :-)
- munificent 9y agoIn case you don't know, Hixie used to be the editor of the HTML specification, so I'm pretty sure he's familiar with what that HTML and CSS are like and isn't likely to inadvertently recreate the web.
- gsnedders 9y agoIf I'm not mistaken, a large proportion of the Flutter team is made up of people who were part of the early Chrome team, many of them having worked on the web for 15+ years.
- whalabi 9y agoThat flutter code could have been done in 2 perfectly good lines, if you weren't being deliberately misleading, and one is an import that isn't exactly going to cost you cognitive load. Your JS code isn't better at all. They're just as easy as eachother.
- imtringued 9y agoYou're forgetting the polyfill for fetch. Not every browser ships with it out of the box. https://caniuse.com/#feat=fetch https://caniuse.com/#feat=fetch (87.35% of global browser have fetch) import 'whatwg-fetch'; vs import 'dart:io'; Doesn't seem very significant to me.