Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I find the interpreter/compiler of Dart language?

Tags:

windows

dart

How can I run a Dart application? Do I need a VM as in Java?

I tried to embed the following code on a html page:

<html>
  <body>
    <script type="application/dart">
      main() {
        Element element = document.getElementById('message');
        element.innerHTML = 'Hello from Dart';
      }     
    </script>
    <div id="message"></div>
  </body>
</html> 

This doesn't work - it returns the pure HTML on the page. What am I doing wrong?
My Google Chrome version: Chrome/14.0.835.202 and my platform is Windows.

like image 467
The Mask Avatar asked Oct 11 '11 21:10

The Mask


People also ask

Does DART use compiler or interpreter?

Dart compiles into JavaScript, and JavaScript is an interpreted language. Usually, by 'compiled' languages one understands languages which are compiled into platform-specific machine code, run right on the CPU and don't require an interpreter to run, which is not the case for neither JS nor Dart.

What compiler does Darts use?

Native platform: For apps targeting mobile and desktop devices, Dart includes both a Dart VM with just-in-time (JIT) compilation and an ahead-of-time (AOT) compiler for producing machine code.

Is Dart a compiled language?

The application developer can type any code and JavaScript allows it, so JavaScript is not a type-safe language. Programming errors can only be found at the runtime. Dart supports both loose and strong prototyping. As Dart is a compiled language, most of the programming errors can be found during the compilation.

Where is Dart language used?

Dart is a programming language designed for client development, such as for the web and mobile apps. It is developed by Google and can also be used to build server and desktop applications. It is an object-oriented, class-based, garbage-collected language with C-style syntax.


3 Answers

You can download Dart binaries for Windows (dart_bin.exe) and Linux from Installing Dart.

You can write a small Hello World, hello.dart:

main() {
    print('Hello World');
}

Then you execute the Dart-script with:

C:\Users\Jonas\dart>dart_bin hello.dart
Hello World
like image 73
Jonas Avatar answered Oct 16 '22 05:10

Jonas


Dart's only in an early developer preview stage right now. In some cases, the implementation, specification and documentation contradict each other!

Google is probably going to add Dart support to Chrome in the future, but this is a long-term objective, and hasn't been implemented yet.

You need to download and compile the Dart interpreter/compiler yourself. Dart's Google Code project's wiki has an entry about this, Building Dart, but like the rest of the documentation it's somewhat sparse at the moment.

like image 20
Jeremy Avatar answered Oct 16 '22 03:10

Jeremy


Currently there are a few options available:

  • Run sample code in the Dartboard window at dartlang.org
  • Build dartc compiler and run provided htmlconverter.py script which will translate an HTML page with yours application/dart blocks into an HTML page with JavaScript code
  • Build the standalone VM and run Dart code in it
  • Wait until Google Chrome will support Dart natively

Update #1

  • It was announced that Dart (only small subset in fact) now runs on JVM 7 (using Dart to JVM bytecode compiler).

Update #2

  • Instead of building dartc compiler from the sources you can download Dart Editor, an editor based on Eclipse components which supports Dart-to-JavaScript compilation.
  • Frog is a new Dart compiler written in Dart; while it was only started recently and still contains some bugs, it generates much more optimized JS code and runs significantly faster than dartc.

Update #3

  • Now there is available Chromium with native Dart VM - Dartium, but only in dev mode.
like image 5
Idolon Avatar answered Oct 16 '22 03:10

Idolon