superherojs / superherojs

Superhero JavaScript

Home Page:http://superherojs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Under the Hood: Event Loop?

mikaelbr opened this issue · comments

Should the Under the Hood section have a resource for understanding the Event Loop? It is mentioned briefly in the "How Browsers Work" article, but not extensively enough to e.g. give an understanding of why setTimeout(fn, 0) works and why it sometimes is bad, etc.

One possible resource is Phillip Roberts's: What the heck is the event loop anyway?. It gives a visual introduction of how the event loop works.

Is it necessary? Is it something that we should cover?

We should absolutely have something about the event loop! I'll take a look at Roberts' talk later today.

@olav @mollerse @mobmad Any thoughts? Seen other great resources on the topic?

This video is one of the best explanations on the execution model of most JavaScript runtimes I've seen. A topic that is a bit of a "boss fight" for many new JavaScript developers. Would make a great addition in my opinion.

A couple of other thoughts:
Prefering a video over, for example, a blogpost is something that vary from person to person. I'm not sure if we should perhaps offer mutiple resources on the same topic depending on wether you prefer audiovisual or textual resources?

And this topic sort-of fall into a new category which might be a good idea to expand upon further: The relationship between JavaScript, the language, and its runtimes (the browsers, node.js, etc). For example, JavaScript the language is not actually async, but all of its runtimes are. Viewing the language outside the context of the runtime might not be useful or worthwhile, so I'm not sure a distinction is wanted, or even needed?

@mollerse Isn't the category "Under the Hood" fitting as an umbrella for these terms? And I don't know if the distinction between "language in runtime" and language is that important, since, as you say, all runtimes are async.

Great point, @mollerse.

I think I prefer that we choose the best resource we've found, and not differentiate between the type of resource. That might mean we only add a book, a video, some slides, a blog post, or something else for a specific topic.

I feel like this topic lands somewhere in between "Understanding JavaScript" and "Under the Hood". Things that are "Under the Hood" deals more with performance intricacies and things that aren't necessarily exposed to all JavaScript-developers.

Runtime APIs, especially the Browser APIs, is something all JavaScript developers use in their day to day coding. The things that gets exposed here, like asynchronous programming, belongs in another category than most "Under the Hood" type of things. Even though most of them actually are an "Under the hood"-thing.

@kjbekkelund How does one decide what the best resource is? Some people will respond better to a blogpost and other to a video, depending on how they prefer to cosume knowledge. Would a good solution be to have multiple links to the same topic if good (for a useful defintion of good) resources exist in different formats? I'm not even sure if this is actually a problem though, it will boil down to using the right words for the right background. What is useful to a Java-developer coming to JavaScript will be different from what a recovering Ruby developer will find useful.

I tend to agree with having it under "Understanding JavaScript". Perhaps we should create a new section for more "low-level hardcore stuff"?

@mollerse I guess the only solution is: we decide. People will be different and like different resources. We just have to decide what we (the team) think is the best resource on the specific topic, and then those who disagree can create a Github issue where we discuss alternative resources.

@mikaelbr Awesome talk! This should definitely be posted. As @mollerse mentions, it feels like something in-between the two categories mentioned. However, I think I prefer "Under the hood" for now.