Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Google Dart
#1
In case you haven't heard, Google is creating a programming language called Dart which aims to be a better client-side web language than Javascript. The key difference between Dart and Javascript is that Dart features a type system with classes and interfaces and optional type checking. You can declare variables with "var" like in Javascript or you can use the name of the type like in C or Java. Type declarations are only used by the type checker; they do not affect runtime behavior and the type checker does not normally run at runtime.

You can currently run standalone programs in a VM or compile web page Dart code to Javascript. I'm sure Google has plans to add native Dart support to Chrome.

Dart is completely open-source.

Has anyone tried it or have any thoughts? Personally, I'm thrilled that a language with type checking (even optional type checking) and OOP like I'm used to instead of Javascript's weird prototype stuff is coming to the web. Unfortunately, the ginormous amount of existing Javascript code and the lack of interop between the languages is going to be a huge barrier to adoption. Native browser support will probably be necessary for serious use because Dart's "Hello World" program compiles to 17,259 lines of Javascript! It's also somewhat of a pain to get started with because there are no Windows binaries for the compiler to Javascript; you have to compile from source yourself.
Reply
#2
With tree-shaking, you will get rid of a lot of that overhead. Sure, as of right now, the compiler doesn't tree-shake, but it should be implemented in future versions.

I'm partly negative to this - not because it isn't a good idea, but because there are over 111 other attempts at doing the same thing out there - making a "better" javascript.
Reply
#3
But how many of those over 111 offer type checking? A mere 6 including Dart (only 4 of which are open-source) are listed under the "Static typing" header, with a note that some others in the last offer it too. Dart seems to be (?) the only one with type checking with aspirations for native browser support.

I just want something better than Javascript to gain widespread support.
Reply
#4
Spaz Wrote:But how many of those over 111 offer type checking? A mere 6 including Dart (only 4 of which are open-source) are listed under the "Static typing" header, with a note that some others in the last offer it too. Dart seems to be (?) the only one with type checking with aspirations for native browser support.
I don't think type checking suddenly makes everything much better. I mean, what's true of every bug out in the field? It has passed the type checker, and it has passed all the tests. It's much more critical that you're able to reason around the language. That should be first priority.

Spaz Wrote:I just want something better than Javascript to gain widespread support.
CoffeeScript is big. Clojure is extremely large for being a 5 year old language, so ClojureScript may have some potential. I haven't really done JS/client-side web programming, so I can't really say whether those are better or worse than good old JS. However, they have quite high popularity among web programmers who use cutting edge technology, so I assume they have some sort of value.
Reply
#5
Devil's Sunrise Wrote:I don't think type checking suddenly makes everything much better.
Not only does it prevent a large class of bugs, it makes it much easier for both humans and computers to reason about the code. Static typing means you can have an IDE with real autocompletion, which is a big productivity boost. Static typing makes code much more self-documenting.
Reply
#6
Spaz Wrote:Not only does it prevent a large class of bugs, it makes it much easier for both humans and computers to reason about the code. Static typing means you can have an IDE with real autocompletion, which is a big productivity boost. Static typing makes code much more self-documenting.

Static typing helps with autocompletion, but programming is rarely just writing - most times understanding what code does, or trying to express some sort of idea in the programming language is far more critical. If you have to think in types from the beginning, it may (or may not, probably depending on who you are) hinder you from finding the solution fast. It does prevent some bugs from happening at runtime, there's no doubt about that. But saying it helps reason about code is kind of like saying that guard rails helps you drive better: If you've made a function which multiplies two matrices, you don't write in the documentation that it "Takes in two two-dimensional arrays of type int and returns a new two-dimensional array of type int which is the product of the two arrays if they were to represent two matrices.", you rather write that it "Takes in two matrices and returns the product of them.".

(And excuse me for totally derailing the thread.)
Reply
#7
There are binaries for the Dart editor available now. It checks for errors on saving a file (as opposed to as you type), has completion after typing a "." (but not before unless you press ctrl+space), F3 to jump to the declaration of something, and has a button for compiling to javascript and viewing the page in a browser.

Something that tripped me up is that the Hello World in the new project template does not work in Firefox or IE because it uses the innerText property, which I now know is non-standard.

Code:
#import('dart:dom');

class HelloWorld {

  HelloWorld() {
  }

  void run() {
    write("Hello World!");
  }

  void write(String message) {
    // the DOM library defines a global "window" variable
    HTMLDocument doc = window.document;
    HTMLParagraphElement p = doc.createElement('p');
    p.innerText = message;
    doc.body.appendChild(p);
  }
}

void main() {
  new HelloWorld().run();
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)