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

Leave a comment

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

There is a reason why JSON is becoming very popular as a data exchange format (more important than it being less verbose than XML): programmers are sick of writing parsers! But “wait”, you say – “surely there are XML parsers available for you to use so that you don’t have to roll your own…”. Yes, there are. But while XML parsers handle the low-level syntactic parsing of XML tags, attributes, etc…, you still need to walk the DOM tree or, worse, build one yourself with nothing but a SAX parser (Objective-C iPhone SDK I’m looking at you!). And that code you write will of course depend on whether the XML you need to make sense of looks like this:

<person first-name="John" last-name="Smith"/>

or this:


or this:

<object type="Person">
   <property name="first-name">John</property>
   <property name="last-name">Smith</property>

or any of the myriad of other ways one can conceive of expressing the same concept (and there are many). The standard XML parser does not help you in this regard. You still need to do some work with the parse tree.

Working with JSON is a different, and superior, experience. Firstly, the simpler syntax helps you avoid the need to decide between many different ways of representing your data (as we saw above with XML) – much less rope to hang yourself with. Usually there is only one straightforward way to represent something:

{ "first-name" : "John",
 "last-name" : "Smith" }

Even more important, if you are working in Javascript (which is very often the case when working with JSON), all you need to do is call eval on a JSON string to obtain a first-class Javascript object. This is huge. The subtle point here is that the output of an XML parser is a parse tree, not an object native to the programming language being used. With XML you are still dealing with syntax to a large degree. When you work with JSON you can go straight from a string representation to object (and back).

What makes this possible is that Javascript has syntactic constructs for describing composite data types literally. While virtually all languages have syntax for the literal description of objects of primitive types (integers (e.g. 5), strings (e.g. “hello world”)), not all languages have syntax for the literal description of objects of composite types. For instance, if you want to create a map in Java you need to do it procedurally:

Map m = new HashMap();
m.put("a", 1);
m.put("b", 2);
m.put("c", 3);

Java does not have literal syntax for maps. But languages such as Python and Javascript (and others) do. In Javascript we can define our map literally:

{ "a" : 1, "b" : 2, "c" : 3, ... }

As it turns out, such sub-languages are a great match for data interchange formats that are both human and machine readable.

As for XML… it’s just not the best for structured data interchange (even with some of the cool Object/XML mapping technologies out there). It works well for markup (i.e. HTML) of text but not as a language for structured data. For that developers want something they don’t have to parse all the time.

Random rambling thoughts while writing notes

Leave a comment

Plain notepad,
You were there since the dawn of the scribes,
Attentively remembering the ideas of those that are wise,
Spreading the word of salvation and damnation with equal grace,
Even being the the one sided listener of those less sane,
Now with the iGeneration coming by,
Will you still perform your duties since that dawn,
Or will you fade away into memory?

Sorry HTML 5, mobile apps are used more than the web — Mobile Technology News

Leave a comment

Mobile applications are commanding more attention on smartphones than the web, highlighting the need for strong app stores on handset platforms. For the first time since Flurry, a mobile analytics firm, has been reporting engagement time of apps and web on smartphones, software is used on average for 81 minutes per day vs 74 minutes of web use. Just a year ago, mobile web use outnumbered time spent on apps with 64 minutes as compared to 43 minutes. Trends are ever subject to change, but this one indicates that we’ll be waiting longer for HTML 5 web apps to unify the world of mobile devices.

What are our mobile app minutes spent doing? Flurry, which monitors software on  iOS, Android, BlackBerry, Windows Phone and J2ME platforms, says we’re a growing community of gamers, with 47 percent of our app time spent playing. Social networking followed up with 32 percent, while news, entertainment and other activities each accounted for single digits.

The entertainment figure of only 7 percent seems low to me given that mobile video, a time-intensive activity, is popular: Some data suggests that iPad users watch 2.5 times more video than traditional web users, for example. While YouTube has a solid mobile web interface, many platforms kick users into a native YouTube application. Last July, YouTube said it was serving 100 million videos per day through both its mobile software and website.

Regardless of that potential anomaly, the data underscores a few points I’ve made about mobile app ecosystems: If a platform doesn’t have a strong set of third-party apps available, consumer adoption of the platform becomes a greater challenge. To some degree, we’re now seeing that with Google Android Honeycomb tablets as well as RIM’s BlackBerry PlayBook. There are other issues facing each of these, but a lack of optimized apps isn’t helping any, especially with the move from web to apps on mobiles.

Flurry’s data also has me pondering the future of web apps; namely, will HTML5 become as strong of an “app” platform as some would hope? As Chetan Sharma noted last year, the beauty of the web as an application distribution point is the reduced fragmentation it brings:

[T]he fragmentation issue in mobile only gets worse with each year with new devices, different implementations and operating systems, the cost of rolling out an app across multiple devices around the world can increase exponentially. As such, the browser provides the prospect of being the great unifier so you can truly design once and run everywhere (where the browser is available). For the simple apps that are less interactive and require less multimedia capability, like the popular social networking and news/weather apps, browser provides the perfect avenue to maximize impact with least amount of development.

Sharma’s thought made perfect sense to me back then, and while I’m still in general agreement with him, I’m beginning to wonder if the situation has changed. Instead of a mobile market with a number of platforms, we’re now witnessing the space become dominated by just two in Android and iOS. The third spot is up for grabs, although Windows Phone 7 has recently gained perceived momentum. BlackBerry / QNX and webOS are in transition, while Symbian is on the way out.

All the smartphone platforms are using WebKit browsers, so there’s still opportunity for web apps to unified across a large number of devices, but with such dominant operating systems in play, there may be less need for the web browser as a “great unifier” in mobile than there was just a year or two ago. And as long as apps keep appearing, the trend indicates consumers will keep buying.

So much for open standard will rule all eh?

Operation Malaysia by Antonymous

Leave a comment

– benjamin wong

BBC News – China accuses Vietnam in South China Sea row

Leave a comment

China has accused Vietnam of “gravely violating” its sovereignty in an escalating row over disputed waters in the South China Sea.

Beijing said Vietnam had endangered Chinese sailors’ lives and warned it to stop “all invasive activities”.

It follows an accusation by Vietnam that a Chinese fishing boat rammed cables from an oil exploration vessel inside its exclusive economic zone.

China is engaged in maritime border disputes with several countries.

The South China Sea includes important shipping routes and may contain rich oil and gas deposits.

The Philippines, Malaysia, Brunei and Taiwan also have rival claims in the area; China’s claim is by far the largest.

The US has also expressed concern about China’s rising naval ambitions.

Escalating dispute

China’s foreign ministry spokesman Hong Lei said Chinese fishing boats were chased away by armed Vietnamese ships on Thursday.

He said that during the incident the fishing net of one of the Chinese boats became tangled with the cables of a Vietnamese oil exploring vessel which continued to drag the Chinese vessel for more than an hour before the net had to be cut.

Protesters shout anti-China slogans during a protest in Hanoi, 5 June 2011. Hackers have taken up where protesters left off

China insists the Vietnamese vessel was operating illegally in the area.

“By conducting unlawful oil and gas surveys in seas around the Wanan Bank of the Spratly archipelago and by driving out a Chinese fishing vessel, Vietnam has gravely violated China’s sovereignty and maritime rights,” said Mr Hong.

“China demands that Vietnam cease all violations,” he said, adding that Vietnam should “not take actions that would complicate and expand the dispute”.

Beijing’s strong-worded statement followed Vietnam’s accusation that a Chinese fishing boat had “intentionally rammed” the exploration cables of a Vietnamese boat – the second such incident in two weeks.

That vessel, chartered by state energy giant PetroVietnam, was conducting a seismic survey inside its 200 nautical mile exclusive economic zone on Thursday, said foreign ministry spokeswoman Nguyen Phuong Nga.

She described the “premeditated and carefully calculated” attack as part of China’s attempts to control disputed waters.

“This is unacceptable to Vietnam,” she said, adding that her colleagues had met Chinese embassy officials “to express our opposition to such acts”.

On Thursday, hackers from both countries planted patriotic messages on hundreds of websites, including government sites.

It follows anti-China protests by hundreds of Vietnamese over the weekend.

Seeking resolution

China’s ambassador to the Philippines, Liu Jianchao, has insisted China’s intentions were peaceful and said that China was not looking for oil in the disputed waters and, therefore, no other country should.

“We’re calling on other parties to stop searching for the possibility of exploiting resources in these areas where China has its claims,” he told reporters.

“We will never use force unless we are attacked,” he said.

The Philippine government has accused two Chinese patrol boats of harassing a Philippine oil exploration ship on 2 March this year.

The Philippines has said it has seen new structures being built on islands which it claims.

“That’s part of our exercise of jurisdiction. It’s not harassment,” Mr Liu said.

He also rejected the involvement of the United States in regional attempts to resolve the long-running territorial dispute.

China prefers to tackle each conflicting claim with each country separately.

Vietnam, Indonesia and the Philippines have led regional efforts to seek a multilateral resolution of the conflict.

Hmmm…..heating up?

Samsung shows affection to CyanogenMod, gives its devs a free Galaxy S II — Engadget

Leave a comment

Let’s see if we’re grokking this: Samsung is not only telling the dev community it’s okay to place custom ROMs on its flagship device, it’s actually encouraging the practice by handing out free phones? Atinm, the developer responsible for prepping CyanogenMod on the Captivate and Vibrant, took to Twitter to praise the manufacturer for sending him a free Galaxy S II. From the looks of it, Samsung sent the phone to a select number of devs intent on building an official release of CM7 for the GSII. Unlocking bootloaders has already become the new fancy with manufacturers like HTC, Motorola, and Sony Ericsson jumping on the bandwagon, but this is the first time we’ve heard of a company doling out free devices to the custom ROM community. Does this mean that, instead of enforcing TouchWiz with an iron fist, Samsung is looking at how this practice could actually benefit consumers? We doubt this will be the case for all of the company’s future Android phones, but wouldn’t you love to live in a world where it was?

Cool stuff, Samsung showing some Android enthusiast love !!

Eric Schmidt Screwed Up Social Networking Strategy

Leave a comment

Apparently according to this article from BusinessWeek, Eric purportedly messed up Google's social networking strategy. I have not read the article but this should be interesting to those who are into this kind of thing.