5 ms·
Because writing/improving yet another JavaScript client side library fails to address the fundamental flaws with JavaScript which are well laid out. ECMAScript
by WoodenChair 13y ago
Because writing/improving yet another JavaScript client side library fails to address the fundamental flaws with JavaScript which are well laid out. ECMAScript 6 will likely correct some of these flaws, but the necessity for backward compatibility continues to be a stumbling block. Dart is a clean break and fresh slate while retaining a familiar syntax and interoperability/compatibility.
Is it a long shot that it will unseat Javascript? Sure. But, competition is good for JavaScript. Google's number one interest is in improvement across the entire client side web app infrastructure since its business is built upon it. It can push Dart while improving JavaScript in parallel.
- nailer 13y agoI definitely agree that JS itself could be improved, but while Dart improves some things, it makes others a lot worse. Look at the Fibonacci program on dartlang.org, and compare it to any language that's popular with web developers: Python, ruby, Coffeescript or even scala. Multiply that unnecessary overhead for every function in your app.
- WoodenChair 13y agoYou mean the graphical one where they use storage, forms, and events? Let's not be misleading... Hello World in Dart is: main() { print("Hello World!"); }
- nailer 13y ago> main() { print("Hello World!"); } Yes, that's my point. Why not just print("Hello World!"), like everything else?
- munificent 13y agoThe top level of a Dart program is a group of definitions, like in Java or C#, instead of a series of imperative statements. That makes it easier for static analysis, since you don't have strange constructs like: if (itsTuesday) { class Foo { ... } } It also means mutual recursion just works, without weird semantic shenanigans like hoisting in JavaScript. In Dart, the top-level is "simultaneous": all of those definitions are static with no mixing of side-effecting imperative code at the top-level which would make ordering matter. The main side-effect of this approach is that you have to wrap your entrypoint imperative code in a main() function. It's a pretty small price to pay, especially in an application with thousands of lines of code.
- nailer 13y agoPersonally I don't mind hoisting but for the moment, OK. So obvious question: why doesn't the language create this entry point for me?
- spankalee 13y agoBecause once you allow statements at the top level alongside declarations, which statement should be run first? main() makes that clear. In JavaScript it depends on the order of script tags and their attributes. It's really hard to determine what code is actually run at application startup, and what the initial state is. Making the top-level only declarations means that the programmer knows what code runs first (the first line in main()) and the VM knows that the order of evaluating the declarations doesn't matter. It can evaluate them all and cache the result so that subsequent runs are fast, it can execute main() before other declarations and evaluate them on an as-needed basis, or something in between.
- nailer 13y agoConvention? I guess it does comedown to function hoisting in the end, so the expectation is the body of code after the functions are defined / function variables created. I think a lot of people prefer that convention over boilerplate code, and the tide of language development seems to be heading in that direction. OT: script tag soup is, for first party stuff anyway, avoided with a single script for a module loader these days.
- xxgreg 13y agoOne big advantage of top-level declarations is it is possible for the VM to use a snapshot for fast start up. This is not really possible if you must interpret top level code to build up your top-level declarations, as done in JS. Using snapshots, the Dart authors have said it should be possible to improve script start up time by 10x over V8. This is a big win for large script heavy apps. Edit: link https://www.dartlang.org/articles/snapshots/ https://www.dartlang.org/articles/snapshots/
- munificent 13y ago
- ahoge 13y agomain()=>print('Hello World!');
- WoodenChair 13y ago...parent changed comment from complaining about Hello World having too much boilerplate in Dart to being about something else entirely. This is why HN should not have an edit feature...
- nailer 13y agoI thought dartlang.org had a helloworld, instead it had a fibonacci. I updated to show an example people could see. Not sure why that's an issue.
- mythz 13y agoIf you're changing the message of your post, annotate it with an Edit leaving the original message in-tact, especially if it's found to be non-factual. Here you're invalidating all responses and making them sound non-sensical. Post a new message if you have something new to say.
- nailer 13y agoI'm not changing the message of the post. The only difference is the demo referred to. The point about Dart being too verbose made remains the same in both 'hello world' and 'fibonacci' cases as you can see, it was simply a matter of being in a cafe using a mobile phone where switching out to another tab, opening the golang site and finding a demo to check that they had the 'hello world' example most sites provide was difficult. The person attacking me for 'changing' my post has been on News.YC (ahem 'Hacker News') for 70 days, called criticism of the boilerplate code shown in the Dart demos 'FUD', and wrote three separate replies to the same point. Judge for yourself.
- WoodenChair 13y agoRight because length of existence of a username is really a good argument of anything... All of your posts attacking Dart are for nonsensical reasons, and then your replies are backsteps admitting part of what you originally said was wrong and then coming up with a new nonsensical argument. I don't know what you have against Dart, but your basic premise that it's verbose is absolutely wrong. They've actually taken pains in the syntax to not be verbose (factory constructors, => functions, getters and setters, .. syntax for cascades, etc). It just shows you judge the language based on glancing at the front page of the website for 2 seconds without doing significant reading. In other words your posts are FUD. I stand by that.
- WoodenChair 13y agoIn reply to your new comment about fibonacci. If you look at the actual function doing fibonacci, it's the same length as the equivalent fibonacci function in Java or Javascript... please stop spreading FUD.
- nailer 13y agoThe boilerplate is the issue, saying to ignore it is illogical. Unless it's not actually necessary in dart (mraleph says something in another comment) in which case it shouldn't be in the docs. I have no interest in or against Dart other than wanting to see a compelling modern alternative to JS. Not sure why you think criticising Dart and it's website is 'spreading FUD'.
- mraleph 13y agoFibonacci function in Dart can be as easy as: fib(n) => n < 2 ? n : (fib(n - 1) + fib(n - 2)); Examples on the main page just exists to show cases as much language features as possible. It does not say that you have to wrap your Fibonacci into a class.
- deleted 13y ago[deleted]
- nailer 13y agoMaybe it's a matter of bad docs giving the wrong impression then? Examples should be terse, the ability to create unnecessary wrappers don't seem like much of a feature to show off.
- mraleph 13y agoStrictly speaking it's not a doc. It's a snippet on the main page that tries to show case available language constructs. I do agree however that wrapping Fibonacci in a class looks a bit strange. Documentation that showcases features in the terse form is available at http://synonym.dartlang.org/ http://synonym.dartlang.org/ If you have better ideas you can file a bug or even submit a pull request for the site: https://github.com/dart-lang/dartlang.org https://github.com/dart-lang/dartlang.org
- nailer 13y agoWeb pages showing people how to do things are documentation. No inclination to contribute, Google have known that verbosity is a common reason for disliking Dart for 750+ days and haven't done much about it. I'm fine using JS and, when I want strong typing, know that Typescript is there.
- spankalee 13y agoYeah, I think the Fibonacci class example is odd too. I also would love to propose a self-imposed internet-wide ban on the recursive Fibonacci implementation as I'm pretty sure it causes brain rot and makes dynamic programming seem way more magical than it is.
- adamors 13y agoStill seems like throwing the baby out with the bathwater to me. Especially since its from Google; as it is, it looks like the second coming of ActiveX to me.
- WoodenChair 13y agoIt's a legitimate concern until you dig beneath the surface of the politics. The fact is that in the near future Chrome will not achieve IE 6 like market share and therefore Dart will primarily be used through Dart2JS. It's a legitimate fear for the future - but that's admitting then that Dart is a darn good step in the right direction and will see high adoption. At this time it's more of a straw man. Also Google has said they will submit Dart to a standards body. That was never going to happen with Active X. And of course, unlike ActiveX, Dart is open source - so if in a pinch Dart took over the world super rapidly and the other browsers had to incorporate it...
- robmcm 13y agoI think without Dart2JS this would be a non starter. I can't see Apple or Microsoft implementing a DartVM either an open source one or one of their own, remember the Flash Player was an open spec but no one wrote their own.
- dgregd 13y ago> I can't see Apple or Microsoft implementing a DartVM ... That's the whole point of Dart. Apple and Microsoft are protecting their closed platforms. They are not interested in open platforms like Web. Microsoft improved IE JS engine after they lost significant market share. And please compare features of C# and ECMAScript. Google pushed the whole web platform forward. I don't want them to wait for Microsoft acceptance!
- pjmlp 13y ago> Google pushed the whole web platform forward. Really? When do you expect other browser vendors to adopt DartVM and PNaCL? This is the second coming of IE, nothing else.