Why Callback order can be Hell
Callbacks are hard to work with. And if you have more than 1 then the ordering gets really complex. Learn about it in this video
Zachary Kessin: If you're a JavaScript developer, you're very familiar with callbacks. Yes, some people started moving towards promises but, they're fundamentally just a wrap around callbacks.
And callbacks are very primitive concurrency system. A problem you may run into is an ordering of callbacks with the global state since pretty much everything in JavaScript uses global state in some way, shape or form. The order in which callbacks execute can be crucial. The problem is if you have N callbacks, you have 2^N orderings. So if you have 10 callbacks, for example, that could execute in an arbitrary order. There are 1,024 possible ways that [inaudible 00:00:47] order and that grows exponentially, so if you add a 11th, if you're having 1,024 you have 2,048.
As you can imagine, those orderings go up real fast. So, it's entirely possible that you could have some issue that pops up in one specific ordering. Now, again, if you have 10 callbacks, you have 1,024 possible orderings so it's possible that, perhaps unlikely but possible, 1,023 of those orderings work fine, and the 1,024th doesn't. Problem is finding it. And that's really hard. There is no good way to do that beyond exhaustively checking everything. And even doing that is hard, because you need to conspire to somehow force them into each unique ordering. This creates to what we refer to as a [Heisenbug 00:01:45] after the Heisenberg uncertainty principle, which states that observing something disrupts its behavior and often putting in observation putting in observation code will disrupt the ordering and fix your bug for you until you take it out.
In Elm, we don't have callbacks. What you have are events. Now, events can still happen in arbitrary order, [inaudible 00:02:09], but since the global state can only change in constrained ways, it makes things much simpler to debug. So callbacks can be very tricky, especially if you make some assumption about which order they will happen in. Because unless you explicitly create the order of them, the order they happen in is effectively random and unpredictable.
Considering using Elm at Work, would you like a free consult https://elmtraining.youcanbook.me/
Edited by Ronnie Zidon https://www.youtube.com/channel/UCIjyilqw76FbAuBcNKYLjKQ
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Why Callback order can be Hell», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.