Logo

    Hasty Treat - JavaScript Event Buzzwords — Sync, Concurrent, Defer, Blocking, Workers

    enJuly 05, 2021
    What is the main focus of the Syntax episode?
    How does Century.io assist developers with error tracking?
    What is the difference between synchronous and asynchronous writing?
    What problem does render blocking create for web performance?
    How are concurrent and parallel processing different in JavaScript?

    Podcast Summary

    • JavaScript Buzzwords: Synchronous vs Asynchronous, Multithreaded, Concurrent, Parallel, Consecutive, Waterfall, Callback Blocking, Async, Defer, and LazyUnderstanding JavaScript buzzwords like synchronous, asynchronous, multithreaded, concurrent, parallel, consecutive, waterfall, callback blocking, async, defer, and lazy can improve your web development skills by clarifying how code is executed and processed.

      During this episode of Syntax, Wes, Barracuda, Boss, and Scott, El Toroloco, discussed some JavaScript terms that can be confusing for developers of all levels. They referred to these terms as "buzzwords" or "jargon," and they acknowledged that understanding their meanings can be challenging. The episode was sponsored by two companies: Century.io and FreshBooks. Century.io was praised for its error tracking feature, which allows developers to filter, save, mark as resolved or ignored, and assign errors to specific team members. The team encouraged using the coupon code "tasty treat" for a discount when signing up. FreshBooks was highlighted for its cloud-based accounting solution, which ensures that important information is not lost even if a computer crashes or data is not backed up. FreshBooks offers a 30-day free trial with no credit card required. The team then delved into explaining various JavaScript terms. Synchronous and asynchronous refer to the order in which code is executed. Multithreaded, concurrent, and parallel describe how code is processed. Consecutive and waterfall indicate the sequence of tasks. Callback blocking, async, defer, and lazy are related to how functions are invoked. Overall, the episode aimed to clarify these terms and make web development more accessible for developers.

    • Understanding JavaScript's Synchronous, Asynchronous, and Threading ConceptsJavaScript uses both synchronous and asynchronous processes. Synchronous processes are executed one after another, while asynchronous processes allow multiple tasks to run concurrently. JavaScript has been single-threaded but recent advancements like Web Workers enable handling complex tasks.

      JavaScript uses both synchronous and asynchronous processes to execute code. Synchronous processes are executed one after another, with each step completing before the next one begins. This is like doing tasks one at a time, where you finish one before starting the next. Asynchronous processes, on the other hand, allow multiple tasks to run concurrently. This is like doing multiple things at once, such as listening to music, preparing an email, and watching a YouTube video. Most JavaScript operations are asynchronous, but developers can use tools like callbacks or the await keyword to make asynchronous functions behave synchronously for better flow control. Another important concept is threads, which deal with how the CPU processes information. Multithreaded languages allow you to spin off parallel processes, enabling multiple tasks to run at the same time. However, JavaScript has been single-threaded for a long time, meaning that there is only one main thread. This was also the case for web browsers, where each tab ran on the same thread. This single-threaded nature of JavaScript can make it challenging for handling complex tasks, but recent advancements, such as Web Workers, have started to change that. Understanding the difference between synchronous, asynchronous, and threads is crucial for effective JavaScript development. By knowing when to use each, you can write more efficient and performant code.

    • Understanding JavaScript's one process and blocking conceptsOne process per tab system improves browser performance, while blocking can negatively impact it. JavaScript's non-blocking nature makes it suitable for server-side apps, and render blocking can slow down page loading. Placing script tags near the closing body tag helps mitigate render blocking.

      The evolution of modern browsers led to the implementation of a one process or one thread per tab system, which improved browser performance by preventing one tab from monopolizing system resources. This concept is essential in understanding how JavaScript handles multithreading through web workers. Web workers enable background processing, allowing the page to remain responsive even during heavy computations. Another crucial concept is the idea of blocking in JavaScript. Blocking refers to the halting of other page elements from running, which can negatively impact page performance and user experience. Most JavaScript operations are non-blocking, making it an attractive choice for creating server-side applications. Render blocking is a specific type of blocking that occurs when a script tag is placed in the head of an HTML document. This practice can prevent the page's content from being downloaded and parsed, resulting in a slower loading time for the user. To mitigate this issue, developers often place script tags just before the closing body tag. In summary, understanding the one process per tab system and the concept of blocking in JavaScript is essential for optimizing web application performance and delivering an enjoyable user experience.

    • Understanding synchronous vs asynchronous file writing in Node.jsSynchronous file writing blocks the rest of the code, potentially slowing down the server. Asynchronous file writing allows the rest of the code to continue running while the file is being written in the background. JavaScript is concurrent by nature, handling multiple tasks concurrently but processing them sequentially.

      JavaScript's fs.writeFile function can be synchronous or asynchronous. Synchronous writing blocks the rest of the code from executing until the file is written, which could potentially slow down your server if dealing with large files or numerous requests. Asynchronous writing, on the other hand, allows the rest of the code to continue running while the file is being written in the background. Another important concept discussed was the difference between concurrent and parallel. Using a sandwich shop metaphor, concurrent is like having one line for customers where they serve one person at a time, while parallel is having separate lines for different tasks to be executed simultaneously. JavaScript is concurrent by nature, meaning it can start and stop tasks concurrently, but the actual processing happens sequentially. Understanding these concepts can help improve the performance and efficiency of your JavaScript applications.

    • Understanding Concurrent and Consecutive Processing in Asynchronous FunctionsConcurrent processes run at the same time and handle in order of return, while consecutive processes complete one before the other. Both can be synchronous or asynchronous. Callbacks, an older method, can lead to complex flow control issues known as 'callback hell' and are less commonly used in favor of promises and async/await.

      There are different ways to handle asynchronous functions in programming, and two common methods are concurrent and consecutive. Concurrent processes are executed at the same time but are handled in the order they return. This is different from consecutive or waterfall processes, where one process is completed before the next one begins. Both methods can be asynchronous or synchronous. Callbacks, a third method, are functions that execute after other functions have finished. They were popular before the widespread use of promises and async/await, but they can still be found in older code and in certain use cases like streaming data or APIs. While callbacks are not deprecated, they are less commonly used due to issues with complex flow control, which is known as "callback hell." Instead, modern programming favors promises and async/await for handling asynchronous functions.

    • Managing Asynchronous Tasks with Bluebird Q and Sync JSBluebird Q manages concurrent tasks with promises, improving readability over callbacks. Sync JS simplifies asynchronous code with synchronous promises, making it more intuitive for complex tasks.

      Both Bluebird Q and sync JS libraries are useful for managing asynchronous tasks in JavaScript, but they serve different purposes. Bluebird Q, which is based on promises, allows running a specified number of tasks concurrently and automatically picking the next task once the previous one is completed. It's an improvement over callbacks as it eliminates the need for nested callbacks and makes the code more readable. However, with the advent of async/await, Bluebird Q is less frequently used. On the other hand, sync JS is a library that uses synchronous promises, allowing developers to write asynchronous code as if it were synchronous. This approach simplifies the code and makes it more intuitive, especially for complex tasks involving multiple asynchronous operations. Another important topic discussed was the script tag async attribute. When using this attribute, the browser waits until the entire page is loaded before executing the script. This is beneficial for scripts that don't need to be executed immediately, as it ensures that the page loads first and doesn't get blocked by the script. Overall, understanding these libraries and their use cases can help developers write more efficient and effective JavaScript code.

    • Impact of async and defer on script loadingAsync scripts load and execute after HTML, while defer scripts download and run after HTML loading. Defer is useful when waiting for specific DOM elements, and scripts in the head can impact page load times. Google Analytics uses an async script and lazy loading is another technique to improve page load times.

      Both async and defer attributes in script tags have different impacts on how scripts are loaded in the browser. Async scripts are downloaded and executed once they finish loading, while defer scripts are downloaded but wait until the entire HTML is loaded before they run. Defer is often preferred when you need to wait for specific DOM elements to be present before running the script. Additionally, scripts in the head or header can block page loading, so it's important to be careful with their order. Google Analytics, for example, uses an async script that doesn't block page loading but doesn't wait for DOM content to load either. Instead, it uses a data layer array to store data before being loaded. Lazy loading is another technique to load scripts or other resources later, improving page load times.

    • Delay loading of heavy contentLazy loading improves website performance and user experience by delaying the loading of non-essential content, such as images or JavaScript components, until they are needed.

      Lazy loading is a technique used to delay the loading of heavy or non-essential content, such as images or JavaScript components, until they are needed by the user. This helps to improve website performance and user experience by reducing the amount of data that needs to be loaded initially. Lazy loading is particularly useful for media-heavy or JavaScript-heavy websites, where large files could otherwise slow down the page load time. Apple is an example of a company that effectively uses lazy loading to deliver rich media and functionality without blocking the entire website during loading. By prioritizing the minimum necessary content for initial page load and then loading additional content as needed, websites can provide a faster and more seamless user experience.

    Recent Episodes from Syntax - Tasty Web Development Treats

    821: Is Tauri the Electron Killer?

    821: Is Tauri the Electron Killer?

    In this episode of Syntax, Wes and Scott talk with Daniel Thompson-Yvetot about Tauri. They dive into what Tauri is, the motivations behind its development, its open-source ecosystem, use cases, and more.

    Show Notes

    Links

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    820: Potluck: 8000 ESLint Errors × HTML Time Tag × 7 Meg React Bundle × CSS Modules

    820: Potluck: 8000 ESLint Errors × HTML Time Tag × 7 Meg React Bundle × CSS Modules

    In this Potluck episode of Syntax, Scott and Wes answer your questions, from weighing the trade-offs between numerous small npm packages and a few larger ones to managing the challenges of work-from-home life. They also explore CSS modules, strategies for shrinking JavaScript bundles, and even where to find the best replacement ear cups for your headphones.

    Show Notes

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    819: Fun & Profitable Side Projects for Developers

    819: Fun & Profitable Side Projects for Developers

    Scott and Wes serve up a hasty discussion on side projects, sharing their latest Hack Week experiments and tips on how to turn fun ideas into profitable ventures. They cover everything from finding inspiration to choosing the right tech, and even offer advice on how to finish what you start.

    Show Notes

    • 00:00 Welcome to Syntax!
    • 01:11 Brought to you by Sentry.io.
    • 01:27 Wes’ Hack Week project.
    • 02:30 Scott’s Hack Week project.
    • 04:18 Where do you get ideas for side projects?
    • 09:22 End goals for a side project.
    • 14:47 Other end goals.
    • 16:45 What tech should you use?
    • 20:34 Keeping notes.
    • 23:14 Finishing side projects.
    • 26:39 Shameless Plugisode!

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    818: CJ × Hosting Meetups - Lunch and Learn

    818: CJ × Hosting Meetups - Lunch and Learn

    In this episode of Syntax, Wes and Scott talk with CJ Reynolds about the resurgence of meetups in a post-COVID world. They discuss the benefits of attending and speaking at meetups, and the logistics of organizing them. CJ also shares his experiences running the DenverScript meetup, including sourcing speakers, finding venues, and ensuring a welcoming community.

    Show Notes

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    817: You Need These 30 Apps - PART 1

    817: You Need These 30 Apps - PART 1

    Scott and Wes kick off part 1 of a 2-part series, breaking down 30 must-have apps for web developers and productivity enthusiasts. From file management tools to media utilities, they cover everything you need to supercharge your workflow.

    Show Notes

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    816: Why Your CSS Sucks

    816: Why Your CSS Sucks

    Scott and Wes break down why your CSS might suck—from misusing specificity to not leveraging CSS variables. Tune in as they dive into common pitfalls that are making your stylesheets a hot mess.

    Show Notes

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    815: Deno 2 with Ryan Dahl

    815: Deno 2 with Ryan Dahl

    In this episode of Syntax, Wes and Scott talk with Ryan Dahl about Deno 2.0, its new features and use of web standards, and how it seamlessly integrates with popular frameworks like Next.js. Ryan shares insights on the motivations behind Deno’s creation, its emphasis on simplicity and security, and offers his take on the evolving JavaScript ecosystem.

    Show Notes

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    814: Fundamentals: HTML

    814: Fundamentals: HTML

    In this episode of Syntax, Wes and Scott talk about HTML fundamentals — from basic structure and semantics to practical tips for better accessibility and SEO. They also discuss the difference between block and inline elements, form functionalities, HTML5 elements like dialog and canvas, and more.

    Show Notes

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    813: CSS: Scroll Driven Animations

    813: CSS: Scroll Driven Animations

    In this episode of Syntax, Wes and Scott talk about CSS’ new scroll-driven animations, its implementation, uses, and potential pitfalls. They also discuss animation-timeline and animation-range, and how they can be utilized to control animations based on scroll positions.

    Show Notes

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    812: CSS 4, 5, and 6! With Google’s Una and Adam

    812: CSS 4, 5, and 6! With Google’s Una and Adam

    In this episode of Syntax, Wes and Scott talk with Una Kravetz and Adam Argyle from Google Chrome about the evolution of CSS, new features, and the push toward more advanced UI capabilities on the web. They discuss the introduction of CSS versioning, exciting new properties like text-box-trim, state queries, and scroll state functionalities, select, and more!

    Show Notes

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    Related Episodes

    120 Async TDD & Other Pyramids of Doom

    120 Async TDD & Other Pyramids of Doom

    Justin Searls chats with us on testing Asynchronous JavaScript as well as best practices for Continuous Integration, Unit testing vs. Integration testing, and tools we can use to help us understand how to test code.

    Resources


    Guests


    Panel

    #010: Out of order and ensuring delivery in the asynchronous communication

    #010: Out of order and ensuring delivery in the asynchronous communication

    ABOUT THE EPISODE

    This episode follows up on the subject of challenges in asynchronous communication which was started in episode #009 🧵.  Join us for another journey into the depths of this domain!

    TOPICS COVERED

    In episode #010, in which we dug deeper into the ground of Asynchronous Communication, talking about:

    🔢 How we can deal with "out of order" processing? Is it the responsibility of the transport layer only?

    📬 How to ensure the message delivery? What strategies are used by message brokers to give us some guarantees? How does using those strategies affects a producer and a consumer code?

    ⏱ Using Asynchronous Communication in long-running business processes and how to make it blend into the synchronous APIs environment?

    That's not all the concerns one needs to consider when implementing Asynchronous Communication. We intend to follow up on this in future!

    TIMELINE

    00:00:00 - Intro
    00:01:37 - Our last 2 weeks
    00:07:37 - The problem of ordering in async communication
    00:10:06 - Issues with ordering comming from the producer
    00:11:20 - Competing consumers as source of ordering problems
    00:14:03 - Tackling the concurrency issues on the entity level
    00:22:13 - Ordering in queues vs event streams
    00:25:55 - Ensuring delivery
    00:36:05 - Idempotency in the asynchronous communication
    00:42:26 - Long running processes
    00:51:08 - Importance of requestId/correlationId
    00:53:15 - Wrap up

    CONTACT US / COLLABORATION

    If you:
    - want to send us your valuable feedback
    - you would like to appear on the show as a guest
    - you would like to help out the show to grow
    - you would like to sponsor the show

    Then please contact us via: podcast@artistryofcode.com

    You can also check out our website: https://artistryofcode.com

    FOLLOW US ON SOCIAL MEDIA

    Podcast Social Accounts
    Facebook: https://www.facebook.com/ArtistryOfCode
    Twitter: https://twitter.com/ArtistryOfCode
    LinkedIn: https://www.linkedin.com/company/artistry-of-code
    Reddit: https://www.reddit.com/r/ArtistryOfCode/

    Grzegorz Godlewski
    LinkedIn: https://www.linkedin.com/in/ggodlewski/
    Twitter: https://twitter.com/GGodlewski

    Marek Urbanowicz
    LinkedIn: https://www.linkedin.com/in/marek-urbanowicz-0ba65254/
    Twitter: https://twitter.com/UrbanowiczDev

    Artur Wolny
    LinkedIn: https://www.linkedin.com/in/artur-wolny-35150664/

    TPDP029: Asynchronous JavaScript Development

    TPDP029: Asynchronous JavaScript Development
    In this episode I'm joined by Corbin Crutchley, a seasoned JavaScript developer with extensive knowledge of various frameworks such as Vue.js, Angular, and React.js. Corbin also operates his own development blog, Unicorn Utterances. The topic of this episode is around asynchronous development using JavaScript and no particular framework. If you're coming from other programming languages, the concept of promises, callbacks, async / await, and similar all might seem daunting when it comes to working with remote web services or even resource intensive proccesses. Corbin and I shed some light into the world of doing things asynchronously and hopefully clear things up and even make the concepts easier to wrap your head around. A brief writetup to this episode can be found via https://www.thepolyglotdeveloper.com/2019/07/tpdp-e29-asynchronous-javascript-development/

    Explained - Buzz Words and Concepts

    Explained - Buzz Words and Concepts

    In this Hasty Treat, Scott and Wes explain more buzz words like schema, promises, async, sync, dom vs shadow dom vs page HTML, props, and more.

    Appwrite - Sponsor

    Appwrite is a self-hosted backend-as-a-service platform that provides developers with all the core APIs required to build any application. Get free cloud credits by signing up for early access to the Appwrite Cloud launch.

    Sanity - Sponsor

    Sanity.io is a real-time headless CMS with a fully customizable Content Studio built in React. Get a Sanity powered site up and running in minutes at sanity.io/create. Get an awesome supercharged free developer plan on sanity.io/syntax.

    Show Notes

    Tweet us your tasty treats