I'm attempting to create a client开发者_JAVA百科/server web-app. The client software is written in Objective-C (Mac), and the server software is written in Python (Linux). I'd like to encapsulate object data on either side, and send it across the internet to the other side. This will include standard types such as strings, doubles, and data-structures (arrays, dictionaries), along with binary files.
My question is, how would you recommend me going about doing this? What technologies are good for sending encapsulated data, and later converting it, between two different programming languages? Specifically Objective-C and Python?
Python has pickle/cPickle which will allow you to take Python objects and encapsulate them into a file, but un-pickling them leaves you with Python objects and not Obj-C objects. I've also seen XML and JSON, though I'd still be stuck with the issue of converting objects, such as a Python Dictionary into an Obj-C NSDictionary, or vice-versa.
From what I've gathered, XML/JSON may be difficult to use with binary data, requiring converting it into text first before encapsulating it. I may be sending large amounts of binary data (50-100MB per request), so a text-conversion would significantly increase the size of the file, something I'd like to avoid.
Thanks for any help!
If you're talking about a traditional browser based web app, then I'd probably stick with JSON or XML serialization.
For anything else I'd suggest drum roll please...
Google Protocol Buffers
Small, fast, and has a decent set of providers for different languages.
Might check out a piece of technology called Thrift. It is an apache based service built specifically for communicating between different languages.
EDIT - link
You could use PyObjC on the client side and some kind of python based serialization. There are facilities in PyObjC for embedding in an existing Cocoa application and for communicating with the Python runtime.
精彩评论