[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Missing interface that connects NSCoder to NSStream ?
From: |
Helge Hess |
Subject: |
Re: Missing interface that connects NSCoder to NSStream ? |
Date: |
Wed, 14 Mar 2007 08:31:41 +0100 |
On Mar 14, 2007, at 01:57, Vaisburd, Haim wrote:
Does OPENSTEP/Cocoa offer better mechanism that works like C++ stream,
i.e. let you disregard the source of data and concentrate on
formatting?
The "official" way prior NS*Stream was to assemble a packet in an
NSData and then send the NSData, eg using Mach port or NSFileHandle
(eg sendInBackgroundAndNotify).
The historical reason is that NeXTstep was based on Mach which in
turn was based on packet/message IPC. The Mach virtual memory system
would simply remap such a data section in memory to the target
process on the local machine (or forward the block to a remote
machine transparently).
Using streams in the first place is often an over-optimization. Eg if
you just assemble a 32KB JSON packet using an NSMutableString you
gain nothing in practice by using a stream. You loose a lot of
convenience and implicit reliability.
Eg just consider what happens if an error occures during the on-the-
fly serialization. You have little choices but to close the stream
(or implements a complicated protocol which supports OOB data). With
in-memory data you can just clear the so-far generate stuff and
replace it with a proper error.
Even if you send something like a 2MB PDF file to a user a (language
library level) stream is overkill, you can just tell the OS to send
the file directly to the socket. This is magnitudes faster.
Greets,
Helge
PS: I'm not saying that streams are bad, they are just a bit
overused, especially in the Java world ;-)
--
Helge Hess
http://www.helgehess.eu/
- Missing interface that connects NSCoder to NSStream ?, Vaisburd, Haim, 2007/03/12
- RE: Missing interface that connects NSCoder to NSStream ?, Vaisburd, Haim, 2007/03/13
- RE: Missing interface that connects NSCoder to NSStream ?, Vaisburd, Haim, 2007/03/13
- Re: Missing interface that connects NSCoder to NSStream ?,
Helge Hess <=
- RE: Missing interface that connects NSCoder to NSStream ?, Vaisburd, Haim, 2007/03/14
- RE: Missing interface that connects NSCoder to NSStream ?, Vaisburd, Haim, 2007/03/14
- FW: Missing interface that connects NSCoder to NSStream ?, Vaisburd, Haim, 2007/03/15