News for hackers. Stuff that matters.
Re:Evil.js: A JavaScript library for thwarting hot-linkers by derefr on Monday March 31, 2014 @02:24PM (#7503207)
And, awfully-enough, even though Infinity is a required part of IEEE754, and happens all the time in Javascript, JSON doesn't recognize it.
Re:Evil.js: A JavaScript library for thwarting hot-linkers by polemic on Tuesday April 01, 2014 @12:25AM (#7506179)
Why is that awful? JSON is not JavaScript. The string encoded value of the integer 1 is not a IEEE754 numeric either - it's just the character 1. In modern usage: JSON is to JavaScript as JavaScript is to Java.
Re:Evil.js: A JavaScript library for thwarting hot-linkers by derefr on Tuesday April 01, 2014 @12:40AM (#7506213)
It's awful because you would expect a network encoding of a set of types to be able to encode all the valid values of those types. If you claim that your encoding can represent floats, but it can't represent Infinity or NaN, then your encoding cannot, in fact, represent floats.
Re:Evil.js: A JavaScript library for thwarting hot-linkers by polemic on Tuesday April 01, 2014 @01:48AM (#7506394)
It makes no such claim!

See http://www.json.org/ - it is very cleary defined. *It's a string notation for a number. Don't get hung up on the implementations of floats or integers - it's irrelevant!

Re:Evil.js: A JavaScript library for thwarting hot-linkers by mcv on Tuesday April 01, 2014 @04:20AM (#7506784)
> In modern usage: JSON is to JavaScript as JavaScript is to Java.

This is totally wrong. Javascript has nothing whatsoever to do with Java. It only has a few very superficial syntactical similarities (curly brackets, semi-colon at the end of each line, and that awful 'new' keyword). JSON, on the other hand, stands for "Javascript Object Notation", and can be interpreted as Javascript (with 'eval'). It's explicitly meant for storing and transmitting javascript data, so when there's a javascript data value that is not supported by JSON, that is absolutely relevant.

Re:Evil.js: A JavaScript library for thwarting hot-linkers by polemic on Tuesday April 01, 2014 @05:14AM (#7506980)
In modern usage, you don't eval it. In modern usage is used for far more that just "javascript" applications.

Of the four letters in the acryonym, the "J" is the least significant. Yes, it's javascript-y, but that's it. So many misunderstandings come from focusing on the "J". So, as JavaScript has basically nothing to do with Java (aside from superficial syntax similarities) so does JSON to JavaScript, for the same reasons. This "JSON is a subset of JavaScript" is just not true - at best it's "inspired by and interoperable with".

Re:Evil.js: A JavaScript library for thwarting hot-linkers by mcv on Tuesday April 01, 2014 @07:28AM (#7507317)
No, Javascript has far, far less to do with Java than with JSON. JSON is legal javascript. Ever heard of jsonp?

Java, on the other hand, is a totally different language. Any similarities are superficial and exist primarily for PR reasons. You can't pretend javascript is legal Java or vice versa. But JSON is totally legal javascript. That is exactly how you can declare objects in javascript. The name JSON fits the bill perfectly: it is the javascript object notation.

Re:Evil.js: A JavaScript library for thwarting hot-linkers by polemic on Tuesday April 01, 2014 @02:56PM (#7510794)
"it is the javascript object notation."

Except it's not, which is part of the reason this sub thread started. JSON encoded numbers are not IEEE754 floats either. And JSONP is purely a convenient hack around browser security issues only, again it has noting to do with JSON as a format.

You can argue the specifics,, but you miss the point that the claim that "JSON is JavaScript" is false and leads to tricky edge cases when the assumption breaks down.

Re:Evil.js: A JavaScript library for thwarting hot-linkers by mcv on Thursday April 03, 2014 @05:12AM (#7521724)
> And JSONP is purely a convenient hack around browser security issues only, again it has noting to do with JSON as a format.

It gets around those browser security issues by having the JSON wrapped in a function call and interpreted as javascript. I've never heard of a server converting all the values for JSONP.

There are absolutely edge cases, and those are important to note, exactly because outside those edge cases JSON is valid javascript. Claiming that they are totally completely unrelated (like javascript and Java) is false.

Re:Evil.js: A JavaScript library for thwarting hot-linkers by hrjet on Monday March 31, 2014 @02:51PM (#7503376)
IIRC, JSON is a strict subset of JS and Python.
Re:Evil.js: A JavaScript library for thwarting hot-linkers by adambard on Monday March 31, 2014 @04:25PM (#7503889)
I have never heard anyone else make this assertion.
Re:Evil.js: A JavaScript library for thwarting hot-linkers by mcv on Tuesday April 01, 2014 @03:59AM (#7506734)
The Python is new to me, but JSON's strong relationship to javascript is not new at all: http://en.wikipedia.org/wiki/JSON
Re:Evil.js: A JavaScript library for thwarting hot-linkers by pnachbaur on Monday March 31, 2014 @04:59PM (#7504132)
JSON originated from Javascript alone
Re:Evil.js: A JavaScript library for thwarting hot-linkers by riffraff on Monday March 31, 2014 @04:19PM (#7503853)
is it? "null" is not valid python, I think
Re:Evil.js: A JavaScript library for thwarting hot-linkers by wisty on Tuesday April 01, 2014 @03:13AM (#7506612)
If you do this first:

    null = None
    Infinity = float('Infinity')
    NaN = float('nan')
(But no, it's not quite Python)
Re:Evil.js: A JavaScript library for thwarting hot-linkers by mercurial on Monday March 31, 2014 @04:52PM (#7504073)
It isn't. It would be None. I believe parent is mistaken.
Re:Evil.js: A JavaScript library for thwarting hot-linkers by hrjet on Monday March 31, 2014 @11:35PM (#7506028)
I stand corrected; I am not that familiar with python. Though I remember reading somewhere that JSON can be evaled in both JS and Python. Perhaps the python bit is not true.
Re:Evil.js: A JavaScript library for thwarting hot-linkers by kibibu on Monday March 31, 2014 @11:50PM (#7506082)
JSON looks more-or-less like a Python dict, but you still wouldn't be able to parse {"x": NaN} or {"x": Infinity}
Re:Evil.js: A JavaScript library for thwarting hot-linkers by derefr on Tuesday April 01, 2014 @12:47AM (#7506225)
Oddly, there's actually no language that I know of that has NaN and Infinity constants. Many languages pretty-print those float values that way, but none of the parsers can interpret them back in.
Re:Evil.js: A JavaScript library for thwarting hot-linkers by GeneralMayhem on Tuesday April 01, 2014 @01:56AM (#7506424)
...do you mean other than JavaScript? They're not actually parser-level constants, they're just defined as globals/on the window object, but they work.