Skip

WAT.
February 2, 2012 2:12 PM   Subscribe

WAT. - A lightning talk by Gary Bernhardt from CodeMash 2012, on the peculiarities of some popular scripting languages. (Single video link, around 4 minutes in length.)
posted by Slap*Happy (37 comments total) 35 users marked this as a favorite

 
I watched this a few days ago and laughed my ass off.
posted by brundlefly at 2:14 PM on February 2, 2012


Javascript explaind on stackoverflow. What he is seeing conforms to the ECMA standard.
posted by Ad hominem at 2:17 PM on February 2, 2012 [3 favorites]


I wanted that to be soooo much longer!
posted by hincandenza at 2:20 PM on February 2, 2012 [4 favorites]


Horse head mask!
posted by OverlappingElvis at 2:20 PM on February 2, 2012


Every programming language needs an explicit WAT function.
posted by oneswellfoop at 2:20 PM on February 2, 2012


Actually, everything from new Array(16) on makes perfect sense, and is funny, but not WAT-worthy.
posted by fnerg at 2:27 PM on February 2, 2012


Ad Hominem: The ECMA standard is deeply, deeply WAT.
posted by murphy slaw at 2:32 PM on February 2, 2012 [2 favorites]


Seconding brundlefly

Seconding murphy slaw
posted by brianvan at 2:36 PM on February 2, 2012


In response to being told about this, one of the faculty in my lab replied "Oh, is that what the insane giggling was about?" I said "Well, that and Winnipegcat, but I'm not going to subject anyone who hasn't lived in Winnipeg to Winnipegcat."
posted by Alterscape at 2:38 PM on February 2, 2012


Javascript explaind on stackoverflow. What he is seeing conforms to the ECMA standard.

An awful lot of these weird line noise command questions come up on SO for some reason.

My response is always, "ugh, I want my strongly typed language".
posted by smackfu at 2:46 PM on February 2, 2012


Highly nerdy, highly hilarious

What I especially love about this video is that I could watch it at work, laugh at the video, and not feel guilty at all because I was "learning".

WAT
posted by mcstayinskool at 2:47 PM on February 2, 2012


I have the absolute barest minimum of knowledge to even begin to comprehend this and I still I laughed.

WATMAN
posted by PapaLobo at 2:52 PM on February 2, 2012


Waxy posted this a couple weeks ago, and when I finally got around to watching it, I had a good laugh at it.

The fact that everything conforms to the standard per the stackoverflow explanation doesn't mean it is not a WAT. I don't think he is saying necessarily that these things are flat out wrong in their output, but instead that the result isn't very intuitive. You look at them and go "WAT". Not "Oh yes, of course that works,as per sections 11.6.1, 9.1, 8.12.8, and 15.4.4.2 of the ECMA-262 standard."

I'd be interested in seeing a series of talks like this, with WATs from other languages. I love Python, and consider it one of the more intuitive and readable languages out there, but I have stumbled into an occasional WAT with it. And I could see an incredibly hilarious talk on pointer math, if compiled languages were game.
posted by mysterpigg at 3:04 PM on February 2, 2012 [1 favorite]


I cannot lie. Darth Vader + Britta pitcher = Blown circuits. You could honestly get me to vote for Rick Perry if you showed me that picture as I walked into my polling station and then subtly commanded me to do so.
posted by Fezboy! at 3:05 PM on February 2, 2012


None of the javascript stuff is off the charts crazy. Most of the bafflement comes from the fact that he is implicitly calling ToString(), ToString() is just giving back useless strings in these cases.

in C#, you have to explicitly call ToString when you use the + operator but:

Console.WriteLine(new object());
Console.WriteLine(new int[16]);
Console.WriteLine(new object().ToString() + new int[16].ToString());

Gives you:

System.Object
System.Int32[]
System.ObjectSystem.Int32[]
posted by Ad hominem at 3:06 PM on February 2, 2012


Scripting language stand-up? MOAR.
posted by anarch at 3:07 PM on February 2, 2012 [5 favorites]


Meanwhile, is this how people have been pronouncing "wat"?
posted by mhum at 3:17 PM on February 2, 2012 [8 favorites]


Yeah, the talk is funny.

I ain't saying it is fine and dandy that ToString() hands back useless values. It is in the spec though. They can fix object.ToString to hand back something akin to typeof this, but that would probably break a million scripts at this point.

Brendan Eich is MeFi's own, so maybe he will drop in, that would be cool.
posted by Ad hominem at 3:18 PM on February 2, 2012


I LOLd so hard at this. Only contention I have is his pronunciation of "wat". I've always read the various wat-macros as a really flat, unbelieving monotone version of "what" without the intonation of an added question mark. Maybe it's just me.
posted by pyrex at 3:19 PM on February 2, 2012 [5 favorites]


His non-standard pronunciation made it all the more funny, in my opinion. It hadn't crossed my mind that it was unintentional, actually.
posted by gilrain at 3:20 PM on February 2, 2012


WATT.
posted by oneswellfoop at 3:21 PM on February 2, 2012


How much of the javascript weirdness is due to wanting to have pages degrade gracefully if there are programming/typing mistakes in the code?
posted by empath at 3:22 PM on February 2, 2012


I've been watching the discussion of this as it has been doing the rounds, and invariably you get "that is as defined in the standard" comments or the like. I figure that makes it worse. I mean if it was just one broken implementation fair enough, but no, this is the standardised behaviour of the language.
posted by markr at 3:23 PM on February 2, 2012 [3 favorites]


I honestly hate JavaScript. I am a decent programmer, and make my living programming, and yet I have never once managed to write JavaScript that didn't have at least a few "wat" worthy side effects. The language is bizarre. There are people now who advocate node.js – server side JavaScript! – and I just can't help but think they don't know any better.
posted by sonic meat machine at 3:25 PM on February 2, 2012


What I find to be the awful thing with the ECMA/javascript examples is the 'object' notation. {} on the LHS of a + is actually a statement block - think "if (..) {...}" - but on the RHS of a + is an empty object. That kind of baked-so-hard-into-the-language-you-can't-remove-it stupidity is the sort of thing that makes me despair for it entirely.
posted by Jerub at 3:41 PM on February 2, 2012 [2 favorites]


Meanwhile, is this how people have been pronouncing "wat"?

No.
posted by tangerine at 3:42 PM on February 2, 2012


Here's one of my favorites, because programmers only have 8 fingers.

> 003+010
11

It's a lovely gotcha if you throw user string input into parseInt(). Then again Javascript doesn't really have integers at all. Twitter found that out the hard way.
posted by Nelson at 3:48 PM on February 2, 2012 [1 favorite]


How much of the javascript weirdness is due to wanting to have pages degrade gracefully if there are programming/typing mistakes in the code?

Well, if you mistype a variable name, it doesn't complain, which has led to a billion code bugs and has never degraded gracefully once.
posted by smackfu at 3:59 PM on February 2, 2012 [2 favorites]


What I find to be the awful thing with the ECMA/javascript examples is the 'object' notation. {} on the LHS of a + is actually a statement block - think "if (..) {...}" - but on the RHS of a + is an empty object. That kind of baked-so-hard-into-the-language-you-can't-remove-it stupidity is the sort of thing that makes me despair for it entirely

Object (or hash) literals are a very nice feature of an HLL. What makes that statement wat-worthy to me is the opposite— that Javascript, for some bizarre reason, makes the semicolon at the end of a statement optional. Which means the language is inserting semicolons into your code at random. The {} + {} example is being parsed as two statements:
{
   // A block containing no statements
};
+{};  // An expression with a unary + and an object literal
… except when the parser randomly decides to interpret it as two expressions and a binary +.
posted by hattifattener at 4:27 PM on February 2, 2012


"Scripting languages"? Am I suddenly in 2002 again? Dynamic or interpreted languages are just kinds of programming languages, "scripting" seems to be used by OP with diminutive intent.
posted by anateus at 4:50 PM on February 2, 2012 [1 favorite]


Dynamic or interpreted languages are just kinds of programming languages, "scripting" seems to be used by OP with diminutive intent.

WAT.
posted by Slap*Happy at 5:16 PM on February 2, 2012


Obligatory link to JavaScript: The World's Most Misunderstood Programming Language.
posted by kdar at 5:38 PM on February 2, 2012 [2 favorites]


Funny that's from 2001, and how far Javascript has come.
posted by smackfu at 7:06 PM on February 2, 2012


Yup... pretty funny....
posted by ph00dz at 7:54 PM on February 2, 2012


I want my strongly typed language

WAT
posted by DU at 4:49 AM on February 3, 2012


Just came to metafilter to post this, and ...

WAT
posted by zoo at 6:20 AM on March 1, 2012


It's absolutely hilarious though.
posted by zoo at 6:21 AM on March 1, 2012


« Older This guy is the physical embodiment of my...   |   Chickens are actually In The Road Newer »


This thread has been archived and is closed to new comments



Post