XML(e4x) vs AMF

 原文链接:http://www.onflex.org/ted/2006/12/xmle4x-vs-amf.php

 

I am having this inner dilemma about AMF vs XML. For a long time (5 years), I have preferred using AMF over XML. It results in lower over-the-wire bandwidth, faster data serialization/parsing, and you get real class instances in AMF3 when using the full spec (See: Flex Data Services and ColdFusion). Then E4X was added into Flash Player 9 and now I am gradually leaning towards XML for several key use cases:

(New to Flex? Some simple facts first:
1. Flash Player has an XML Parser in it.
2. Flash Player can load XML directly over HTTP/HTTPS.
3. Nothing special is required server side.
4. The XML class implements the E4X (ECMAScript for XML) syntax. Think... readable and writable XPath yet much simpler and tons more fun.
)

Integration with REST

REST API's are blooming everywhere and SOAP seems to be fading rapidly as a client integration format. REST is easy, readable, easy to understand, and best of all it is port 80 friendly.

Queryability
E4X makes client side data easy to query. It is one thing to get an object, it is another to get an object and easily query the data interactively.

Here are a few:

In the loaded XML object named myE4XObj:

Give me elements named 'student' off the root?
myE4XObj.student

Give me 'student' nodes anywhere that have a 'name' attribute?
myE4XObj..student(@name)

Give me 'student' nodes anywhere that a 3.0 or higher grade point average?
myE4XObj..student(@average >= 3)

Now for pure remoting, well that is an AMF thing, for loading models or leaving the result client side queryable, XML with E4X takes the cake. I should note that you can pass XML objects within AMF3 so they remain queryable client side as well, shoot with AMF3 you can pass binary images and SWF files around too.

The problem with AMF is that the secret sauce and recipe are bottled up at Adobe. Although there are many AMF clones out there, they vary wildly in support for the deeper object types in AMF3 binary. They all sort of taste like New Coke or Generic Cola, it tastes similar but something is missing, it is just not the real thing.

What is interesting to me is the fact that AMF is easily 10X faster and lighter than SOAP Web Services for server to server and server to client operations. We have all this server iron out there wasting bandwidth and CPU time parsing XML when they could natively serialize objects with less memory and less bandwidth. AMF3 is a perfect spec for it but we need clients and servers for AMF in many languages first. Currently the AMF format is a transmitter/receiver that can only talk to Flash Player and that needs to change.

I am not sure what 2007 will hold but know that I am lobbying for an open AMF spec in 2007 with server and client implementations for Java/C/CSharp. We need to open up AMF and let it breath. It is really great technology that would enable a wide array of companies leverage efficient data transfer and enjoy native Flash Player data exchange.

2007 is going to be a great year for Flex/Flash/Flash Player/Apollo.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值