News for hackers. Stuff that matters.
Re:JavaScript is Good, Actually by alephnan on Wednesday May 16, 2018 @03:18AM (#17080576)
Sure, but there is boilerplate and abstractions that are needed in a language like Java or Scala. In JavaScript, it's a first-class citizen of the language.
Re:JavaScript is Good, Actually by Scarblac on Wednesday May 16, 2018 @03:28AM (#17080617)
It seems you're not talking about JSON (the serialization format) but rather about Javascript's object literal syntax that inspired JSON. They're really different things.
Re:JavaScript is Good, Actually by Vinnl on Wednesday May 16, 2018 @04:06AM (#17080749)
An advantage, however, is that you can directly encode Javascript data objects to JSON without having to annotate its fields or anything. I don't recall you being able to do that with Java.
Re:JavaScript is Good, Actually by imtringued on Wednesday May 16, 2018 @10:55AM (#17082882)
You can't do that with javascript either unless your data objects are acyclic and if they are then using a JSON parser for Java is equally trivial.
Re:JavaScript is Good, Actually by Vinnl on Thursday May 17, 2018 @02:15AM (#17089171)
You mean that if they are acyclic, you don't have to annotate the fields in Java either? Because the data objects I want to serialize usually are acyclic.
Re:JavaScript is Good, Actually by wyattpeak on Wednesday May 16, 2018 @04:06AM (#17080748)
Perhaps, but probably not. ES6 recognises the distinction, and includes native functions for serialisation. That's first-class treatment if anything is.
Re:JavaScript is Good, Actually by Scarblac on Wednesday May 16, 2018 @05:10AM (#17080979)
JSON.stringify and JSON.parse? They're standard library functions that many languages have, I don't see what's ES6 about them, they're much older.

First class treatment would be if the language had JSON-typed objects with functionality, e.g. something like

    const myJson = j'{"key":"value"}';
    const value = myJson['key'];
    const newJson = myJson.set("otherkey", "newValue");
(using the j'' notation for a hypothetical json-typed value)

But AFAIK it doesn't, not even in ES6.

Re:JavaScript is Good, Actually by brlewis on Wednesday May 16, 2018 @08:20AM (#17081772)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Implementing j`{"key":"value"}`; as a tagged template literal is left as an exercise for the reader.

Re:JavaScript is Good, Actually by Sean1708 on Wednesday May 16, 2018 @05:07AM (#17080968)
Isn't comparing JS to something like Java or Scala a bit misleading in this regard? They're completely different styles of language with different tradeoffs. I think it would be a lot more fair to compare to something like Python or Ruby, in which case this advantage become a lot less clear IMO.
Re:JavaScript is Good, Actually by sametmax on Wednesday May 16, 2018 @06:38AM (#17081323)
Well you must compare a dynamic language with another dynamic language. It would be more fair to compare JS to Python or Ruby if you talk about ease of use.