ŷ

Jump to ratings and reviews
Rate this book

You Don't Know JS #5

You Don't Know JS: Async & Performance

Rate this book
No matter how much experience you have with JavaScript, odds are you don't fully understand the language. As part of the "You Don't Know JS" series, this concise yet in-depth guide focuses on new asynchronous features and performance techniques--including Promises, generators, and Web Workers--that let you create sophisticated single-page web applications and escape callback hell in the process.

Like other books in this series, You Don't Know JS: Async & Performance dives into trickier parts of the language that many JavaScript programmers simply avoid. Armed with this knowledge, you can become a true JavaScript master.

With this book you will:


Explore old and new JavaScript methods for handling asynchronous programming
Understand how callbacks let third parties control your program's execution
Address the "inversion of control" issue with JavaScript Promises
Use generators to express async flow in a sequential, synchronous-looking fashion
Tackle program-level performance with Web Workers, SIMD, and asm.js
Learn valuable resources and techniques for benchmarking and tuning your expressions and statements

296 pages, Paperback

First published September 25, 2014

186 people are currently reading
1,313 people want to read

About the author

Kyle Simpson

37books355followers
Kyle Simpson is an Open Web Evangelist from Austin, TX, who's passionate about all things JavaScript. He's an author, workshop trainer, tech speaker, and OSS contributor/leader.

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
318 (47%)
4 stars
260 (38%)
3 stars
86 (12%)
2 stars
11 (1%)
1 star
1 (<1%)
Displaying 1 - 30 of 42 reviews
Profile Image for Daniel R..
219 reviews13 followers
June 25, 2015
This book dives deep into various techniques for handling asynchronous operations in JavaScript. In particular the simplicity and drawbacks of callbacks are outlined with suggestions to address them as the cost of added code complexity. The chapter on promises is one of the best that I've read and walks through great examples of chaining and the power of composing. The chapter on generators focuses on modeling asynchronous code in a more synchronous manner. I was unconvinced and found the code examples hard to follow or reason about. The chapter briefly mentions the proposed ES7 async/await syntax which makes more sense to me and can be used today with the Babel transpiler. The final two chapters on performance and benchmarking felt like blog posts primarily linking to other resources and best practices. The callbacks and promises chapters are must reads while most of the rest can be skipped and definitely ignore the author's ubiquitous self promotion of his asynquence library.
Profile Image for Tareef Mando.
134 reviews364 followers
April 28, 2020
الكتاب الرابع من سلسلة أنت لا تعرف جافاسكربت. وأظنه أصعب الكتب أو أكثرها غوصًا في التفاصيل التقنية.

الفصل الأول يعرض الفرق بين التنفيذ المتزامن، غير المتزامن، والتنفيذ المتواقت للكود في جافاسكربت. وأقصد بها على الترتيب:

Synchrony, Asynchrony, Concurrency.

الفصل الثاني يتحدث عن أقدم أساليب كتابة الكود غير المتزامن وهي دوال الردود Callbacks
ويتوسع في شرح مشاكل ومساؤى هذا الأسلوب.

الفصل الثالث يتحدث عن دوال الوعود في جافاسكرتب Promises
وهي تحل كافة مشاكل دوال الردود في كتابة كود غير متزامن. وأهمها معكوسية التحكّم والموثوقية.

الفصول الثلاثة الأولى مفيدة للغاية، وأنصح بقرائتها لجميع المبرمجين. مع بداية الفصل الرابع وحديثه عن دوال المولدات Generators
تبدأ التفاصيل التقنية الدقيقة والحديث المتشعب. هناك إشارة عابرة إلى دوال async/await
بحكم القدم النسبي للكتاب رغم أنها أحدث الدوال الأكثر شيوعًا وسهولة للاستخدام اليوم في تأليف كود غير متزامن.

الفصل الخامس والسادس مخصص للحديث عن كيفية قياس أداء البرامج ونصائح وأدوات متعلقة بذلك. الملحقين الأول والثاني لم أستطع إكمالهما حقًا وهي متعلقة بشرح مكتبة من تأليف الكاتب نفسه تُدعى asynquence

وسيكون لي وقفة لاحقة معها في قراءة ثانية للكتاب لاحقًا. إن وجدت لذلك فائدة مرجوة
Profile Image for Vlad Ardelean.
155 reviews33 followers
December 24, 2018
Quite technical, not at all light, very interesting read. Although understanding promises and generators is quite handy, the last part about advanced patterns is one of those things that I'm not sure when I'll end up using.

Still, while I personally appreciate knowing stuff, without worrying too much about when I'll find that knowledge useful, some more pragmatic folks will probably skip those parts (apendixes).

The chapter about promises is a little too preachy, promising that they will save us from callbacks...only to in the end, get to creating code that requires maybe a little too much mind bending.

Also, now it's december 2018. The async/await keywords made it to the language (maybe?...not sure..I write python most of the time). Many of the patterns in the book would be obsoleted by these new keywords. Those make async code look waaay more sync. Somehow I already met the async/await keywords in python and took them for granted. Without those, the world is a very dark place indeed, as illustrated by the many patterns and "workarounds" in this book.

All in all, if you appreciate perspective on promises and generators, this is a good book, though a little outdated.

O yeah, there is a random chapter here about performance... it was ok, but what's up with that? It was probably worth writing another book on that (maybe even shorter), but the author maybe wasn't in the mood for so much research. I can't blame the guy, there is a lot of information in the books in this series, after 6 books, the guy is exhausted :p (or maybe the publisher didn't approve? Dunno, but the chapter was random. He could have written about the performance of async operations I guess, but that was not the case :p

Good book!
Discard the preachiness, and you'll learn lots of things
Profile Image for Ilya Ivanov.
25 reviews9 followers
September 20, 2016
I have never imagined that there are so many concerns not with callbacks, but regarding promises as well.

Wonderful book on handling async requests via callbacks, promises and handling them via generators. Kyle looks ahead a bit into ES7 async\await features.

Last two chapters cover web performance, from general topics: Web Workers, SIMD, asm.js, to very specific ones: benchmarking pieces of js code, figuring out crucial path. I will definitely take a look at


Profile Image for Eder Sanchez.
56 reviews6 followers
September 2, 2016
La primera mitad se puede saltar si se entiende bien como funcionan las promesas, la segunda se pone mas interesante con los generadores y performance.
Profile Image for Sathish Paul.
3 reviews
August 9, 2017
A fantastic exploration of what "async" means in the context of JavaScript. I was amazed at the depth of explanation provided especially for the Promises chapter. It is a gold mine in my opinion, one that I expect to be returning to again and again.

The author's take on Generators is pretty interesting. Though I must confess, after a while, it started going a little above my head. This only means that the text is dense and needs re-reading. This also makes me think how much of this can I apply in my day-job. Considering the goal of keep code readable/simple, I am not very sure I will be using Generators anytime soon. Async/await looks fantastic and will certainly be useful in Node.js based environments.

I expect Promises to be the bread and butter of all async code that I write, at least for the next year or so. I am grateful to Kyle for the fantastic content he has provided in this area.

Overall a good read, something that makes you mildly uncomfortable, but just enough so you keep pressing into more of the language.
Profile Image for Helen.
422 reviews99 followers
October 5, 2018
Clear and easy to understand, this has helped me make sense of the often murky world of promises and generators.

It's very information dense but I found it easier to get to grips with by reading through a chapter and then going back and trying out the supplied code for myself.

The performance chapters didn't feel as in-depth as the rest of the book but they did cover a few little things that the JavaScript engine will do to your code without you knowing (eg unrolling recursion for you if it thinks a loop will run faster) and things that you shouldn't spend time worrying about (--x or x--). They also went into how to use (and not use) benchmarking tests for checking your own code.

I must admit I got a bit lost on the last appendix - advanced async patterns - but I think that's because I haven't had much real-life practice of the basics yet.

This book has massively improved my understanding and use of async JavaScript code. It's one that I will be adding to the limited collection I keep on my desk.
Profile Image for Hưng Đặng.
128 reviews68 followers
March 4, 2019
The most interesting thing today is that I got one question in my interview about Promise and it was covered in this book.
A few things from the top of my mind:
1. Callbacks are no good, use them sometimes and avoiding nest them. For many async task, try using Promise.
2. Promise tends to swallow errors so use it with async/await
3. Optimization my code is more complicated than other devs suggest. Using jsperf.com or benchmarkjs to test my optimzation.
There are more to this book that I have yet put into my mind but I don't have any plan to reread this one in foreseeable future.
The appendixes are about the author library asynquence which I guiltily skipped since I don't have any intention to take a loot at it. For the 2 months, I think I will just focus on Promise and async/await function. Btw sorry generator function for misunderstanding you. You are the precursor for the new async/await (since 2014 I guess)
Profile Image for Jon Jones.
88 reviews1 follower
December 25, 2019
Every book in this series is a must-read for a Javascript dev. This one does not fail to deliver. The reason I choose to read this book is to learn more about how aysnc works in JS. I never really mentally grasped ASYNC with full confidence even though I've been using it for over 10 years. I would need to google the best approach for addressing deadlocks or race conditions.

This book definitely helped gave me a much fuller understanding of async. All the issues with callback, not just callback hell... why generators are good. Some subtle nuances with promises I had never considered before.

You should read this book because it is asy to read and understand. It covers the fundamentals so you will understand and you can design async solutions with a lot more confidence
Profile Image for Divan Visagie.
4 reviews1 follower
March 30, 2020
This is the worst book I have read in my life so far.

It's about 5 times more verbose than it needs to be, making it clear that the entire series actually could have been a single book rather than a series... but gotta make bank right?

Besides the verbosity the author jumps back and fourth referencing both past and future chapters as well as repeating concepts over and over and over... The chapter on promises alone spans around 70 pages and could have honestly been compacted to about 20 or less.

This book is a waste of time and money, god I even blocked the author on Twitter just so that I never have to ever read another word from him again. Every minute was torture and I'm glad it's over.
19 reviews
Read
September 2, 2020
This one seemed to me not as useful as previous ones from the series. But, still, it's rather useful. It contains a great explanation about what Promises is and why they were included in js. But apart from it, the book contains chapters about topics related to concurrency itself but not to JavaScript itself. I didn't find it useful, since I am quite familiar with the concept.

Also, the book contains a chapter about Generators and I must confess I didn't get it. It's not clear what problems they solve and why I need them.

To conclude, my advice is to read the first three chapters of the book. The others you can read on your own risk)
Profile Image for Carlos Garcia.
36 reviews3 followers
July 7, 2021
El más complejo de la serie sin duda. Tuve que regresar a él unas tres veces porque estoy tonto para entender bien el concepto de programación asíncrona. Al final se cumple el principio de que la programación solo se aprende practicando, y después de algunas horas experimentando con promesas, pude terminar el libro.

Al ser una edición vieja, ya hay tecnologías que facilitan mucho las tareas que el libro propone. Sin embargo, la raíz de los conceptos sigue siendo la misma, y la manera en que son explicados aquí son lo que puede aportar valor a cualquier programador que le dé una checada.
Profile Image for Hatem.
21 reviews1 follower
May 9, 2019
Amazing book if you want to understand how asynchronicity (or the illusion of asynchronicity) in JavaScript works. Kyle has a unique way of explaining deep technical CS concepts in a simple and straightforward manner. He lays down the differences between concurrency, serialism and parallelism and then use those differences to explain the JS Event loop and then goes into the technicalities of implementation using callbacks, promises, and generators. Finally, he gives some overview of assessing performance and benchmarking.
10 reviews
December 14, 2018
I really liked building an understanding for promises and async/await in javascript. One thing that I had never seen before was generators which is the underlying magic behind asynchronous programming in javascript. It was cool to understand that better. The performance aspect of the book could have been more fulfilling but I guess if you're using javascript you probably don't care that much about performance anyway.
29 reviews1 follower
December 7, 2019
This whole series is awesome. Having read several JS books, it was nice to have a really comprehensive technical treatment on these topics. These books read really well, and somehow manage to be engaging at the same time as being very thorough.

One thing I really like about this book, is that since it is open-sourced and available on GitHub, I can easily reference it when any questions come up about these topics.
52 reviews
April 5, 2020
Callbacks, promises and generators. All things asynchronous. No reservations about the quality, but it was a bit boring. Among the books from the YDKJS series by Simpson, even though async operations is are hugely important in frontend programming, this one I liked probably the least and likely will not return to it and will use other resources for this topic. I skipped the addendums about asynquence library authored by Simpson, because it did not seem relevant anymore.
Profile Image for Prakash.
154 reviews88 followers
December 23, 2017
The last chapter on performance is a complete dud which could be summarized in a single paragraph. Some of the chapters are overtly long but still exhaustive so 4 stars unless I find a better book on this topic.
Profile Image for Toros Yesja.
145 reviews20 followers
August 9, 2018
The first appendix was unnecessary (perhaps the second one as well), the Promise's chapter did get repetitive (but it was still good), and I wish he had gone deeper into performance. Still not a bad book though, worth reading.
Profile Image for Emily Owaki.
83 reviews1 follower
February 12, 2019
This book ended up more low level than I had expected. Coming in without much of an understanding of generators and async/await, I ended up having to consult outside sources more than I'd have liked, just to be able to follow along with what the writer was talking about.
Profile Image for Shivam Mamgain.
8 reviews
February 24, 2019
All the books in the series are quite verbose - over-explanation with analogies doesn't always make it easy to understand concepts. "Async & Performace" title doesn't get concurrency and parallelism right. Rest, it does do a good job of explaining JS's quirkiness.
Profile Image for Alexander.
64 reviews22 followers
March 30, 2018
I don't know why I didn't read this book earlier, for weeks I've been lost with all the "Async-Await" tech talks and now this book, eloquently written offers a clear and consice explanation.
Profile Image for Dmytro Chasovskyi.
89 reviews
June 20, 2018
The book itself is good. The only the part I didn't like was about the asyncquence library. I felt it was out of the scope of JavaScript core features. Apart from this book is amazing.
Profile Image for David.
43 reviews4 followers
August 15, 2018
One of the best resources for learning the ins and outs of JS asynchronous programming and Promises. Some really great insight about JS performance and benchmarking too!
Profile Image for Eduardo Vedes.
9 reviews
March 2, 2019
The best book about javascript I've read in which concerns to async and performance! Learned a lot of new things I didn't know and didn't find in another place.
Profile Image for Julian.
13 reviews
August 7, 2019
I mean, this series of the books are MUST READ for the engineers that want to feel strong in JS world.
Profile Image for Vibhor Rawal.
49 reviews7 followers
January 8, 2022
I've fallen in love with JS :3
Amazing writeup, chapter on generators felt a little boring, but I guess it's on me since I haven't worked on it yet
Displaying 1 - 30 of 42 reviews

Can't find what you're looking for?

Get help and learn more about the design.