-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Remove support for dart:mirrors and dart:isolate from dart4web #30538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@munificent will there be a web worker library then? |
Likely, but mutually exclusive with this issue. |
Sure I just figured there'd be an associated issue. |
No associated issue yet. |
No concrete plans that I know of, but I think you should be able to get to web workers by going through JS interop. |
We talked a bit about this when I visited @jacob314 and others. Any "native" API is likely to be more-or-less equivalent of the bit of JS interop you'd write today - there aren't any immediate plans to make a super "Darty" web worker/service worker API, especially given the spec evolving. |
I respect not wanting to have a darty web worker/service worker API at this time. My first concern is about how stuff exposed in As an example in Chrome's IDL there is https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/indexeddb/WorkerGlobalScopeIndexedDatabase.idl and https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/indexeddb/WindowIndexedDatabase.idl for the two different contexts of indexeddb. I feel I should be able to have the same My second concern is about compilation. I'm not sure if DDC would freak out when running in a worker context because of any magic happening with Thanks for the replies here. I'm really looking forward to the Dart's 2.0+ future but wanted to make sure I didn't run into trouble when I started trying to use worker contexts in Dart. Its going to get even more complicated with houdini and its additional set of worker contexts so figured I'd voice issues now rather than later. |
This is just me spit-balling a bit, but I imagine a web-worker or service-worker script would just be a Dart web application with a
This is a bit harder of one. Of course, some smart abstract class IndexedDb {
factory IndexedDb() {
if (inWorker) return new _WorkerIndexedDb();
return new _WindowIndexedDb();
}
}
I don't know specifically about DDC, though I'll defer to @jmesserly - Jennifer does DDC assume it is running in a windowed context? (I imagine if the answer is "yes" we can fix it, though it probably won't be a top priority)
It would definitely be useful to create some sort of /cc @jakemac53 on the build/DDC story, since we might need multiple entry-points? |
I think DDC should be fine from a worker -- we can run on |
You remove mirrors without a clear strategy for reflections???? OMG! These are the available technologies I am a ware of:
Reflections are essential for a modern language - please recommend one, clear strategy. |
On the web (and to some extent our other platforms), Dart is:
Those constraints lean heavily towards doing metaprogramming statically (during the compile) instead of dynamically (at runtime). So most of our metaprogramming focus is on static tools right now. source_gen is a good package to take a look at. Ahead-of-time code generation is also how Angular templates are managed. Reflection and mirrors — doing your metaprogramming while the program is running — is nice on VM- or image-based systems where code size doesn't matter and you already happen to have access to all of the underlying information at runtime. That's true in platforms like Smalltalk, the JVM, and the CLR. The designers of Dart hoped it would eventually be true of the Dart VM in the browser as well. Now that that's not going to happen, I believe a static metaprogramming approach is a better fit for the language's compilation model and target platforms. |
Thanks for your answer but it's a very general answer. A metaprogramming/reflection strategy from the Dart-Team should be out before Dart 2.0. I think sometimes at Google you don't know how real world apps are built. In my case my package "mdl" uses mirrors. I import "dice" for DI and "mustache" for templates - both of them are also using mirrors. Now what? Betting on the wrong horse is to expensive. I can't make my lib Dart 2 ready. I have to wait an see where the train goes. Very annoying. Thats the problem with Dart - it's a nice language with nice ideas but approaches like this makes it look like a language in beta. |
@wdevore my understanding is that the removal affects only browser targets. If you run your code on VM, you should be fine. |
It's being removed from Dart2JS/Dart4Web only. Anybody using mirrors or isolates in the command-line VM can continue to do so. Flutter doesn't support mirrors, but isolates will continue to work. For the web, we'll be focusing on supporting web technologies like web workers, service workers, animation workers - etc - which have different constraints than isolates. For compilation, mirrors unfortunately just doesn't allow any kind of decent JavaScript output. In a world with lots of dynamic programming options, I'd probably suggest something like TypeScript, Flow, etc, if you truly need runtime reflection. Funny enough, even Angular TypeScript is soft-deprecating runtime reflection support for similar JavaScript code size issues. We are investing hugely in code generation (pkg/source_gen, pkg/build_runner) for static meta-programming, so would love to know your thoughts on how we can better support your use-cases. Cheers! |
So basically the idea that I can use code from my web application to a "vm-application" dies another little bit here? |
Yup, but as mentioned, I'm sure folks will have abstractions that target both. Web workers are better than isolates in almost every way (today), so we're excited that we'll be able to offer web users this API. On the other hand, Flutter may choose to at some point supporting, say, coroutines, which aren't implementable in the web at all. |
Some dependency cleanup: Neither dependency was used on dart4web, so this is purely a cleanup. Those CL's do not disable dart:isolate on dart4web. |
dart:isolate was used for the `Future<Isolate>` return type of spawnDomUri, which is an unimplemented experimental method. This method now returns `Future`. This change helps dart4web disable support for dart:isolate (#30538) Change-Id: Ida87c2a27ac33d1b9a14feb7dd6d306a546a0aaf Reviewed-on: https://dart-review.googlesource.com/43860 Reviewed-by: Terry Lucas <[email protected]>
This needs to happen very soon if it's happening for 2.0 |
rules for conditional imports are implemented in dart2js now, we will however make dart:isolate produce runtime errors in a future version (likely in beta4). That's being tracked separately here: #32684 As soon as ddc returns false on |
Jenny just fixed #30540 |
dart test, either in flutter or web browser, does not support mirror, see dart-lang/sdk#30538 and flutter/flutter#1150. Using `Directory.current.path` might still be problematic for web browser later on, but now let's focus on flutter only.
dart test, either in flutter or web browser, does not support mirror, see dart-lang/sdk#30538 and flutter/flutter#1150. Using `Directory.current.path` might still be problematic for web browser later on, but now let's focus on flutter only.
In Dart 2.0, our web products — dart2js and dartdevc — will no longer support dart:mirrors and dart:isolate. Support for those has been limited and problematic in many ways for years, so the simplest solution that gives us the most room for future improvement is to not support them at all.
Now that we have configuration-specific imports and
const bool.fromEnvironment("dart.library.mirrors")
"dart.library.isolate", it's feasible for user code to feature-detect whether those libraries are available and handle their absence.This is the main metabug to track this. Feel free to file more specific issues for changes that are needed.
The text was updated successfully, but these errors were encountered: