7 ms·
For those unfamiliar, Gary Bernhardt is the same guy who did the famous "Wat" talk on JavaScript: https://www.destroyallsoftware.com/talks/wat https://www.dest
by jliechti1 13y ago
For those unfamiliar, Gary Bernhardt is the same guy who did the famous "Wat" talk on JavaScript:
https://www.destroyallsoftware.com/talks/wat https://www.destroyallsoftware.com/talks/wat
- Yhippa 13y agoThat was really funny. First time I've laughed all day. Thanks for sharing.
- fuzzythinker 13y agoFunniest tech video I've seen! Actually maybe even minus the "tech".
- vor_ 13y agoClassic video, though it's wrong at times. For instance, the audience member who corrected him was right.
- robert-boehnke 13y agocouldn't quite make it out, what did he correct?
- vor_ 13y agoThe second JavaScript example, when he told someone in the audience, "No, that's just an object." It was a string.
- gary_bernhardt 13y agoI knew that it was a string. If you listen closely, you'll hear that he asked "is that an array of object?" He probably asked that because it's in square brackets. I said "No, it's just an object". I've probably seen twenty people call this "wrong", which frustrates me. It's not wrong. It was a stringified object! I didn't say "stringified" because it wasn't relevant to the question of whether the object was in an array! There are other things in Wat that are genuinely wrong, though, like the fencepost error about "16 commas", which mistake will haunt me forever.
- saraid216 13y agoMaybe worth releasing a transcript, at this point?
- hetid 13y agoIt's only 15 commas man, 15 commas. That extra comma could kill someone. Speaking of which, why does WAT do different things on node.js?
- Turing_Machine 13y ago"That extra comma could kill someone." Only in old versions of Internet Explorer.
- espadrine 13y ago> why does WAT do different things on node.js? Wrapping the same input in parenthesis (eg, '({} + [])') yields different results.
- calibwam 13y agoIt is wrong because it is the toString of Object, because the + operator wants to do string concatenation. You were misleading the audience, both by using a shell which doesn't show strings with quotes, and saying that the toString of the object is 'just an object'. And that is not the only thing that is misleading, as you clealy said that {} was an object. Yes, the syntax in js is weird as it looks like an object, but it isn't. Again, a better shell would not let you do this.
- nilliams 13y agoAs gary explained he wasn't wrong in his response to the question because the audience member was asking whether [object Object] means the object is in an array. It doesn't. The string point is moot. I do agree the {} + [] example has always felt a bit unfair to me (for the reason that {} is a block), but whatever, it's a light-hearted talk.
- hazelnut 13y agoBrilliant - everbody working with JavaScript should watch this!
- liviu 13y agoBrendan Eich covered this subject at O'Reilly Fluent conference in 2012: http://youtu.be/Rj49rmc01Hs?t=5m7s http://youtu.be/Rj49rmc01Hs?t=5m7s
- MichaelGG 13y agoIf by cover you mean he essentially shrugs and says "it was the 90s" and moves on to ES6.
- skrebbel 13y agoWhich seems a pretty appropriate reaction, no? :-)
- 1stop 13y agoSeems he took the Wat talk a little personally, but I'm not sure why he defends {} + [] by saying the first { is a statement... wat?
- _mhr_ 13y agoIt's automating semicolon insertion. The browser translates {} + [] into {}; + [], so + [] === 0 too. {}; is undefined.
- codeflo 13y agoBeing pedantic: it's NOT semicolon insertion. Your actual point is correct, the {} is an empty block statement, and the +[] is a separate expression statement. It's equivalent to "{} 0". However, semicolon insertion is only triggered when there's a newline at a position where there would otherwise be a syntax error. Here, neither is the case: blocks don't have to be terminated by semicolon (so no syntax error), and there's no newline in the source code!
- drostie 13y agoIt's because they wanted to say both: if (a) b; and if (a) { b; c; } which tends to make you think of curly braces as a syntactic feature which can appear anywhere, turning many lines of code into one line of code. If you think that way then these should possibly also be valid: {b; c} {b} {} but, since JS scope is function-oriented and in other places (e.g. functions) the braces are ultimately needed anyways, even for one-liners, it seems like this was a stupid choice and we should have just rejected the form: if (a) b; and then the reuse of {} for lightweight (if non-robust) hashmaps would perhaps be unambiguous again.
- kevinwang 13y agoThe video seems to be down now? Anyone have a mirror? edit: nevermind, I clicked the download link. But I'm still wondering why the video's unplayable on the site.
- thousande 13y agoWorks with Chrome not Firefox. Yay! 2014 ;)
- briantakita 13y ago> Javascript is a bad choice Javascript is great once used in a "good" way. It's flexible & it's almost everywhere. Spending all your time complaining about how "bad" Javascript is kindof pointless. If you use Javascript, learn how to use it well. Master sushi chefs don't sit there complaining how bad knives are because the knives need to be constantly sharpened. If you are cooking spaghetti, learn how to strain the noodles, instead of using silly examples assuming people are incompetent at learning a tool. https://www.youtube.com/watch?v=rbA9KAc5gZs https://www.youtube.com/watch?v=rbA9KAc5gZs
- rplnt 13y agoThe fact that something is "almost everywhere" doesn't make it good. It makes it useful at most. And your examples make sense, javascript doesn't (in some cases) so it's very appropriate to complain.
- briantakita 13y ago> so it's very appropriate to complain In that case, it's appropriate to complain about gravity & being restricted to the speed of light? No, it's better to learn about and use these properties to your advantage.
- loup-vaillant 13y agoAre you seriously equating the laws of physics and human artefacts? That would be ludicrous. While the laws of physics are set in stone, human artefacts can be remade. That changes everything I'm sure you have the skills required to, say, write a preprocessor for whatever language you are using, and add some special constructs in it. Missing feature? Done in a few days. So… If the laws of physics suck, suck it up. If your tools suck, change them.
- briantakita 13y ago> Are you seriously equating the laws of physics and human artefacts? Yes I am. The property that they share is they will not be changed or avoided in the near future. Another property is that despite certain limitations, you can still accomplish many things. If you focus on these limitations, you will accomplish less. > If the laws of physics suck, suck it up. Not in all cases. Physics is just a model of our understanding of physical existence. Einstein demonstrated that. > If your tools suck, change them. I guess if it's worth it to spend that much effort, then go ahead. Just know that the frequent examples of javascript's "problems" are easily surmountable, that is if you don't dwell on these "problems". Javascript has some great attributes to it. Indeed, it does not "suck". That's like saying the human body sucks because we have this ridiculous tail bone and wisdom teeth. No accounting for taste, I suppose. I choose to focus on that and progress in mastery of my craft. If you want to complain and/or change your tools, go ahead. I don't judge you.