Live data from Hacker News

Why is JSON so popular? Developers want out of the syntax business

stereolambda.wordpress.com

71–80 of 120 posts

Re: Why is JSON so popular? Developers want out of the syntax business

#71
post #42
post #32

Earlier quoted context omitted.

I'm not sure what you think your JSON parser is doing.

Come on. Any one of us could write a JSON parser in a page of code. An XML parser is significantly more work due to the overcomplexness of XML. Both to write, and for the CPU to run. And it's larger. In fact I'm struggling to think of something XML has that is good. (And please no one respond with "it's extensible" or I may explode). An XML parser has to track open tag names, with JSON it doesn't matter. XML has all…

XML brings a lot of other baggage to the party. Some of it can be useful. I particularly like XML namespaces, because when used properly there's hardly an equivalent in any other standardized serialization format I know. (And part of the problem is that you really need it standardized at the serialization format level for it to work; you can hack things into any other format but by definition you're not doing it in a standard way.)

However, that statement should be understood through the filter of the fact that I've only seen one thing that uses XML namespaces properly, and that's XHTML. Everything else I've seen gets it wrong, and that includes most things trying to deal with XHTML....

You also get a "free" and modestly powerful validation system, a serialization format that has seriously thought through encoding issues and has answer for them (JSON does too, but a lot of other fly-by-night stuff doesn't), a fairly powerful format for tagged text (JSON-tagged text is a hack no matter how you slice it). You also get XSL, which floats some people's boats, though I wouldn't be caught dead working in it.

If you don't need any of that, don't use it. I don't very often. But when you need it, do. Also:

"An XML parser has to track open tag names, with JSON it doesn't matter."

This is equivalent to JSON needing to track {, [, ', and ", among other things. That's just parsing; both JSON and XML need to be parsed. That's not an advantage.

"XML has all stupid entities like & which look ugly and need to be parsed."

This is equivalent to the escape sequences in JSON: http://json.org/string.gif They also need to be parsed, they do not magically turn into bytes without that.

Re: Why is JSON so popular? Developers want out of the syntax business

#72
post #62

Earlier quoted context omitted.

Only the ones too clueless to use Emacs or another editor that does it for you.

Maybe it goes back to my frustrations with Dreamweaver, but I always felt like an IDE only served two purposes - to prevent developers from really learning a language (autocompletes, intellisense, etc) and making up for poorly designed, overly-verbose syntaxes. Here we are in 2010 and most programming languages still contain tons of semicolons, parans, and curly braces, and the only reasons I can find for this is: *…

Well, that's quite an extrapolation from my recommendation to use automation to match brackets/parens.

Python is almost there in terms of language simplicity, but I'd much rather count parens than count spaces/tabs. The former are visible. The latter are only visible through secondary effect.

Any tool can be abused. Not using automation for truly mindless tasks like counting parens is often just a knee-jerk reaction that precludes real thinking about the cost/risk/benefit of the tool.

Programming has always been full of idiots who turn off their brains. Maybe modern tools make this a bit too easy. I'd posit that one way to detect programmers with such proclivities is to discuss tools with them, and see if they give you back unsupported prejudice or reasoned analysis. (Really be wary of the ones who try to pawn off prejudice as reasoned analysis!)

Re: Why is JSON so popular? Developers want out of the syntax business

#73
post #23

Earlier quoted context omitted.

no. but fun. SCNR is an old usenet acronym and stands for "sorry. could not resist". I was a) being sarcastic and b) just making fun for the list crowd. I totally agree that if the parens issue is a non-issue for you and you feel comfortable and productive writing lisp code than go ahead. In fact, I have the utmost respect for people able to wrap their heads around that syntax.

If you really think "wrapping your head around" the almost non-existent syntax of Lisp is a reason to respect someone, then I suggest you might delve a little further in your CS/programming studies and find many more wonderful and interesting things. For the true rockstar coder "wrapping your head around" any reasonable syntax should be a triviality.

For the true rockstar coder "wrapping your head around" any reasonable syntax should be a triviality.

Never had the dubious pleasure of trying to decipher another person's APL code, eh?

Then again, you did say "reasonable"...

Re: Why is JSON so popular? Developers want out of the syntax business

#74

Earlier quoted context omitted.

For some reason, every time I let an editor automatically insert a closing parenthesis, quotation, or brace, I almost always end up with extras at the end User issue here. I never have the problem you refer to. Don't have the editor/IDE insert the parens/brackets. Have it check them for you. Emacs can do a momentary highlight of the opening paren/bracket whenever you type the close of the pair. I used to use that to…

"Don't have the editor/IDE insert the parens/brackets. Have it check them for you. Emacs can do a momentary highlight of the opening paren/bracket whenever you type the close of the pair." NO. Sorry but you're doing it wrong. Relying on the editor to highlight parentheses is a highly inefficient and error-prone way to work. It's distracting, it wastes mental cycles and inhibits flow. The correct way is to configure e…

NO. Sorry but you're doing it wrong. Relying on the editor to highlight parentheses is a highly inefficient and error-prone way to work. It's distracting, it wastes mental cycles and inhibits flow.

The correct way is to configure emacs so that when you press a certain key (in my case, right shift because I configured my keyboard so I can activate left shift with my thumb), emacs inserts "()" and puts the cursor in the parentheses. No need to remember or count closing parentheses this way.

No, sorry you are doing it "wrong!" :) I also use the insert () technique. I basically use whichever technique is optimal in context. Please note that your assertions about flow and distractions are highly subjective.

http://www.cyberbore.com/puzzle/klok.html

Incidentally, I no longer use emacs, and I don't write Lisp.

Re: Why is JSON so popular? Developers want out of the syntax business

#75
post #71
post #42

Earlier quoted context omitted.

Come on. Any one of us could write a JSON parser in a page of code. An XML parser is significantly more work due to the overcomplexness of XML. Both to write, and for the CPU to run. And it's larger. In fact I'm struggling to think of something XML has that is good. (And please no one respond with "it's extensible" or I may explode). An XML parser has to track open tag names, with JSON it doesn't matter. XML has all…

XML brings a lot of other baggage to the party. Some of it can be useful. I particularly like XML namespaces, because when used properly there's hardly an equivalent in any other standardized serialization format I know. (And part of the problem is that you really need it standardized at the serialization format level for it to work; you can hack things into any other format but by definition you're not doing it in a…

>> This is equivalent to JSON needing to track {, [, ', and ", among other things. That's just parsing; both JSON and XML need to be parsed. That's not an advantage.

JSON can simply count brackets. That makes for a very simple parser indeed. XML needs to cope with invalid nesting, end tag names not matching start tag names etc. End tag names are just wasted space.

>> This is equivalent to the escape sequences in JSON: http://json.org/string.gif They also need to be parsed, they do not magically turn into bytes without that.

But those are sane. We all escape double quotes and backslashes in pretty much every programming language. They make sense in a very simple encoding.

Why should I need to replace & with %amp; they seem arbitrary, and the replacements aren't simple. " ?? seriously? you're naming characters with odd abreviations, and then expecting people to remember those? why not just escape them with a prefix such as erm.... "\"

Re: Why is JSON so popular? Developers want out of the syntax business

#77

Earlier quoted context omitted.

jQuery includes a proper parser

I think it was even being incorporated in browsers natively for maximum performance. It might be available already.

http://ejohn.org/blog/the-state-of-json/

Re: Why is JSON so popular? Developers want out of the syntax business

#78
post #26

The "XML requires you to build your own parse tree" argument isn't valid; XML libraries are fully capable of handing you a DOM-style tree, and of allowing you to pull things out of the tree without writing your own traversal code. JSON just assumes messages are going to trivially fit into naive data structures, and so provides fewer options.

The point here (in the orig article) was that in some cases you do (i.e. if all you have is a SAX parser - Obj-C iPhone SDK being singled out as an example where only a SAX parser is supplied by the SDK)

Re: Why is JSON so popular? Developers want out of the syntax business

#79

Earlier quoted context omitted.

If you really think "wrapping your head around" the almost non-existent syntax of Lisp is a reason to respect someone, then I suggest you might delve a little further in your CS/programming studies and find many more wonderful and interesting things. For the true rockstar coder "wrapping your head around" any reasonable syntax should be a triviality.

For the true rockstar coder "wrapping your head around" any reasonable syntax should be a triviality. Never had the dubious pleasure of trying to decipher another person's APL code, eh? Then again, you did say "reasonable"...

You don't have to tell me about APL syntax. For our senior year CS project, we implemented APL with unlimited precision arithmetic.

Wrapping your head around APL wins my respect. Lisp? You get a pat on the head for that, maybe.

Re: Why is JSON so popular? Developers want out of the syntax business

#80

JSON is popular because there is a straightforward mapping from JSON to native types in many programming languages.

Language designers take note: there is tremendous utility in making entities in your language isomorphic to entities expressed in previous languages. I am actually using such isomorphisms in my current porting project. I'm literally getting a couple of orders of magnitude more productivity out of this over porting by hand. Also note: less syntax makes this easier.

I recently wrote a program to do Threefish encryption which I deliberately wrote to look as much like the mathematical notation in the spec as possible. That made things so much easier that it was almost ridiculous, even if it made the resulting program very peculiar-looking.
Post reply on HN