6 ms·
>Who is the audience for Dart? AS3, C#, Java, and JavaScript developers. That's why they went with C-like syntax. It's familiar to most people. >But web devel
by ahoge 13y ago
>Who is the audience for Dart?
AS3, C#, Java, and JavaScript developers. That's why they went with C-like syntax. It's familiar to most people.
>But web developers, who are the primary producers of JavaScript, will happily stick with Node.js, CoffeeScript, or plain JavaScript.
I'm writing JavaScript for a few years now. I'm really tired of it. It scales very poorly and there is zero tooling. For example, JSLint is mostly about formatting and conventions, because it got very little information to work with.
Also, if you want to take care of dependencies in JavaScript, you'll need boilerplate code (several flavors exist). If you want to document your code, you'll need lengthy doc comments (several flavors exist).
Finally, with JavaScript you're always discouraged to write extensive libraries, because everything you don't use is dead weight.
With Dart, you don't have any of those problems. It scales, there is proper tooling, you can use `import` and put stuff into packages, basic documentation is already done by adding some type annotations, and unused code is also removed.
Additionally, it's a lot easier to learn than JavaScript, because the language is less quirky.
>Dart does not seem to improve on JavaScript in a compelling way. It adds optional static typing, and as far as I can tell, nothing else.
Classes/inheritance, mixins, implicit getters/setters, implicit interfaces, import, lambda expressions, proper lexical scoping, a lexically scoped `this`, operator overloading, actor-like concurrency (isolates), SIMD, faster startup, better performance, const/final, factory constructors, optional positioned/named arguments... and good tooling.
Seen that "WAT" talk? None of that.
Dart is drastically better than JavaScript.
- dietrichepp 13y agoWhen I started seriously working with JavaScript, I decided to try to conform to community standards by using JSLint. I was shocked by how terrible JSLint was. It offered corrections for very straightforward constructs such as: var count = 0; for (var i = 0; i < arr.length; i++) { if (some_func(i)) { count++; } } I have no idea why JSLint would tell me that I should move the definition of "i" to the top of the function (am I supposed to pretend I'm writing ANSI C for obsolete compilers?) and its insistence that "++" is evil in both uses above is equally ridiculous. I love static analysis, I like tools that automatically format source code (indent, go fmt, emacs), but JSLint is just annoying.
- v413 13y agoYou can use JSHint to fine-tune your linting rules.
- cpeterso 13y agoJSLint recommends declaring vars at the top of the function because vars have function-scope regardless of where they appear in the function ("variable hoisting").
- happy_dino 13y agoYour issue is not knowing JavaScript. No point to blame a JavaScript linter.
- PommeDeTerre 13y agoThe real issue is that, as a programming language, JavaScript is poorly designed and quite broken. Its implementors and community have been quite unwilling to fix these issues, even after a decade and a half. As a result of this, it is still riddled with oddities in even extremely simple constructs. Even when one understands the reasoning behind why a tool like JSLint suggests what it does, this doesn't change the fact that dietrichepp's observations are correct. JavaScript's scoping and variable hoisting are unnecessarily broken, leading to convoluted coding practices that wouldn't really be necessary if JavaScript itself wasn't so broken.
- ahoge 13y ago>[JavaScript's] implementors and community have been quite unwilling to fix these issues [...] You can't really fix things. It would break the web. You can only add stuff on top. >JavaScript's scoping and variable hoisting are unnecessarily broken [...] It will get a bit better with ES6's `let` keyword. Annoyingly, that keyword was introduced with Firefox 2.0 (October 24, 2006) but you still can't use it. Even Node.js needs a switch.
- jaredmcateer 13y agoThe ++ thing is due to the fact that JavaScript uses + for concatenation and I've run into real life issues with this, in that if someone writes something like var foo = "The id number is: " + ++this.id + "."; a Minifier may make that like var foo="The id number is: "+++this.id+"."; which is a syntax error. Now of course you should be using a minifier that wouldn't be so stupid but it happened in our staging environment because some former employee used a very basic, yet aggressive minifier in the build process from Staging to Live. JSLint gives you an option to turn it off though, plusplus:false. Same with the variable hoisting warning others have explained.
- runT1ME 13y ago>Seen that "WAT" talk? None of that. You realize Dart literally has broken generics? That the team thought covariant mutable collections was a good thing?
- lucian1900 13y agoPerhaps there is a lack of appreciation of generics at Google in general. Go entirely lacks them, as another data point.
- happy_dino 13y agoYes, but I think it's a more wide-spread issue. Comparing languages of the European school with languages of the Anglo-Saxon school, it seems like the wide-spread anti-intellectualism in the US has a large impact on language design quality. I remember that Dijkstra had some pretty good article about it.
- ahoge 13y agoI literally meant none of JavaScript's flaws from the "WAT" talk. Anyhow, JavaScript doesn't have any kind of generics or types. Do you really prefer that?