Skip to content

[New feature] Bring GO-lang's goroutine support to dart, as Web is not a problem now #52858

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

Closed
gintominto5329 opened this issue Jul 6, 2023 · 6 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-isolate type-enhancement A request for a change that isn't a bug

Comments

@gintominto5329
Copy link

hi,

Go-routine

A goroutine is a lightweight thread managed by the Go runtime.

A Goroutine is a function which executes independently and simultaneously in connection with any other Goroutines present in the program.

The cost of creating Goroutines is very small as compared to the thread.

Dart's Isolates are even heavier than threads, so goroutine would be like a 3-yo brother to Isolate.

Why?

  • Goroutine is the prime highlight feature of GO language.
  • This feature, along with memory efficiency, can even make the most GO-phers, and NodeJS-ers, jump to Dart.

Why now?

As I could understand from Google Groups: Why not the goroutine way? [Oct 2016], dart team did not implement goroutines before, because:

Dart has Isolates that work in the VM and Browser (implemented as web workers).

Dart was trying to match the JavaScript features

this need to match the present and future JS features

But dart-web is going the wasm route, which will have threading support,
So cannot this be implemented now, because

Make the most GO, and NodeJS users, jump to Dart
Because Memory is not a very big factor now-a-days, which GO users would care about

I also read (in the above google-groups chat), that

Dartino was experimenting with lighter weight concurrency controls, like coroutines

May be because Dartino, did not have the "Web worker" constraints

thanks

@gintominto5329
Copy link
Author

@lrhn lrhn added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. type-enhancement A request for a change that isn't a bug labels Jul 6, 2023
@lrhn
Copy link
Member

lrhn commented Jul 6, 2023

I'll admit I have a hard time placing this issue into an existing bucket. I'm going with library-isolate, but only because that's the existing feature it wants to replace.

But dart-web is going the wasm route,

I wouldn't assume compiling to JavaScript will just go away.

@bivens-dev
Copy link

Am I missing something? I thought this had already been a thing for some time now https://youtu.be/SXT7nir1B48

@bernaferrari
Copy link
Contributor

you don't need to wait for javascript to go away, isolates is already native exclusive, they could just build an easier to use isolate (similar to goroutine or kotlin coroutine) without looking into javascript.

@gintominto5329
Copy link
Author

I do not support this feature, anymore, after reading:

Isolate groups (having shared heap) can overcome some of the negative scenarios such as parsing a JSON in a spawned isolate and sending the result back to the main thread without a noticeable freeze there.

This fundamental change can ruin Dart, as it seems to violate, some key concepts of the language.

Originally posted by @maxim-saplin in dart-lang/language#333 (comment)

Also,

Visual Studio Code is implemented in single thread JS and packaged as standalone app via Electron

Originally posted by @maxim-saplin in dart-lang/language#333 (comment)

repo admins, please close this issue if needed

thanks

@lrhn
Copy link
Member

lrhn commented Aug 23, 2023

Consider it closed :)

@lrhn lrhn closed this as completed Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-isolate type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants