Deploying Dart console applications

983 views
Skip to first unread message

JiK

unread,
May 25, 2013, 10:58:30 AM5/25/13
to mi...@dartlang.org
Hi All,
I have developed some small console applications in Dart and I want to use them in an other computer which doesn't have Dart installed. What is the minimum installation I need to run these console applications? Or better, what are the files needed to run these applications?
Thank you.

Seth Ladd

unread,
May 25, 2013, 1:07:54 PM5/25/13
to General Dart Discussion
Hi,

I would install the Dart SDK (http://www.dartlang.org/tools/sdk/) which is just the command-line tools.

Then, for your app, use this command to create a single .dart file that contains everything you need for the app.

dart2js --output-type=dart --minify -oapp.complete.dart app.dart

This is the fabled "dart2dart" which takes a Dart app, tree shakes it, minifies it, and generates a single .dart file ready to go. This is nice because it pulls in dependencies like 3rd party libraries (and tree shakes it to eliminate the unused parts) so you don't need to run 'pub install' on the target machine.

Hope that helps,
Seth



--
For other discussions, see https://groups.google.com/a/dartlang.org/
 
For HOWTO questions, visit http://stackoverflow.com/tags/dart
 
To file a bug report or feature request, go to http://www.dartbug.com/new
 
 

Yarko Tymciurak

unread,
May 25, 2013, 2:09:53 PM5/25/13
to mi...@dartlang.org
Wow, Seth!   That's useful...

The bottom line, I think, is you need either a dartvm (i.e. dart sdk) or node.js on the target.


Regards,
- Yarko

Seth Ladd

unread,
May 25, 2013, 2:23:57 PM5/25/13
to General Dart Discussion
Hi Yarko,

You'll want the Dart VM and your tree-shaken Dart file.

Thanks,
Seth

Eric J. Smith

unread,
May 25, 2013, 8:36:40 PM5/25/13
to mi...@dartlang.org
Who else thinks that it's REALLY strange to call the dart2js compiler to get a dart file?  Why isn't it simply called something like dartc or something like that?

Yarko Tymciurak

unread,
May 25, 2013, 9:01:58 PM5/25/13
to mi...@dartlang.org
dartc is already used; historically, as I understand it,  dartc was the first version,  frog the second, and dart2js the third version.

looking at dart2js -h doesn't help (it says, first thing, "Compiles Dart to JavaScript." - heh;  dart2js -vh shows "--output-type" under "...may be removed in future versions.").   To find out what it "does", you need to head to something like http://www.dartlang.org/docs/dart-up-and-running/contents/ch04-tools-dart2js.html

Some doc is aching for a minor tweak here...


Regards,
- Yarko

Jos Hirth

unread,
May 25, 2013, 9:13:58 PM5/25/13
to mi...@dartlang.org
On Sunday, May 26, 2013 2:36:40 AM UTC+2, Eric J. Smith wrote:
Who else thinks that it's REALLY strange to call the dart2js compiler to get a dart file?  Why isn't it simply called something like dartc or something like that?

http://dartbug.com/8172 - dart2dart not in the dart-sdk/bin directory bundled in Dart Editor 

Greg Lowe

unread,
May 25, 2013, 10:40:29 PM5/25/13
to mi...@dartlang.org
Is it possible just to install the dart executable rather than the entire SDK?

As I understand it, the corelib and everything it needs is bundled inside this executable. So you should really only need to deploy this and your minified dart app.
Message has been deleted
Message has been deleted

Harald Glatt

unread,
May 25, 2013, 11:42:41 PM5/25/13
to mi...@dartlang.org
Weird my message got lost: I was saying: When you execute this line to dart2dart a console application that uses dart:io you get the error message that dart2js doesn't know dart:io.

Jos Hirth

unread,
May 26, 2013, 12:13:23 AM5/26/13
to mi...@dartlang.org
If you want to compile it to JavaScript, you can't use stuff from 'dart:io, because there isn't a counterpart for these things in the browser.

I'm not sure why you're trying to compile it to JavaScript though. Use --output-type=dart to make dart2js output minified Dart code.

Yarko Tymciurak

unread,
May 26, 2013, 12:29:20 AM5/26/13
to mi...@dartlang.org
I apologize if I spurred this - when I said you'd have to have either dart or node.js on target, it was a theoretical (not experience based) statement on my part.

Looking quickly, there appear to be many of the dart:io equivalents on node.js, but the mapping hasn't happened (and probably doesn't need to, even if it might be plausable to do).


Regards,
- Yarko

Harald Glatt

unread,
May 26, 2013, 12:43:39 AM5/26/13
to mi...@dartlang.org
Look into what I quoted, that is what I am doing and it is what Seth suggested. Running that line of code results in the dart:io error. Of course I am not trying to compile to javascript.

Vadim Tsushko

unread,
May 26, 2013, 1:31:59 AM5/26/13
to mi...@dartlang.org


суббота, 25 мая 2013 г., 23:07:54 UTC+6 пользователь Seth Ladd написал:

Then, for your app, use this command to create a single .dart file that contains everything you need for the app.

dart2js --output-type=dart --minify -oapp.complete.dart app.dart



Another way is to generate snapshot with --generate-script-snapshot option of dart executable. After that you run this snapshot with dart executable just as plain source dart file.
That definitely pull into snapshot all dependencies so you do not required to run pub install on target machine. Not sure about tree shaking though.
Supposedly you would also benifit with respect to startup time of your script.


 

Jos Hirth

unread,
May 26, 2013, 1:36:04 AM5/26/13
to mi...@dartlang.org
Use --categories=Server

Harald Glatt

unread,
May 26, 2013, 1:48:13 AM5/26/13
to mi...@dartlang.org
Thanks it works now!

George Moschovitis

unread,
May 26, 2013, 5:32:02 AM5/26/13
to mi...@dartlang.org



Who else thinks that it's REALLY strange to call the dart2js compiler to get a dart file?  Why isn't it simply called something like dartc or something like that?

+1000

-g.

Zoran Tkavc

unread,
May 26, 2013, 11:33:59 AM5/26/13
to Dart Misc
It is strange name.

+1

Zoran

On 26 maj, 11:32, George Moschovitis <george.moschovi...@gmail.com>
wrote:

Bob Nystrom

unread,
May 28, 2013, 12:23:00 PM5/28/13
to General Dart Discussion

On Sun, May 26, 2013 at 2:32 AM, George Moschovitis <george.mo...@gmail.com> wrote:
Who else thinks that it's REALLY strange to call the dart2js compiler to get a dart file?  Why isn't it simply called something like dartc or something like that?

+1000

It's a historical artifact. At the time dart2js was started, "dartc" was already in use to refer to the old Dart->JS compiler/analyzer written in Java. Now that the new analyzer is in, that project is, I think, totally dead. We could probably reuse the name dartc now if we wanted to, though I don't know if that would just cause confusion.

Cheers,

- bob

Matthew Butler

unread,
May 28, 2013, 12:38:51 PM5/28/13
to mi...@dartlang.org

It's a historical artifact. At the time dart2js was started, "dartc" was already in use to refer to the old Dart->JS compiler/analyzer written in Java. Now that the new analyzer is in, that project is, I think, totally dead. We could probably reuse the name dartc now if we wanted to, though I don't know if that would just cause confusion.

Cheers,

- bob

FWIW, I've seen the various compilers/analzyers for a while now. And who knows there may still be some more iterations/code names before 1.0. My personal suggestion would be leave as they are for the time being, and just prior to 1.0 make a breaking change to rename the various tools to a 'final' name. Personally I don't mind dart2js when it was just to javascript, but it is a little unintuitive for dart2dart (and eventual/side project java2dart?) If renaming dart2js isn't in the cards perhaps a script named dart2dart which launches dart2js in with the --output-type=dart flag already set?

Matt

Ivan Posva

unread,
May 28, 2013, 1:27:16 PM5/28/13
to General Dart Discussion
On Sat, May 25, 2013 at 7:40 PM, Greg Lowe <greg...@gmail.com> wrote:
Is it possible just to install the dart executable rather than the entire SDK?

As I understand it, the corelib and everything it needs is bundled inside this executable. So you should really only need to deploy this and your minified dart app.

This is correct, the dart binary in the SDK contains everything it needs to run. This is so one can move the binary and either the minified sources or the generated snapshot to a different machine and you should be up and running.

Please let us know if this approach does not work.

Thanks,
-Ivan
Message has been deleted

George Moschovitis

unread,
Nov 10, 2013, 1:53:13 PM11/10/13
to mi...@dartlang.org
Maybe this should be revisited, before 1.0?

-g. 

Bob Nystrom

unread,
Nov 11, 2013, 4:14:53 PM11/11/13
to General Dart Discussion

On Sun, Nov 10, 2013 at 10:53 AM, George Moschovitis <george.mo...@gmail.com> wrote:
Maybe this should be revisited, before 1.0?

There's been an ongoing discussion about shuffling some of the command names around. We could maybe do something here, but I think most people on the team are still happy with "dart2js", so I wouldn't be surprised if that name stuck.

- bob

Bienlein

unread,
Dec 6, 2013, 4:42:01 AM12/6/13
to mi...@dartlang.org

Am Sonntag, 26. Mai 2013 07:31:59 UTC+2 schrieb Vadim Tsushko:
 
Another way is to generate snapshot with --generate-script-snapshot option of dart executable. After that you run this snapshot with dart executable just as plain source dart file

Is there maybe a way to load in an alternative snapshot at runtime? Maybe a weird question. Just something that struck my mind. Then you could move in bugfixes at runtime without restarting the thing as in Erlang.

-- Bienlein

Peter Ahé

unread,
Dec 6, 2013, 4:46:13 AM12/6/13
to General Dart Discussion
We often refer to this as "hot swapping".

Dart is not capable of hot swapping at this time, but it is something
that I personally hope that we can achieve.

Cheers,
Peter
> --
> For other discussions, see https://groups.google.com/a/dartlang.org/
>
> For HOWTO questions, visit http://stackoverflow.com/tags/dart
>
> To file a bug report or feature request, go to http://www.dartbug.com/new
>
> To unsubscribe from this group and stop receiving emails from it, send an
> email to misc+uns...@dartlang.org.

Bienlein

unread,
Dec 6, 2013, 5:45:53 AM12/6/13
to mi...@dartlang.org


Am Freitag, 6. Dezember 2013 10:46:13 UTC+1 schrieb Peter von der Ahé:
We often refer to this as "hot swapping".

Dart is not capable of hot swapping at this time, but it is something
that I personally hope that we can achieve.

If it had been capable of it I would have just here and now sat down and started developing something like Erlang in Dart ;-). Is it legal to ship the Dart compiler with the runtime? Then you could invoke the compiler at runtime to load in a fix or new features this way.

Peter Ahé

unread,
Dec 6, 2013, 6:01:40 AM12/6/13
to General Dart Discussion
The Dart VM is a compiler (so is the JVM). This compiler is invoked
"just-in-time" and called a JIT compiler. A compiler like dart2js is
called "ahead-of-time" or AOT compiler.

So the VM already has the compiler. dart2js can compile it self, and
this allowed us to build try.dartlang.org.

In the context of try.dartlang.org, I have been thinking a lot about
incremental compilation and hot swapping. A big part of what lacks is
to identify what needs to be fixed up, making this the hard part of
supporting hot swapping.

For the VM to support hot swapping, my understanding is it is
currently lacking not tracking dependencies (meaning that identifying
what needs to be fixed up is the hard part here as well).

Hot swapping is an essential feature in Smalltalk, and many of the
people involved in the Dart project from the start would like to see
such features from Smalltalk be made available in Dart.

Cheers,
Peter

Bienlein

unread,
Dec 6, 2013, 6:46:17 AM12/6/13
to mi...@dartlang.org


Am Freitag, 6. Dezember 2013 12:01:40 UTC+1 schrieb Peter von der Ahé:

In the context of try.dartlang.org, I have been thinking a lot about
incremental compilation and hot swapping. A big part of what lacks is
to identify what needs to be fixed up, making this the hard part of
supporting hot swapping.

For the VM to support hot swapping, my understanding is it is
currently lacking not tracking dependencies (meaning that identifying
what needs to be fixed up is the hard part here as well).

One approach I could think of would be to organize the code in modules. Some process in your Dart application periodically checks whether some new module was added to some pickup directory. If so the code compiled on the fly. What I don't know is whether this way the old code would get replaced with the newly compiled code. OSGi for the JVM has a dependency system that knows about dependencies between modules. For the time being I would ignore that kind of functionality and leave responsibility to the developer who has to make sure that a new module is compatible with existing ones.
 
Hot swapping is an essential feature in Smalltalk, and many of the
people involved in the Dart project from the start would like to see
such features from Smalltalk be made available in Dart.

I earned my pay for about 10 years in a row with Smalltalk development. The idea of snapshots clearly corresponds with the concept of images in Smalltalk. But I don't see how Smalltalk allows for hot swapping. If you hand in source code at runtime you need the Smalltalk compiler to be present to turn it into byte code executable by the vm. That would violate license conditions of many Smalltalk systems. Some Smalltalk systems later had something called Smalltalk link libraries (SLL)  that were introduced in order show up with something similar to Java's jars. But loading in a SLL would probably not replace existing code as it doesn't either on the JVM (OSGi does some tricks here where the newly loaded code becomes visible somehow. The old code remains in the code space, though).

Regards, Oliver


Peter Ahé

unread,
Dec 6, 2013, 7:10:25 AM12/6/13
to General Dart Discussion
On Fri, Dec 6, 2013 at 12:46 PM, Bienlein <jet...@web.de> wrote:
>
>
> Am Freitag, 6. Dezember 2013 12:01:40 UTC+1 schrieb Peter von der Ahé:
>>
>>
>> In the context of try.dartlang.org, I have been thinking a lot about
>> incremental compilation and hot swapping. A big part of what lacks is
>> to identify what needs to be fixed up, making this the hard part of
>> supporting hot swapping.
>>
>> For the VM to support hot swapping, my understanding is it is
>> currently lacking not tracking dependencies (meaning that identifying
>> what needs to be fixed up is the hard part here as well).
>
>
> One approach I could think of would be to organize the code in modules.

The dependencies I'm concerned about are not between modules. It is
the dependencies that are created when a compiler optimizes one method
by inlining another. This sort of dependency violates all abstractions
the programmer has put in place, in order to make the code run fast.
We expect the compiler to do this, but unless you think about hot
swapping early, chances are that the compiler forgets what it inlined
(a dependency).

> Some
> process in your Dart application periodically checks whether some new module
> was added to some pickup directory. If so the code compiled on the fly. What
> I don't know is whether this way the old code would get replaced with the
> newly compiled code. OSGi for the JVM has a dependency system that knows
> about dependencies between modules. For the time being I would ignore that
> kind of functionality and leave responsibility to the developer who has to
> make sure that a new module is compatible with existing ones.
>
>>
>> Hot swapping is an essential feature in Smalltalk, and many of the
>> people involved in the Dart project from the start would like to see
>> such features from Smalltalk be made available in Dart.
>
>
> I earned my pay for about 10 years in a row with Smalltalk development. The
> idea of snapshots clearly corresponds with the concept of images in
> Smalltalk. But I don't see how Smalltalk allows for hot swapping.

You hot swap each time you accept a new method during development.
When the compiler is available, the Smalltalk VM can hot swap.

In Dart, the compiler is available, but neither the VM nor the output
generated by dart2js supports hot swapping.

Cheers,
Peter

> If you
> hand in source code at runtime you need the Smalltalk compiler to be present
> to turn it into byte code executable by the vm. That would violate license
> conditions of many Smalltalk systems. Some Smalltalk systems later had
> something called Smalltalk link libraries (SLL) that were introduced in
> order show up with something similar to Java's jars. But loading in a SLL
> would probably not replace existing code as it doesn't either on the JVM
> (OSGi does some tricks here where the newly loaded code becomes visible
> somehow. The old code remains in the code space, though).
>
> Regards, Oliver
>
>
Reply all
Reply to author
Forward
0 new messages