|
Ouch, that article is awful!
I would try to justify my claim but I just don't have enough spare time to point out all the wrongs with it. Let's just say it's very biased and the examples are not practical and have been cherry picked to fit the agenda.
For example, at one point it uses XPath to show how easy it is to get elements with a certain attribute using XML, but then suggests you need to write a multiple line for-loop to deal with the JSON equivalent...
Personally I don't have a problem with either, pick what best suits the requirements, as is true with most things.
|
|
|
|
|
Quote: Ouch, that article is awful!
Maybe. I posted the link just because it mentioned C# troubles with JSON .
Quote: Personally I don't have a problem with either Me too. Nowdays I use more JSON , because often I need the serialization of trivial objects.
|
|
|
|
|
(Yes, I see below that you are being tongue-in-cheek.)
SQL Server supports XML as a datatype, so when I'm reading JSON to store data in SQL Server I convert it to XML then store the whole elephanting thing in an XML-typed field.
But, really, it's like saying that apples are better than oranges.
Nearly all the places I see people rationalizing that JSON is "better" than XML, it's just completely unconvincing.
I can consume either (and convert to XML as necessary) and I can produce either. No big deal.
|
|
|
|
|
Yeah, the only benefit i see is that it's more concise. And doesn't have namespaces that I know of.
Yeah, instead of a JSON type there's just JSON parsing to turn it into a table, which I've done quite a bit of lately
|
|
|
|
|
well, the other benefit is native support in javascript. Just sayin
hack everything.
|
|
|
|
|
Javascript supports JSON, that's why we hack around with it in C#. it is of no intrinsic use otherwise, except perhaps for another serialisation format
|
|
|
|
|
i mean, that's what it is - a serialization format.
but textual serialization formats are useful for all kinds of things - like remote procedure calls over text based protocols.
IMO, it's not JSON's format so much that matters, but what people do with it.
The fact that it *is* native to javascript makes calling JSON services with Javascript basically built-in to existing browsers, unlike XmlHttpRequest was for so long.
But aside from that, yes, it's just another serialization format.
The structure is easy to query though, unlike XML (which can be simple, but gets complicated quickly)
hack everything.
|
|
|
|
|
Xpath was complex because it was powerful.....
|
|
|
|
|
|
Is. Was means 'back in the days when everyone used it a lot'. Even VB6 still exists, although it's a lot less useful than XML, which I am sure is still used.
|
|
|
|
|
I use XPath nearly every day. Very handy in a tight spot.
|
|
|
|
|
Yeah, I'm sure some people still do. Nothing wrong with that, it's hardly outdated. XML is just not the fix all it was assumed to be in 2002
|
|
|
|
|
I think it got that reputation on account of being the first widely adopted extensible textual structured data format online. It was really the idea of such a format that was a fix all rather than Xml itself, if anything. just my $0.02
hack everything.
|
|
|
|
|
I'm not even talking about xpath. JSONPath does the same thing, except through JSON documents.
The *only* reason JSONPath is simpler is because JSON *structure* is simpler (no attributes, no namespaces, all keys are fixed to field names instead of based on the key marker in an XSD schema)
Yes, *XML* is fundamentally more "powerful" than JSON because it can represent more data in more ways. It's more expressive.
However, it's also clunky if all you need is something basic like JSON provides.
hack everything.
|
|
|
|
|
I can't help but jump into a gabfest!
RPCs are generally for people who couldn't be bothered to write state machines. Which means that they're usually execrable. They're why a little spinning wheel appears on the screen and you can sit there and stare at it until the cows come home or it has the courtesy to time out. Utter dross.
|
|
|
|
|
there are valid reasons for json RPCs though, like querying a large database at a foreign entity.
Better to do that than to refresh the whole page
hack everything.
|
|
|
|
|
Maybe I'm missing something, but I don't see why this kind of thing can't be done asynchronously.
I see RPCs as anathema because they lead to gross inefficiencies and undesirable attributes:
- in a server, large thread pools (e.g. Thread Per User or Thread Per Request)
- the inability to handle other inputs (e.g. client cancellations--the "spinning wheel on the screen" problem)
- the inability to send parallel requests because RPCs block
- responses and timeouts arriving inside application functions instead of being routed top-down like other inputs
- in some implementations, undesirable coupling caused by explicitly naming the destination function
I've seen systems where mutexes were held during RPCs. This really does wonders for latency.
RPCs are good for prototyping but shouldn't appear in production code.
|
|
|
|
|
What you're missing is the internet. This is a client server scenario. At some point the client needs to fetch data from the server.
It has nothing to do with async and everything to do with the basic problem of communicating across a network boundary.
I feel like we're talking about two totally different things. Remote procedure calls - a way to call a method across a network boundary.
hack everything.
|
|
|
|
|
Maybe we are talking about two different things. To me, an RPC (so named because it behaves as if you called a procedure that returned a result) is a blocking send. Synchronous messaging. The send function waits for the result to arrive, causing the thread to be scheduled out.
|
|
|
|
|
RPC calls can indeed be asynchronous.
I'm not sure who told you otherwise.
Synchronous messaging is just a standard way to do the baseline, just like a single threaded app is a standard baseline way to write one, but an app by definition isn't single threaded.
When you do asynchronous RPC you make the call, and you get something like a return/cancellation token you can use to retrieve your result later.
Doing RPC over HTTP can be async, you just use request/response for the request, and then request/response again for the response (or hack the http result using keep alive and spit that way)
hack everything.
|
|
|
|
|
The usual meaning of RPC is that the client blocks until the server responds. Getting back a token that is later used to retrieve the result doesn't make it look like a regular procedure call. But it's a much better way to do it.
|
|
|
|
|
yeah, it's a basic pattern in doing asynchronous programming.
Seriously, there's nothing fundamentally synchronous about RPC.
That's why it's not called SRPC.
That's why there's no ARPC
It's just RPC
Remote
Procedure
Call
Nothing in there about sychronicity
Sorry I realized afterward how much of a jerk i just sounded like.
Life stuff was frustrating me, it wasn't you.
I'm in need of a cigarette i can't have.
hack everything.
|
|
|
|
|
No need to apologize. I don't think you sounded like a jerk.
|
|
|
|
|
I'm glad to hear it, because I was frustrated when I wrote it, and I can tell by reading it, but I wasn't frustrated at you. =)
One of the nice things about JS is it's really easy to set it up to do asynchronous RPC. Creating a "thread" in javascript (not a real thread) is easy as pie, and since it's not a real thread, but rather a cooperatively scheduled fiber spawned by the browser you don't need to work synchronization primitives.
Basically the browser is creating your state machine for you if you just <script> to an url (or any of the other enumerable ways to get JS to load something asynchronously)
Adding: with JS you wouldn't use a cancelation token, but rather a callback method ala JSONP to do your async notify. In JS this is cake as all functions are basically delegate objects
hack everything.
|
|
|
|
|
I route responses to asynchronous requests just like other messages: received by an I/O thread, put on a work queue, and eventually dequeued by an "invoker thread", so named because it invokes applications to pass them messages. I find that there are advantages to having a consistent flow of control.
|
|
|
|