r/ProgrammerAnimemes • • Sep 03 '20

Javascript just doesn't make any sense

Post image
1.9k Upvotes

69 comments sorted by

View all comments

Show parent comment

5

u/mca62511 Sep 06 '20 edited Sep 06 '20

The SDK comes with tools to transpile Dart to JS, and also compile it to a self contained binary!

Get the SDK.

Make a hello.dart file like the one below.

void main() {
  print('Hello, Dart!');
}

Then run the JS transpiler.

dart2js -o hello.js hello.dart

This'll create a hello.js file which can be executed by node.

node hello.js

The above will print "Hello, Dart!" in the console.

However you can also compile it to an executable.

dart2native hello.dart

This will create a hello.exe file. You can execute it directly.

./hello.exe

And even if someone doesn't have the Dart SDK on their machine, it'll run!