Discussion:
[dart-misc] Will dart.... in Node.js ?
Alexey Solovey
2015-11-18 18:06:06 UTC
Permalink
Hello. I want to see Dart VM inside Node.js. But will be Dart use as
Node.js Engine (sub-engine).
I think about scenario, where Dart work as Node.js native module. And runs
like coffeescript runs through "coffee script.coffee".
Also I thinking about interaction with C++ native module API.

I want try Dart with C++ AMP native module, or CUDA.
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Bob Nystrom' via Dart Misc
2015-11-18 18:44:14 UTC
Permalink
Post by Alexey Solovey
Hello. I want to see Dart VM inside Node.js. But will be Dart use as
Node.js Engine (sub-engine).
Is it that you want to use Dart code within Node, or the Dart *virtual
machine?*
Post by Alexey Solovey
I think about scenario, where Dart work as Node.js native module. And runs
like coffeescript runs through "coffee script.coffee".
The way this works for CoffeeScript is that it's compiled to JavaScript and
then the resulting JS is run in node. Would the same work for you for Dart?

– bob
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Mike Carter
2015-11-18 20:05:11 UTC
Permalink
You might want to check out this project, gives you some node bindings in
dart: https://github.com/dglogik/node_io.dart
Post by Alexey Solovey
Hello. I want to see Dart VM inside Node.js. But will be Dart use as
Node.js Engine (sub-engine).
I think about scenario, where Dart work as Node.js native module. And runs
like coffeescript runs through "coffee script.coffee".
Also I thinking about interaction with C++ native module API.
I want try Dart with C++ AMP native module, or CUDA.
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Jim Simon
2015-11-18 23:41:45 UTC
Permalink
I'd love to be able to run dart code compiled to JavaScript on node.js. I
tried doing this with the old js interop package, but quickly ran into
issues with I/O and finding a working preamble. It'd be great to have
node.js be a target platform for dart2js or ddc. Dart packages could then
theoretically serve two communities at once. If the resulting JS is
readable, it would also help mitigate the whole "what if Google gives up on
Dart?" fear since there would be a migration path. Does the new JS interop
provide a better story for this?
Post by Mike Carter
You might want to check out this project, gives you some node bindings in
dart: https://github.com/dglogik/node_io.dart
Post by Alexey Solovey
Hello. I want to see Dart VM inside Node.js. But will be Dart use as
Node.js Engine (sub-engine).
I think about scenario, where Dart work as Node.js native module. And
runs like coffeescript runs through "coffee script.coffee".
Also I thinking about interaction with C++ native module API.
I want try Dart with C++ AMP native module, or CUDA.
--
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
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Bob Nystrom' via Dart Misc
2015-11-18 23:55:33 UTC
Permalink
I tried doing this with the old js interop package, but quickly ran into
issues with I/O and finding a working preamble. It'd be great to have
node.js be a target platform for dart2js or ddc.
I think so too.
Dart packages could then theoretically serve two communities at once. If
the resulting JS is readable, it would also help mitigate the whole "what
if Google gives up on Dart?" fear since there would be a migration path.
Yes! Readable, debuggable, JS is a key goal of DDC (as opposed to dart2js
where it never was).
Does the new JS interop provide a better story for this?
I'm not the best person to answer detailed questions, but my understanding
is that, yes, it's a much more seamless experience.

– bob
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Michael Bullington
2015-11-20 00:12:07 UTC
Permalink
Hello!

Michael Bullington here, I work at DGLogik, and I'm the main developer on
the aforementioned node_io project, as well as other node.js <-> Dart
related projects. With these projects, we are able to ship a stable version
of our IoT platform's Dart SDK to clients that can be used to create
applications entirely in JavaScript. This is on both the browser, and on
node.js.

Basically, to run Dart code in node.js, there are a few things you need to
do.

- Compile your "main" Dart file with dart2js.
- You need to prepend code to the dart2js output file for it to be able to
work in a node.js environment. I've created a pub package for mostly ease
of use, as it's versioned and easily able to be integrated into a build
system with Grinder or similar.

https://pub.dartlang.org/packages/node_preamble

Or, if you'd just like the file itself to prepend, here it is:

https://raw.githubusercontent.com/mbullington/node_preamble.dart/master/lib/preamble.js

If you are building for the browser, you need to do other things like
Browserify, etc. Considering you are wondering about native modules, I
don't believe this is in the scope of what you'd like to do?

With this setup, you can use any node.js API by using the dart:js package,
including node.js native modules (we use node.js native modules when
available to speed up some cryptographic operations).
The new js package introduced with Dart 1.13 should work, I haven't tried
it personally. I'm not sure how it would work with CommonJS's require().

As for node_io, we use it for our purposes, but as of right now it is
hardly API complete with dart:io. We intend to branch node_io out in the
future, but until then it is not published on pub for this reason.
And as for using Dart code from JavaScript, we use something we built on
top of the current dart2js compiler called calzone, which you can find on
pub. (as a side note, can't wait to see how DDC will improve our codebase
with readable JS!)

If you (or anyone else curious about the subject) would like to discuss
Dart on node.js (I'll try my best), I'd love to chat on the Dart Slack
Post by Alexey Solovey
Hello. I want to see Dart VM inside Node.js. But will be Dart use as
Node.js Engine (sub-engine).
I think about scenario, where Dart work as Node.js native module. And runs
like coffeescript runs through "coffee script.coffee".
Also I thinking about interaction with C++ native module API.
I want try Dart with C++ AMP native module, or CUDA.
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Jim Simon
2015-11-22 21:45:12 UTC
Permalink
What I'd really like to see is for the dart compiler (either one) to be
aware of node IO operations and to compile Dart IO operations down to their
corresponding Node equivalent. IIRC, right now it just doesn't do anything
(maybe throws an error?)
Post by Michael Bullington
Hello!
Michael Bullington here, I work at DGLogik, and I'm the main developer on
the aforementioned node_io project, as well as other node.js <-> Dart
related projects. With these projects, we are able to ship a stable version
of our IoT platform's Dart SDK to clients that can be used to create
applications entirely in JavaScript. This is on both the browser, and on
node.js.
Basically, to run Dart code in node.js, there are a few things you need to
do.
- Compile your "main" Dart file with dart2js.
- You need to prepend code to the dart2js output file for it to be able to
work in a node.js environment. I've created a pub package for mostly ease
of use, as it's versioned and easily able to be integrated into a build
system with Grinder or similar.
https://pub.dartlang.org/packages/node_preamble
https://raw.githubusercontent.com/mbullington/node_preamble.dart/master/lib/preamble.js
If you are building for the browser, you need to do other things like
Browserify, etc. Considering you are wondering about native modules, I
don't believe this is in the scope of what you'd like to do?
With this setup, you can use any node.js API by using the dart:js package,
including node.js native modules (we use node.js native modules when
available to speed up some cryptographic operations).
The new js package introduced with Dart 1.13 should work, I haven't tried
it personally. I'm not sure how it would work with CommonJS's require().
As for node_io, we use it for our purposes, but as of right now it is
hardly API complete with dart:io. We intend to branch node_io out in the
future, but until then it is not published on pub for this reason.
And as for using Dart code from JavaScript, we use something we built on
top of the current dart2js compiler called calzone, which you can find on
pub. (as a side note, can't wait to see how DDC will improve our codebase
with readable JS!)
If you (or anyone else curious about the subject) would like to discuss
Dart on node.js (I'll try my best), I'd love to chat on the Dart Slack
Post by Alexey Solovey
Hello. I want to see Dart VM inside Node.js. But will be Dart use as
Node.js Engine (sub-engine).
I think about scenario, where Dart work as Node.js native module. And
runs like coffeescript runs through "coffee script.coffee".
Also I thinking about interaction with C++ native module API.
I want try Dart with C++ AMP native module, or CUDA.
--
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
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Kasper Peulen
2015-11-22 23:16:18 UTC
Permalink
Post by 'Bob Nystrom' via Dart Misc
Yes! Readable, debuggable, JS is a key goal of DDC (as opposed to dart2js
where it never was).
I understand that the reasoning behind choosing ES6 instead of ES5, as with
ES5 the output will still not be really readable.

The downside is of course, that we probably still need to use babel, for
compiling it to ES6.

Therefore, I would hope the team to consider maybe having an option
compiling Dart to typescript instead of ES6. I think this makes sense, as
when compiling to typescript, the types, annotations, and soon also
async/await code would not get lost in the process.

So basically, compiling dart to typescript would probably give more
readable code than compiling to ES6. Only then you would use the typescript
compiler to target es5 (or es3), instead of babel.

I wonder if in that way, I could write angular2 components in Dart, that
could be used by angular 2 typescript devs.
Post by 'Bob Nystrom' via Dart Misc
What I'd really like to see is for the dart compiler (either one) to be
aware of node IO operations and to compile Dart IO operations down to their
corresponding Node equivalent. IIRC, right now it just doesn't do anything
(maybe throws an error?)
On Thu, Nov 19, 2015 at 7:12 PM, Michael Bullington <
Post by Michael Bullington
Hello!
Michael Bullington here, I work at DGLogik, and I'm the main developer on
the aforementioned node_io project, as well as other node.js <-> Dart
related projects. With these projects, we are able to ship a stable version
of our IoT platform's Dart SDK to clients that can be used to create
applications entirely in JavaScript. This is on both the browser, and on
node.js.
Basically, to run Dart code in node.js, there are a few things you need
to do.
- Compile your "main" Dart file with dart2js.
- You need to prepend code to the dart2js output file for it to be able
to work in a node.js environment. I've created a pub package for mostly
ease of use, as it's versioned and easily able to be integrated into a
build system with Grinder or similar.
https://pub.dartlang.org/packages/node_preamble
https://raw.githubusercontent.com/mbullington/node_preamble.dart/master/lib/preamble.js
If you are building for the browser, you need to do other things like
Browserify, etc. Considering you are wondering about native modules, I
don't believe this is in the scope of what you'd like to do?
With this setup, you can use any node.js API by using the dart:js
package, including node.js native modules (we use node.js native modules
when available to speed up some cryptographic operations).
The new js package introduced with Dart 1.13 should work, I haven't tried
it personally. I'm not sure how it would work with CommonJS's require().
As for node_io, we use it for our purposes, but as of right now it is
hardly API complete with dart:io. We intend to branch node_io out in the
future, but until then it is not published on pub for this reason.
And as for using Dart code from JavaScript, we use something we built on
top of the current dart2js compiler called calzone, which you can find on
pub. (as a side note, can't wait to see how DDC will improve our codebase
with readable JS!)
If you (or anyone else curious about the subject) would like to discuss
Dart on node.js (I'll try my best), I'd love to chat on the Dart Slack
Post by Alexey Solovey
Hello. I want to see Dart VM inside Node.js. But will be Dart use as
Node.js Engine (sub-engine).
I think about scenario, where Dart work as Node.js native module. And
runs like coffeescript runs through "coffee script.coffee".
Also I thinking about interaction with C++ native module API.
I want try Dart with C++ AMP native module, or CUDA.
--
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
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
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
---
You received this message because you are subscribed to the Google Groups
"Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an
--
Kasper
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'John Messerly' via Dart Misc
2015-11-23 18:44:21 UTC
Permalink
Hi Kasper,
Post by 'Bob Nystrom' via Dart Misc
Yes! Readable, debuggable, JS is a key goal of DDC (as opposed to dart2js
Post by 'Bob Nystrom' via Dart Misc
where it never was).
I understand that the reasoning behind choosing ES6 instead of ES5, as
with ES5 the output will still not be really readable.
The downside is of course, that we probably still need to use babel, for
compiling it to ES6.
Therefore, I would hope the team to consider maybe having an option
compiling Dart to typescript instead of ES6. I think this makes sense, as
when compiling to typescript, the types, annotations, and soon also
async/await code would not get lost in the process.
Absolutely we'd consider this for DDC. It really just needs someone with
time to champion it.

Currently DDC works (basically) like this:

Dart --> ES6 (with an ES5 module pattern)


Imagine if it worked more like this:

Dart --> "typed JS AST" ---> ES6 w/ modules --> ES6+ES5 module pattern

|--> TypeScript

\--> ES6 w/ Closure Compiler comments/modules


"typed JS AST" is something a bit higher level than the ES6 AST we
currently emit. Something that's easy for us to transform to ES6, TS, or
Closure Compiler as needed.

For anyone interested in this topic, feel free to discuss in the
dev-***@dartlang.org
group <https://groups.google.com/a/dartlang.org/forum/#!forum/dev-compiler>.

I also created https://github.com/dart-lang/dev_compiler/issues/391 to
track this feature request.

So basically, compiling dart to typescript would probably give more
Post by 'Bob Nystrom' via Dart Misc
readable code than compiling to ES6. Only then you would use the typescript
compiler to target es5 (or es3), instead of babel.
I wonder if in that way, I could write angular2 components in Dart, that
could be used by angular 2 typescript devs.
It should work. But keep in mind we do not want DDC to require other
transpilers! (imagine if TypeScript required running the output through
Babel, which required Traceur, which required Narcissus, which required ...
).
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Rat Jo
2015-12-02 06:32:57 UTC
Permalink
If anyone is interested into running dart compiled to js in nodejs, just
hit me. I have actually have few project that do so and work great!
Post by Alexey Solovey
Hello. I want to see Dart VM inside Node.js. But will be Dart use as
Node.js Engine (sub-engine).
I think about scenario, where Dart work as Node.js native module. And runs
like coffeescript runs through "coffee script.coffee".
Also I thinking about interaction with C++ native module API.
I want try Dart with C++ AMP native module, or CUDA.
--
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
---
You received this message because you are subscribed to the Google Groups "Dart Misc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Continue reading on narkive:
Loading...