What the heck is the event loop anyway? | Philip Roberts | JSConf EU
JSConf16 HN recommenders · recommended in 14 months, 2015–2025
talk · intermediate · evergreen · 2015–2025 on HN
Philip Roberts explains the JavaScript event loop, call stack, callbacks and asynchronous behavior with live visualizations using a tool he built. It demystifies terms like non-blocking and single-threaded.
HN commenters repeatedly name it as the best explanation of the JS event loop and the first thing to watch before tackling async code.
Up next
6 mo on HNJake Archibald on the web browser event loop, setTimeout, micro tasks, requestAnimationFrame, ...
JSConf
7 HN recommender · 2018–2023
4 mo on HN10 Things I Regret About Node.js - Ryan Dahl - JSConf EU
JSConf
6 HN recommender · 2018–2025
6 mo on HNEvo-Devo (Despacito Biology Parody) | A Capella Science
acapellascience
6 HN recommender · 2017–2026
12 mo on HNJustice: What's The Right Thing To Do? Episode 01 "THE MORAL SIDE OF MURDER"
Harvard University
11 HN recommender · 2013–2025
7 mo on HNUnix and Google
FOAM
4 HN recommender · 2016–2023
4 mo on HNDoctor Dissects the Wim Hof Method - Cold Hard Science Analysis
Medlife Crisis
3 HN recommender · 2019–2022
2 mo on HNDiffie-Hellman Key Exchange
Art of the Problem
2 HN recommender · 2012–2016
2 mo on HNAlcoholic Vervet Monkeys! - Weird Nature - BBC animals
BBC Studios
2 HN recommender · 2014–2021
13 mo on HNRich Harris - Rethinking reactivity
You Gotta Love Frontend
15 HN recommender · 2019–2026
10 mo on HNCrockford on JavaScript - Volume 1: The Early Years
YUI Library
10 HN recommender · 2013–2022
10 mo on HNRailsConf 2016 - Turbolinks 5: I Can’t Believe It’s Not Native! by Sam Stephenson
Confreaks
6 HN recommender · 2017–2020
10 mo on HNJavaScript: The Good Parts
Google TechTalks
11 HN recommender · 2009–2020
12 comments from Hacker News
This one is my all time favorite - What the heck is the event loop anyway? | Philip Roberts | JSConf EU ▶ this video
I got to know the nuances of the language by working with it for years and having to figure out why various things didn't work at different points, but it doesn't sound like that's your style. This isn't comprehensive, but it's probably the most helpful deep-dive I've ever seen about some aspect of JavaScript. It's about the Event Loop, which is one of the biggest differences between JS and comparable languages like Python: ▶ this video Contrary to what you might think, even though the event loop is in some sense "distinct from the language", it isn't simply an API. You can't really have JavaScript without the event loop; it exists in both the browser and in Node, and is the basis for most of the language's advantages.
Another event loop talk from Philip Roberts. The tool he created to display the event loop in real time is fantastic. ▶ this video
The corner stone of understand async JavaScript code is a deep understanding what happens under the hood with the Event loop. Philip Roberts has a great lecture called what the heck is the event loop anyway? [1] Once that video is watched once, everything else just makes sense. [1] ▶ this video
> How do I take, say JS, and learn it to the point where it really clicks to the point where I can visualize what's going on under the hood when I write programs? Learn how a JS engine works. Any engine will do, although V8 is very discussed on the internet. Here's a few things to get started with: - How the event loop works ( ▶ this video ). This show how JS works under the hood, what's part of "JS" and what's extended, how async operations are scheduled on a single thread. After watching this, everything will just "click". - How objects are represented in V8 ( link ). It's v8-specific but nevertheless tells you how objects are represented in memory. Keeping these concepts in mind, you will be able to write efficient code on the get-go. - ES6 spec ( link ). Optional reading (if you want to read 500+ pages), but it's a handy reference when in doubt. You can literally slap this thing to a person who doesn't know what they're talking about. Not that you should, but backing evidence is always great.
You should be good to go after reading through the Rust book [0] and watching this video [1] [0] link [1] ▶ this video
I've been struggling with wrapping my head around asynchronous programming with callbacks, promises and async/await in JS, however I think it's finally clicking after watching these YouTube videos and creating a document where I explain these concepts as if I'm teaching them to someone else: * Philip Roberts's What the heck is the event loop anyway? - ▶ this video * The Story of Asynchronous JavaScript - link * JavaScript Callbacks, Promises, and Async / Await Explained - link * Async Javascript Tutorial For Beginners (Callbacks, Promises, Async Await). - link * Jake Archibald: In The Loop - setTimeout, micro tasks, requestAnimationFrame, requestIdleCallback, - link Edit... I've been rewatching these videos, reading the MDN docs, the Eloquent JavaScript book, javascript.info, blogs about the subject, etc. This further proves you shouldn't limit yourself to a single resource, and instead fill up the laguna with water from different sources if you will.
Not the parent, but I recommend understanding the event loop first: here [0] is a very good talk. Then, read the chapter on promise on javascript.info [1], as it explains the problems Promise set out to solve (callback hell), then as usual the excellent MDN article [2]. [0] ▶ this video [1] link [2] link
Haha, I'm genuinely intrigued to see the contents of that book. It could certainly be copy/paste from the Mozilla docs, but who knows! I was pleasantly surprised by this video about the JS event loop, although in fairness it is a lecture at a conference rather than a made for youtube video. Regardless, the length of the video made me question how necessary it was but I ended up watching the whole thing and enjoyed it. ▶ this video
Yes, something like that. Like here's David's "Build Your Own Async" [1], which I prefer over Philip's (still extremely good) "What the heck is the event loop anyway?" [2]. It's one thing to tell how something works, but to successfully show what the hell its actually doing under the covers, just conveys much more information. [1] link [2] ▶ this video
I've been using JavaScript professionally for about 12 years. You're going to have to look for talks and really technical posts. Consider whitepapers and source code for JavaScript engines at this point. You'll probably want to start reading up on the things attached to JavaScript, rather than the language itself. Browser rendering, event loop, V8 things, garbage collection, etc. I'm sure you've seen it, but things like this: ▶ this video , and this: link It might be time for you to start writing what you know about JavaScript.
Oh boy, I'm arguing over the Internet. Sorry for that. You do bring good points and I agree upfront that they are indeed JS features that either suck or are not very pedagogical. 1. You don't need to learn about the event loop straight away (or asynchronous programming) by the time you get to that concept, you might as well go to another language that's easier for that. But I do concede that once you get to async programming: JS is not the best language to learn from. With that said for people who got past the basics, here's an intuitive video about the event loop [1] (note: if you're past the basics, don't watch it while you're still doing the basics xD). 2. Basic objects are easily learnable with JS since you can type them in a literal sense, whereas otherwise you need to instantiate it with a constructor (e.g. Java) or you don't really learn about objects (e.g. C, though I've heared that it does have objects right? Despite it being an obscure feature, anyways, I'm not sure if you should be happy to learn about objects, learning about dictionaries or hashing is cool though). More importantly, when you start out learning programming, primitives + some HTML + simple objects are all you need to know. 3. Yes, try/catch is useless. I wouldn't call that basic though, but I'm already noticing we're differing on definitions (note: my definition was relatively clear, variables, if-statements, for loops and functions). And in coding bootcamps, the concept came long after I taught the