You are reading a single comment by @AkosLukacs and its replies. Click here to read the full conversation.
  • why is it a poison for kids? some language supports the wait function, why limit event based javascript to the mind of a kid?
    it is all about the interpreter

    also with ES7 it can support async and await, is it really a poison?

  • The poison part meant to be slight joke.
    In most languages a delay / wait literally waits at that point, and nothing else can happen simultaneously. This leads to locked-up UIs & CPUs sitting and waiting later. More and more languages include some form of async-await, or already have Future / Promise / Task to help avoid blocking code and callback hell.

    If you do that with async-await, it won't block the CPU, it 's just a state machine, that gives the illusion of "sync" code. While allowing the CPU can do whatever it wants. Execute other code, or go to sleep to save energy.

    Ok, that's really far from a kid just learning programming, and I have no experience teaching kids. So you are right, it should be as simple as possible.
    If someone has never seen programming, I guess the concept of a while loop is something new as well.
    Can you get to the same end result with run code every X seconds block?
    For example: can you easily blink 2 LEDs at different frequency? Have never played with Blockly & Espruino, but I think that would need two "timer" blocks, and pretty much done. It would be much difficult in a while loop.
    For interaction (UIs with buttons & leds, or some external chip) an event-driven approach feels better. Honestly, don't know which one would be more easier for kids to grasp. I started with Pascal & C in the school, for and while loops, etc. Those languages don't support async. But what if a kid can start with a language that has async support?

About

Avatar for AkosLukacs @AkosLukacs started