Live data from Hacker News

Wat

destroyallsoftware.com

91–100 of 103 posts

Re: Wat

#91
Congrats to all of you who laughed. You are all great hackers. I don't find this remotely funny.

Re: Wat

#92
I think that a hacker would also realize that the title makes no claim whatsoever about the hacker status of those who don't laugh.

Re: Wat

#93

I guess you had to be there. I can see why someone might find this funny, but honestly, nothing is that funny. Some behavior in Javascript is surprising, but not that surprising.

If you've ever gone through a phase (or a graduate degree!) of thinking deeply about programming language design, you might, as I do, find Javascript's expression evaluation behavior to be just about the funniest thing around.

I have but I don't. Javascript was designed to reduce programmer-visible errors at the cost of making it nearly impossible to write a correct program. At that goal, it succeeds, and [] + {} being NaN makes perfect sense under those constraints.

Re: Wat

#94
post #78

that weird behavior of javascript can actually be used for xss attacks, by being able to assemble strings. for example: (![]+[])[+!+[]] produces an "a". https://news.ycombinator.com/item?id=1153383

But of course, anyone that actually wants to protect against XSS attacks won't allow user input to be evaluated. If they did want to allow user-supplied Javascript, they wouldn't blacklist, they would whitelist (by parsing the user-supplied script and using the AST to emit only whitelisted operations).

Re: Wat

#95

Guess I'm not a hacker? It's like watching a rerun I've seen twice over with the laugh track turned up to 11 (just to clarify, someone said it was a repost but I haven't seen it before).

I didn't laugh because I was so worried that if I didn't laugh I wouldn't be considered a hacker :(

Your comment made me laugh a lot! Thanks.

Re: Wat

#96
For some reason, what I find the most hilarious here is reading the extremely serious HN comments. It's a weird contrast.

Re: Wat

#97

Earlier quoted context omitted.

I understand the downvotes since this is HN and you people don't like useless comments here. But I simply thought it was very funny. No need to be mean here.

For the record, the downvotes aren't to be mean. We just don't want this turning into a Reddit clone and/or fill the comments with run-of-the-mill comments you'd see on any PHPbb forum. No, I wasn't one of the ones who downvoted you and no, I'm not trying to be mean. There used to be times I wondered why an innocent comment of mine was downvoted and thought I'd just let you know instead of leave you hanging.

Thanks for the reply. Perhaps I was unclear. I completely understand the downvotes - that's why they're on the site. But I thought the "wow, you must be the best hacker ever congrats" comment was unnecessary and mean-spirited.

Re: Wat

#98
post #44

How does this have anything to do with a sense of humor specific to hackers? Don't all professionals enjoy jokes about their field?

That is exactly what I was wondering: what you say must be true, but I could not find any equivalent of what you see here for any other profession.

But maybe it is just because I write code for a living...

Re: Wat

#99

What's the "correct" ("less funny"?) result of Array(16).join("wat" - 1) + " Batman!" ? Empty strings separated with NaN s look perfectly logical to me (I'm a JS guy though, so, well, bear with me).

Well, .join(x) joins an array into a string, with x as the separator. First of all what does Array(16) make? Effectively it should make an array with null 16 times. Now, JavaScript seems to think null is a blank string, a string with the text 'null', or a zero depending on the context.

The first thing it should do is TypeError that null is not a string. Or don't join null fields because there is nothing there.

If is does convert null to '', then it should TypeError on string - int. If it is not going to TypeError it should do something sensible, like slice the string

  > Array(16).join("wat".slice(0,-1)) + " Batman!"
  'wawawawawawawawawawawawawawawa Batman!'
I think the correct thing would be to TypeError in two different places. Or change the language so things that don't error actually work. Returning a string with NaNs in it will just lead to uncaught errors. If it actually returns something it should probably be ' Batman!'.

JavaScript nuttiness:

Now it's zero:

  > null + 1
  1
Now it's "null":

  > null + "text"
  'nulltext'
Now it's a blank string:

  > [null, null, null].join()
  ',,'
Python errors when things don't make sense, and forces you to make them make sense:

If it doesn't work, error:

  >>> "wat" - 1
  Traceback (most recent call last):
	  File "", line 1, in 
  TypeError: unsupported operand type(s) for -: 'str' and 'int'
Can't join None into a string:

  >>> ','.join([None, None, None])
  Traceback (most recent call last):
	  File "", line 1, in 
  TypeError: sequence item 0: expected string, NoneType found
Convert None to a string if you want:

  >>> ','.join([str(i) for i in [None, None, None]])
  'None,None,None'
But it makes more sense to drop the None:

  >>> ','.join([str(i) for i in [None, None, None] if i])
  ''

Re: Wat

#100
post #36
post #19

Earlier quoted context omitted.

It's jsc (comes with Webkit) - it's present on Mac OS X by default in /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc You can just do: sudo ln /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc /bin/jsc To be able to invoke it directly from the command line.

That is extremely useful. Do you know if any testing libraries or other useful functionality have been built around this? I suppose if you are a WebKit-only developer, this utility could have many useful applications.

There's also mozrepl, which lets you evaluate code in Firefox from the command-line or Emacs.
Post reply on HN