[dart-announce] Dart2 Breaking Change: Removing web support for dart:mirrors and dart:isolate

1,414 views
Skip to first unread message

'Kevin Moore' via Dart Announcements

unread,
Feb 23, 2018, 8:05:53 PM2/23/18
to Dart Announcements

As part of our work to ship Dart 2, we are removing support in our web tools for dart:mirrors and dart:isolate. You will see this change in dart2js and the Dart Dev Compiler in the next few weeks on the Dart SDK dev channel.


Note: the Dart VM will continue to fully support both libraries.


Details:


dart:isolate
This library was an attempt to provide a single API that provides common concurrency functionality across Dart's web and native platforms. While useful in some cases, most users found the isolate API limiting compared to the Web Workers API. The infrastructure for supporting isolates also adds substantial overhead when compiling to JavaScript. In the future, you should use Web Workers to access concurrency on the web.


dart:mirrors - This library provides a runtime reflection API. To provide a full fidelity experience, Dart JavaScript compilers included a substantial amount of type information while also losing the ability to do precise tree-shaking. This leads to dramatically increased output size and execution time. We recommend web developers use code generation using tools like package:build and package:source_gen. These are the tools used by AngularDart and package:json_serializable.


If you have questions about this change, please post on the Dart discussion group.

--
For more news and information, visit https://plus.google.com/+dartlang
 
To join the conversation, visit https://groups.google.com/a/dartlang.org/

Frank Rollpin

unread,
Feb 23, 2018, 11:55:30 PM2/23/18
to Dart Misc, anno...@dartlang.org
So there will no longer be a way to use the same concurrent code on both server and client side? This is unfortunate as we are doing just that, it really is a killer feature of Dart. I was really hoping that the Dart team would instead enhance the Isolates API to make it on par with WebWorkers (using shared memory, etc).

I guess we will need to come up with some sort of abstraction layer now :(

Istvan Soos

unread,
Feb 24, 2018, 10:58:02 AM2/24/18
to General Dart Discussion, frank....@gmail.com
I think you can still have the same concurrent semantics, but need to
do some tweaks (e.g. webworkers can be started only via a script).

+1 for an abstraction layer. About a year ago I've started this, but
never really concluded how it should look like:
https://github.com/isoos/message_hub

If somebody would love to pick it up, I'm happy to help...

Cheers,
Istvan
> --
> 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+uns...@dartlang.org.

Tobe Osakwe

unread,
Feb 24, 2018, 11:07:58 AM2/24/18
to mi...@dartlang.org, frank....@gmail.com
One solution that’s worked for me is just using package:stream_controller and package:json_rpc_2.

It’s easy to create a channel between the main thread and a web worker and send messages back and forth. You can use the same json_rpc_2 utilities across Isolates in the VM, too.

Vasiliy Nerozin

unread,
Feb 24, 2018, 1:02:30 PM2/24/18
to Dart Misc, anno...@dartlang.org
This is sad... :( We are intensively using this features in our project. I agree with Frank Rollpin that it is killer feature of Dart to use the same concurrent code on both server and client side. 

We are waiting for shared memory feature for Isolates and support dart:isolate to use the same code on server and client side.

John Yendt

unread,
Feb 24, 2018, 1:02:30 PM2/24/18
to Dart Misc, anno...@dartlang.org
I am currently using dart Isolate in the browser.  I would be happy to switch to WebWorker, but I cannot find any documentation on Dart WebWorkers, only JS.  Also, can you elaborate on when my current Isolate code will stop working.  

Kevin Moore

unread,
Feb 24, 2018, 1:17:51 PM2/24/18
to Dart Misc, anno...@dartlang.org

On Saturday, February 24, 2018 at 10:02:30 AM UTC-8, John Yendt wrote:
I am currently using dart Isolate in the browser.  I would be happy to switch to WebWorker, but I cannot find any documentation on Dart WebWorkers, only JS. 

We're working on updating the APIs that dart:html and friends are based on. Stay tuned!
 
Also, can you elaborate on when my current Isolate code will stop working.  

If you're using Dart 1.24.x, it will continue to work – although when Dart 2 comes out, you'll like want to upgrade.

If you're following the Dart 2 dev releases, expect isolate on the web to stop working in the coming weeks.

Andrew Skalkin

unread,
Feb 24, 2018, 5:10:00 PM2/24/18
to Dart Misc, anno...@dartlang.org
Will the API be completely different from isolates? Is there any roadmap for the parallel computations in Dart (browser and VM)?

I apologize if I sound negative (you guys have done awesome work with Dart which I appreciate a lot), but isn't it a step backwards? We have an API that already works fine across platforms. The plan is to make it incompatible. Why? If the only reason is the overhead for JS compilation, perhaps it can be improved somehow?

Matan Lurey

unread,
Feb 24, 2018, 5:25:50 PM2/24/18
to mi...@dartlang.org, anno...@dartlang.org
On Sat, Feb 24, 2018 at 2:10 PM Andrew Skalkin <ska...@gmail.com> wrote:
Will the API be completely different from isolates? Is there any roadmap for the parallel computations in Dart (browser and VM)?

I apologize if I sound negative (you guys have done awesome work with Dart which I appreciate a lot), but isn't it a step backwards? We have an API that already works fine across platforms.

Sort of.

Part of the isolate API has never worked (spawnFunction) in JS platforms, and the other (spawnFile) doesn't work in Dart/AOT (Flutter). Neither are able to use transferrable/shared memory objects, and dart:isolate was never implemented in DDC (dartdevc, the development mode for Dart2 using JavaScript). There are other inconsistencies as well.
 
The plan is to make it incompatible. Why? If the only reason is the overhead for JS compilation, perhaps it can be improved somehow?

It could be, but that would also mean potentially never making the Dart VM/Flutter AOT multi-threading substantially better, because it would have to support the lowest-common denominator of whatever JS supports (web workers). 

On the other hand, the JS platform has evolved quite a bit since isolates were created:

* Web workers
* Service workers
* Animation worklets
* ... and other APIs like SharedArrayBuffer

... we'd like to enable our web users to seemingly use these, with as little overhead as possible, without worrying about whether these same APIs could be implemented efficiently in the Dart VM.
 

On Saturday, February 24, 2018 at 1:17:51 PM UTC-5, Kevin Moore wrote:

On Saturday, February 24, 2018 at 10:02:30 AM UTC-8, John Yendt wrote:
I am currently using dart Isolate in the browser.  I would be happy to switch to WebWorker, but I cannot find any documentation on Dart WebWorkers, only JS. 

We're working on updating the APIs that dart:html and friends are based on. Stay tuned!

--

'Kevin Moore' via Dart Announcements

unread,
Feb 24, 2018, 5:28:07 PM2/24/18
to Dart Misc, Dart Announcements
*deletes email being drafted*

What Matan said. :-)

You received this message because you are subscribed to a topic in the Google Groups "Dart Misc" group.
To unsubscribe from this topic, visit https://groups.google.com/a/dartlang.org/d/topic/misc/djfFMNCWmkE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to misc+uns...@dartlang.org.

Andrew Skalkin

unread,
Feb 24, 2018, 6:13:44 PM2/24/18
to Dart Misc, anno...@dartlang.org
Matan, 

Thanks for the explanation, now I understand the reasons behind the decision better. It will certainly be nice to be able to use the latest features of the JS platform, but still, I see a lot of value in being able to process data in parallel in the same way across platforms. I wonder if it would be possible for us to develop a layer that would parallelize algorithms and use either isolates, or Web Workers depending on the platform? Let's imagine we are writing a compression utility, how would we compress several arrays in parallel?


It could be, but that would also mean potentially never making the Dart VM/Flutter AOT multi-threading substantially better, because it would have to support the lowest-common denominator of whatever JS supports (web workers). 


Why not implement whatever JS supports (Web workers, SharedArrayBuffer) with isolates, therefore making it cross-platform, and make advanced VM-related functionality (by the way, are there any plans to do it?) available only in the VM?

In any case, thanks for the work you are doing - and I am looking forward to see the updated dart:html and other improvements!

Kevin Moore

unread,
Feb 26, 2018, 3:23:09 PM2/26/18
to Dart Misc
On Sat, Feb 24, 2018 at 3:13 PM, Andrew Skalkin <ska...@gmail.com> wrote:
Matan, 

Thanks for the explanation, now I understand the reasons behind the decision better. It will certainly be nice to be able to use the latest features of the JS platform, but still, I see a lot of value in being able to process data in parallel in the same way across platforms. I wonder if it would be possible for us to develop a layer that would parallelize algorithms and use either isolates, or Web Workers depending on the platform? Let's imagine we are writing a compression utility, how would we compress several arrays in parallel?


It could be, but that would also mean potentially never making the Dart VM/Flutter AOT multi-threading substantially better, because it would have to support the lowest-common denominator of whatever JS supports (web workers). 


Why not implement whatever JS supports (Web workers, SharedArrayBuffer) with isolates,

Chrome, Safari, etc don't have Isolates – they have Web Workers, etc.
 
therefore making it cross-platform, and make advanced VM-related functionality (by the way, are there any plans to do it?) available only in the VM?

In any case, thanks for the work you are doing - and I am looking forward to see the updated dart:html and other improvements!

Thanks! We care about this area. Love the discussion and interest...
 

--
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 a topic in the Google Groups "Dart Misc" group.
To unsubscribe from this topic, visit https://groups.google.com/a/dartlang.org/d/topic/misc/djfFMNCWmkE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to misc+uns...@dartlang.org.

Dmitriy Vasilyev

unread,
Mar 16, 2018, 7:19:31 AM3/16/18
to Dart Misc, anno...@dartlang.org
It's really sad. We are using mirrors a lot in our project. We have classes, annotated with special parameters and can generate info apon that annotations, set field data and so on. What can we do in Dart 2?

суббота, 24 февраля 2018 г., 4:05:53 UTC+3 пользователь 'Kevin Moore' via Dart Announcements написал:

Jonathan Rezende

unread,
Mar 16, 2018, 8:22:15 AM3/16/18
to mi...@dartlang.org, anno...@dartlang.org
source_gen.
I was using mirrors too, then reflectable and finally source_gen. 
I think it is much better, since you have much more control and generate only what you need.

Atenciosamente, 

Jonathan Rezende

-- 
For more ways to connect visit https://www.dartlang.org/community
--- 

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+uns...@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/e4cccb56-8541-4ee8-b3e0-dcc04f2bdd4c%40dartlang.org.

Erik Ernst

unread,
Mar 16, 2018, 8:40:51 AM3/16/18
to Dart Misc
On Fri, Mar 16, 2018 at 12:19 PM Dmitriy Vasilyev <kele...@gmail.com> wrote:
It's really sad. We are using mirrors a lot in our project. We have classes, annotated with special parameters and can generate info apon that annotations, set field data and so on. What can we do in Dart 2?

The package reflectable (which was also mentioned by Jonathan Rezende) is based on static code generation, but is very nearly the same thing as 'dart:mirrors'. It uses `String`s rather than `Symbol`s, and doesn't support a couple of things (e.g., reflection on closures), because the required run-time support does not exist. That package is currently being updated to work in Dart 2 (and also to fit into a continuous testing setup which has changed a lot). It's a busy time, but we'll get there. ;)

суббота, 24 февраля 2018 г., 4:05:53 UTC+3 пользователь 'Kevin Moore' via Dart Announcements написал:

As part of our work to ship Dart 2, we are removing support in our web tools for dart:mirrors and dart:isolate. You will see this change in dart2js and the Dart Dev Compiler in the next few weeks on the Dart SDK dev channel.


Note: the Dart VM will continue to fully support both libraries.


Details:


dart:isolate
This library was an attempt to provide a single API that provides common concurrency functionality across Dart's web and native platforms. While useful in some cases, most users found the isolate API limiting compared to the Web Workers API. The infrastructure for supporting isolates also adds substantial overhead when compiling to JavaScript. In the future, you should use Web Workers to access concurrency on the web.


dart:mirrors - This library provides a runtime reflection API. To provide a full fidelity experience, Dart JavaScript compilers included a substantial amount of type information while also losing the ability to do precise tree-shaking. This leads to dramatically increased output size and execution time. We recommend web developers use code generation using tools like package:build and package:source_gen. These are the tools used by AngularDart and package:json_serializable.


If you have questions about this change, please post on the Dart discussion group.

--
For more news and information, visit https://plus.google.com/+dartlang
 
To join the conversation, visit https://groups.google.com/a/dartlang.org/

--
For more ways to connect visit https://www.dartlang.org/community
---
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+uns...@dartlang.org.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/misc/e4cccb56-8541-4ee8-b3e0-dcc04f2bdd4c%40dartlang.org.


--
Erik Ernst  -  Google Danmark ApS
Skt Petri Passage 5, 2 sal, 1165 København K, Denmark
CVR no. 28866984

'Kevin Moore' via Dart Announcements

unread,
May 14, 2018, 11:10:04 AM5/14/18
to Dart Announcements
Follow-up: 2.0.0-dev.55.0 has just been released with dart:isolate APIs removed.

Two addendum:
  1. This change also now allows Web Workers to be used via JS interop. I will share some follow-up information shortly.
  2. In most web apps, you will notice a decrease in JS compiled size – 25-30KB in minified output.

--
For more ways to connect visit https://www.dartlang.org/community
---
You received this message because you are subscribed to the Google Groups "Dart Announcements" group.
Visit this group at https://groups.google.com/a/dartlang.org/group/announce/.

'Kevin Moore' via Dart Announcements

unread,
May 14, 2018, 11:11:16 AM5/14/18
to Dart Announcements
My apologies. To be very clear, dart:isolate support has been removed from dart2js.

dart:isolate is still available via the Dart VM for console, server, and Flutter applications.
Reply all
Reply to author
Forward
0 new messages