Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is XML over Sockets good or bad pratice? [closed]

I've been working on a system that transmits xml over sockets for a while now. And i never really understood whats the real advantage of the choice of xml over sockets instead of a custom protocol.

But i do see a lot of developers(specially originally web-developers) setting up this sort of implementation(xml over sockets).

I do understand that is more "human-readable" (that's what i keep hearing).

But,

  • Xml carries an awful amount of characters, leading to huge messages when in fact the content is really small and simple.

  • Message size varies, therefore you need to guarantee that you terminate your message with specific character or string pattern.

  • There is more overhead when parsing xml

For all this reasons i remain skeptic about considering XML over Sockets for new systems when i could set my systems using a custom protocol using fixed-size messages. Avoiding huge messages being transmitted and performance hits parsing xml on the client size.

Am i wrong to think as such ? What's "best" in terms of system-architecture ?

Regards

like image 263
ehanoc Avatar asked May 21 '12 07:05

ehanoc


1 Answers

The main reason that XML has traditionally been used when transmitting data across a network is because it's extensible. It scales your application and turns it into a potential platform for other applications to build upon yours, or it enables other applications to more easily integrate with you, without having to solve a problem that has already been solved.

After all, that's what developers are paid to do. Solve new problems. Not create them.

Ryan Tomayko talked about this in his blog article on How I Explained REST to My Wife, when he highlighted that using a standard meant that individual systems all over the world could be networked to form massive, cohesive, yet individual, systems.

When you use your own, custom protocol, you basically limit your application to only communicating in it's own little world. Then, when the time comes to glue it together with another system, a lot more integration work is required on both ends.

With that said, JSON is starting to gain lots of traction as a replacement to XML. It's more lightweight, is understood by multiple platforms, and is in fact native to the language of the Web, JavaScript.

Either choice is great in that you're using something that all experienced developers will easily understand, and that every system is capable of consuming.

like image 148
jmort253 Avatar answered Oct 16 '22 19:10

jmort253