7 ms·
I was always wondering why HN crowd is ok with TS and so prejudiced against Dart - Dart has NG2, await async in older browsers and good tooling (webstorm, vscod
by tkubacki 10y ago
I was always wondering why HN crowd is ok with TS and so prejudiced against Dart - Dart has NG2, await async in older browsers and good tooling (webstorm, vscode) and much saner package system. When doing lot of small web apps - it's easier to mantain.
- gsnedders 10y agoAt least in my view, there's a couple of big things: Dart doesn't introduce that many advantages over JS for all of its differences, and TS introduces many of them with a smaller diff; there's also the presentation of it—Dart was originally presented as a wholesale replacement of Dart, to ship in all browsers, the language more or less as a fait accompli, which rubs plenty of people the wrong way.
- markdog12 10y ago> Dart doesn't introduce that many advantages over JS for all of its differences As someone with experience in both languages, I could not disagree more. > Dart was originally presented as a wholesale replacement of Dart I think you meant replacement of JS here. I guess it depends entirely on what you think of JS as a language. I, for one, would rather a language that fixes core issues with JS, instead of just being a superset of JS.
- gsnedders 10y ago> I think you meant replacement of JS here. I guess it depends entirely on what you think of JS as a language. I, for one, would rather a language that fixes core issues with JS, instead of just being a superset of JS. If I were aiming to replace JS, I'd fix what Dart does, but I wouldn't stop with merely fixing what Dart does. Dart, despite being an entirely new language, has a less expressive type system than TS. It's transpiler (and it's VM) also does no optimisation based on the type system, instead heavily relying on the JIT to infer what the types already imply (e.g., it would be nice to do things like LICM at compile-time).
- markdog12 10y ago> has a less expressive type system than TS Care to elaborate on that? As for the rest of your comment, I'm with ya. I guess they're reasoning behind that was they thought a lot of development would start out untyped with additional types added as development progressed. I think that assumption didn't pan out, at least that's not how I do it. Official answer from https://www.dartlang.org/faq https://www.dartlang.org/faq: "Q. But don’t you need sound typing information to get high performance? Sound types can help with performance but aren’t essential. What we need are uniform, simple semantics. Modern VMs can use actual runtime behavior as a valuable signal for optimizations."
- logicchains 10y ago>Care to elaborate on that? I'm not the OP, but TypeScript supports union types (A | B ; a type that can be either type A or type B) and intersection types (A & B ; a type that is both A and B), while Dart doesn't. https://www.typescriptlang.org/docs/handbook/advanced-types.html https://www.typescriptlang.org/docs/handbook/advanced-types.... Typescript also has structural types, like Go and OCaml, which many people find nicer than nominal types. Structural types mean if I have an interface Blaz with two methods Foo and Bar, if I have an object MyObject with Foo and Bar methods of the same types then my object counts as a Blaz, while nominal types mean I have to write something like MyObject extends Blaz.
- skybrian 10y agoThat's how dart2js works today but the goal for Dart 2.0 is to move to a sound type system. The beginning of this is available today as "strong mode" and the Dart Dev Compiler.
- coldtea 10y ago>As someone with experience in both languages, I could not disagree more. Elaborate then. Because one's major advantages can be another's (and sometimes, objective) trivialities...
- markdog12 10y agohttps://www.dartlang.org/guides/language/language-tour https://www.dartlang.org/guides/language/language-tour
- pekk 10y agoWhat do you mean "fait accompli"? Was the Dart team supposed to give the community a chance to abort the language from existing, and the community was upset that it was completed and published without the input of people who wanted it not to be?
- coldtea 10y ago>Was the Dart team supposed to give the community a chance to abort the language from existing No, he means that the Dart team was supposed to solicitate opinions on how to build Dart and what the best objectives for it would be, but instead they showcased it in "almost done" form, and only then tried to attract a community.
- gsnedders 10y agoThis. While yes, it was a long way from "standardised" and a lot changed between what Google initially published and the Ecma standard, many fundamental design decisions were made internally and there was never any real influence externally over that. Those are fundamental design decisions where to change them you essentially need to start from scratch. The other big problem was that it was done with the VM being a major part of the project with the intent of getting it into Chrome, obviously without having talked that much with several of the people who have significant influence over such things in (then) WebKit, even those within Google. That the VM was going to be outright objected was entirely predictable.
- deleted 10y ago[deleted]
- monyr75 10y agoYour view seems to be from someone who hasn't used Dart extensively, because no one who had would minimize its advantages this way. Being different from JS is the whole point. Dart introduces all the advantages of TS and more, while leaving the baggage and bullshit of JS behind.
- kolar 10y agoIt puzzles me also. Dart is solid language with great libraries, good tooling and still it is ignored by most developers. The truth is people from JS world seems to like 'cool' languages, but the one who want to be productive just uses boring Java/Dart etc.
- markdog12 10y agoHappy Dart programmer here. Great, easy to learn, productive language that runs on browser, server, mobile. I have no idea why Dart isn't used more.
- kelvin0 10y agoI want to give Dart a chance, because most of it's features seem quite appealing. I decided to start learning JS/Jquery and then move onto to Dart. The fact that everything comes bundled into Dart as a whole dev environment (IDE, compiling,packaging,) and the interoperability with JS make it quite attractive. What is your experience doing web dev with and without Dart (JS vs Dart, pros and cons)? I'd be really interested in your feedback!
- markdog12 10y agoI started off with C/C++, Java, then AS3 writing Flash games. Then js/jquery and I instantly hated it (js). There were just too many quirks, bizarre, unexpected behavior. Sure, I could learn it inside out and avoid these pitfalls, but why would I when there were better alternatives? I did use CoffeeScript after that, a beautiful little language, but only suitable for smallish projects. I need static typing for large projects. After that, I learned Dart, and coming from C/C++, Java, AS3, it was a breeze. I find there are no quirks, everything behaves as you'd expect. Other team members were productive in Dart in about a week, without having seen a line of Dart code. I mostly write HTML5 games and server-side with Dart, so I can't really talk too much about any client-side frameworks. As for Dart cons, I guess one would be you have to use a different browser for web dev, but it's not really a big deal, I'm kinda reaching here. There aren't as many 3rd party libraries as some other languages. Depending on what you want, you might have to get your hands dirty and issue some pull requests for features/bug fixes for those libs. JS interop can still be a bit tricky too, depending on what you're doing. Any specific questions, I'd be happy to answer. Also, there's a great slack channel for Dart: https://dartlang-slack.herokuapp.com/ https://dartlang-slack.herokuapp.com/
- lmm 10y agoTS seemed more willing to interoperate with the rest of the JS ecosystem - gradual typing, external .d.ts files for popular libraries, working with existing build tools and module systems. Whereas Dart felt like more of a gated community where you were expected to do things the Dart way and there wasn't much support for traditional JS.
- markdog12 10y agoDart has gradual typing > working with existing build tools and module systems I'd say they replaced it with a better tool, pub. The one good argument you have there is .d.ts files. Dart lacks them, but there are tools to generate js bindings from those same .d.ts files. https://github.com/jirkadanek/definitely_typed https://github.com/jirkadanek/definitely_typed I haven't used it though, so I can't say if it works as advertised.
- lmm 10y ago> I'd say they replaced it with a better tool, pub. Right but that route ends in forcing people to leap to a whole different ecosystem before they can even try your thing. Whereas with typescript you could put a single .ts file in your existing project without messing with anything else.
- markdog12 10y agoYes, I agree with your point that typescript is easier to hop into if you have an existing js project.
- monyr75 10y agoI consider the small hop to TS its greatest disadvantage, personally. JS's ecosystem is a horribly broken mess, and any sane person would welcome a leap to another, better designed one. Dart has JS-interoperability for those times when you just can't get away, but TS is like an anchor holding you down in the mire of the JS world.
- svieira 10y ago
- Touche 10y agoI can't find in the documentation, does the `pub build` tool do code splitting? I can't use a language without this.
- markdog12 10y agoSorry for my ignorance, but does that amount to loading a library on demand? If so, yes, Dart can do this: import 'package:deferred/hello.dart' deferred as hello; // When you need the library, invoke loadLibrary() using the library’s identifier. greet() async { await hello.loadLibrary(); hello.printGreeting(); }
- Touche 10y agoThat does indeed work. I just tried it, and it works beautifully. The only problem is that the main output js file is still 107kb, quite large.
- markdog12 10y agoWhen I test this out, I get a 94KB file. That's reasonable depending on what you're doing.
- wstrange 10y agoAlso worth pointing out that Dart can do tree shaking at compile time, to eliminate library code that is never called
- svieira 10y agoDart is not structurally typed and so only provides help typing the parts of your program you have actually modified to use Dart. TS and Flow both provide structural typing that makes it far easier to convert existing code. Just annotate it (no need to even modify the existing code, just plop a `.d.ts` or `.flow` file in the right place) and immediately start to see benefits.
- whatever_dude 10y agoTS is more of an evolution of what exists. In that sense it's a possible "future" implementation of JavaScript -- still keeping the same semantics, but in a more structured way. Dart is a different language so it's a different path. It's no different than, say, using C# or Java or C or whatever language that can be transpiled to JavaScript.
- computerex 10y agoDart is a special cookie. You can't use dart with all of Javascript's ecosystem.
- tkubacki 10y agoJS interop backed by Dart Team works pretty well for me: https://pub.dartlang.org/packages/js https://pub.dartlang.org/packages/js
- labrador 10y agoI've been a long time fan of Dart but I've recently (this week) given up on it for my purposes, which are write browser SPA's that need to run in different browsers. My sense is that after the Chrome team decided not to include the Dart VM in Chrome, Dart started looking for a new story. That story is Flutter, which is Dart running in the Dart VM on mobile devices [1] It is not Dart converted to JavaScript so it can run in any browser, despite the awesome work of the dart2js authors and the relatively new dev_compiler project [2]. The latter will be awesome when done, because the goal is to convert Dart to ES6/ES2015. However, it is my impression that Google really doesn't care that much about transpiling Dart to JavaScript. I was willing to put up with the huge file size dart2js produced, because Dart made my life easier and something better was coming. However, it's been a long time and the pace of Dart transpiling work is too slow. I converted my Dart app to TypeScript (size dropped from 650kb to 60 kb) and am happy for that, but sad that Google does not put more people on the dev_compiler team to keep long term enthusiasts like me on board. I'm sure Flutter is fantastic and will take a look when I have a need for that kind of solution. I can't really blame Google, because the JavaScript community turned it's back on Dart, but I wish they would just state the new goals and not leave us hanging. [1] https://flutter.io/faq/ https://flutter.io/faq/ [2] https://github.com/dart-lang/dev_compiler https://github.com/dart-lang/dev_compiler