Earlier quoted context omitted.
I don't get why people hate on starting with JavaScript. Since ES6, JS strikes a really nice balance between practical usage and theoretical value. Like Scheme it's a dynamically typed language focused around a single data structure (list for Scheme, object for JS), with first class functions. Sure, it has weak typing and there's some scoping complexity. But, that's a completely reasonable tradeoff for being one of t…
Because programming should be descriptive to what you want the computer to do , and the way that humans explain things to each other is usually linear. For instance: brush your teeth, then put on your clothes, then get in the car, then start it. The "JavaScript" way to do this is that starting your car is somehow nested inside of the brush your teeth event. Everything is a callback of everything else, so trying to ex…
function first(cb) {
console.log('first');
cb();
}
function second() {
console.log('second');
}
first(second);
can now be expressed as new Promise().then(console.log('first'))
.then(console.log('second');
or async function first() {
console.log('first');
}
async function second() {
console.log('second');
}
async () => {
await first();
await second();
}();
depending on exactly what your goals are. The inversion of order ("callback hell") can be avoided if you stick to modern concepts.