Skip to content

Guide: don't use GlobalScope in first example #2122

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
zach-klippenstein opened this issue Jul 5, 2020 · 1 comment
Closed

Guide: don't use GlobalScope in first example #2122

zach-klippenstein opened this issue Jul 5, 2020 · 1 comment
Assignees
Labels
docs KDoc and API reference

Comments

@zach-klippenstein
Copy link
Contributor

The use of GlobalScope is well-known to be a code smell in most cases - it's documented in the kdoc itself, as well as numerous articles and discussions around the Kotlin community.

However, in the official coroutines guide, the very first example of coroutines code, and the first example of such code most people will probably see from an "official" source, uses GlobalScope. I think this is counterproductive to all the other recommendations and warnings, and sets many people's first impressions of it as something that is ok to use as a default, and not only as a last resort.

I think the guide would do a better job of getting people off to the right start if the early examples, at least, didn't use GlobalScope.

@elizarov elizarov added the docs KDoc and API reference label Jul 7, 2020
@elizarov
Copy link
Contributor

elizarov commented Jul 7, 2020

Good point. It is not a simple fix, though. It requires rethinking the whole approach to the introduction of coroutines.

@elizarov elizarov self-assigned this Jul 7, 2020
elizarov added a commit that referenced this issue Apr 8, 2021
…hout it

Also, remove the tutorial variant of the basic coroutine introduction as it essentially duplicates the content of the
basic coroutine introduction, albeit with "how to create a project" additional information, which does not seem to be appropriate in this section at all.

Fixes #2122
pablobaxter pushed a commit to pablobaxter/kotlinx.coroutines that referenced this issue Sep 14, 2022
…hout it (Kotlin#2637)

Also, remove the tutorial variant of the basic coroutine introduction as it essentially duplicates the content of the
basic coroutine introduction, albeit with "how to create a project" additional information, which does not seem to be appropriate in this section at all.

Fixes Kotlin#2122

Co-authored-by: Vsevolod Tolstopyatov <[email protected]>
Co-authored-by: Andrey Polyakov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs KDoc and API reference
Projects
None yet
Development

No branches or pull requests

2 participants