No, he can’t fly. He is single-threaded. While other kids are multi-threaded.
When normal kids want to make a hot chocolate and watch a funny show on YouTube, they do it at the same time:
But when our special kid wants to do it, he does it one by one:
The difference is that our kid always waits until some task is done and only after that starts the next one. Other kids perform tasks simultaneously and don’t wait until some task is completed.
The same way single-thread languages are different from multiple-thread languages. One performs only one task at a time. Others can perform them in parallel.
But why single-thread languages, special kids, can’t be normal and perform tasks in parallel?
It's all about how the threads work.
Threads. Slides. Dogs.
In programming, threads are essentially single processes that a program can use to perform tasks. Like a water slide where performing a task is the process of sliding down.
Yes, it's a dog. It represents a task.
Your computer works that way that each thread can execute only one task at a time. And everything else is blocked until an operation completes.
When one dog slides down a water slide, the other dogs have to wait. They can't slide down. Only one dog in a water slide. Only one task at a time in a thread.
But other kids are different.
Thread. Aquapark. Our child has grown up.
Imagine that our special kid grew up and decided to open an aquapark for dogs. But not a normal aquapark. He applied his “single-threaded philosophy of life" to it.
And no matter how hard he tries to imitate multithreading behavior with setTimeout(..., 0) and web workers, he will still remain single-threaded. He will still remain our special kid.
PS: no dogs were harmed in the process of writing this article.
In the end...
And if you like this article you need to know that every Monday, I send a letter to 4,000+ Web Developers with 3 hand-picked articles from the tech world, 2 web development guides, and 1 best Tweet of the week
“Your newsletter is f**king awesome, really Nick. It gives me a great start to the week with a lot of insightful knowledge.”
Join smart developers who get short and full of knowledge letters for free here.