What the… JavaScript?




Kyle Simpsons talk for Forward 2 attempts to “pull out the crazy” from JavaScript. He wants to help you produce cleaner, more elegant, more readable code, then inspire people to contribute to the open source community.

JavaScript Training from NewCircle: http://crcl.to/72rru

http://forwardjs.com/

Original source


33 responses to “What the… JavaScript?”

  1. Great video, it actually helps me like JavaScript, you have a good way of presenting the counter intuitive design of these various statements. Thanks also for your contribution to GNU-Linux and opensource. Peace among men of goodwill.

  2. 27:03 I just tested this in the console in Chrome v56 and the behavior is different from what Kyle shows here. For me, it.next(25) resumes the generator and logs out "c:25", then returns {value: 7, done: true}. So is falling out of the finally clause 'fixed' now? Or is this ES7 behavior or something else? wtf js?

  3. Am I the only one who thinks semicolons where a good idea in 1980 but a step backwards nowadays. I really liked the ECMAScript standarization made them optional and I encourage everyone to stop using them (except, of course, on minified code). Don't know why virtually every open source js project still uses semicolons. Am I really the only one who is desperate from dropping them out of every language??

  4. I am disappointed, most of the WTFs that seem to tick him off are not WTFs at all, especially after the middle of the video where it was supposed to actually get "crazy". Destructuring order of names is key:alias and makes total sense, especially when you apply it to deeper structures – the json syntax stays on the right side. Temporal dead zone is a WTF name but it is completely logical. Yes it is inconsistent with the old approach, but that is on purpose. Why would we even want a new way of declaring variables if it worked just like the old way? The goal is to phase out var and only have let in the future, and the transition period can seem like a WTF but it is needed.
    The "default" case falling through is completely natural and consistent. Missing "return" in a finally not meaning "return undefined" – completely natural. Breaking out of a "finally" block – yeah it's odd and can get messy, perhaps it is a WTF that it is allowed. But once you accept it is allowed at all, the way it works is completely natural and consistent, even in generators.
    Speaking of generators, in older versions of the spec you had to catch an exception to know when the generator was over, which was a huge WTF. But now there are some other WTFs left, like the redundant star syntax in declaring them – presence of yield is a sufficient indicator; or the fact that they start in a paused state, which is completely pointless, and makes the parameter of the first resume call meaningless; or the fact that they went with the half-hearted single-stack-level generators which greatly hampers their use in lambas in forEach or map and such, when they could have gone the full monty with lua-like coroutines able to yield across multiple stack levels.
    There are even bigger WTFs in JS that I expected to be mentioned: the still half-assed attempt at meta-programming, i.e. Proxy class or prototype chain mutation as specific examples, but more generally just being constantly countered by other language developments like pointless access control on properties, static analysis and performance optimization in engines, etc; the ability to override String and Number coercion but not Boolean coercion, leading to impossibility of falsey objects; the inability to make a function-like callable object (except with the mentioned lame Proxy class); native Promise performance; the async/await syntactic sugar they plan in the next version (which sucks because it's based on generators with single-stack-level limitation);

  5. it's a fun video about "WTF JS"… but, let be serious a moment, nobody code some things like that… or you're can"t distinguish you fantasms and your work or passion… if you code like that, you're an asshole or a fuckin' troll !

  6. I thought this is about "what is JavaScript " When I saw and heard him for 10 seconds I knew he was one of those. Too advanced for me. He didn't even start by explaining what JavaScript is?  All I see is,  WTF, WTF, WTF, etc.

  7. There is a good reason why destructuring is done that way. Look at this example:
    function foo() {
    return { foo: { x: 1, y: 2 } };
    }
    var { foo: { x, y } } = foo();
    If we reverse alias/value we would get something weird like this:
    var { { x, y } : foo } = foo();
    That that would be real WTF.
    The syntax is not only fine, but great. You can think this way: the left side must have same structure as returned object, but with variables instead of values.

  8. Switch/default makes perfect sense and here's an example where it's useful:
    switch (value) {
    default:
    // fallback to default option and log warning
    console.warn('This should not happen');
    case 'A':
    // do something
    break;
    case 'B':
    // do something else
    break;
    }

  9. 15:19 line 4, I think String([undefined]); is treated as an undefined array entry, so stringifying it would assume that the array entry would be returned. And it would not print whats undefined in the array when printing the entry or entries. Am I way off??? Or even making sense

  10. Is it a good idea for a language to "try to make a best guess?" To me, that is one of the reasons why there's so much effort to make JS more rigid. We would rather have errors than best guesses. It makes sense when you think of the context of what JS was meant to do a long time ago, but not as much today. Especially now that people want to write JS for servers and desktops.

Leave a Reply