<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 20, 2016, at 9:44 AM, Jan Neumüller via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Alegreya-Regular; font-size: 15px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">What advantage? Streaming IO is a pain in the ****. I never got what people like at this stuff</span></div></blockquote><div><br class=""></div><div>Well for one, it abstracts away the source of the data. It could be a file, a TCP socket, an HTTP body, the output of another algorithm like a GZip codec, the output of another process. One of the big innovations of Unix was the ability to build small tools and chain them together using pipes.</div><br class=""><blockquote type="cite" class=""><div class=""><span style="font-family: Alegreya-Regular; font-size: 15px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Even in my windows days I always used the much better memory mapped file IO.&nbsp;</span></div></blockquote><br class=""></div><div>Memory mapping is great, but it has limitations and pitfalls.</div><div>* You can only use it on filesystems that can’t be unmounted, otherwise if the filesystem disconnects, accessing the memory will crash.</div><div class="">* It ties up a file descriptor for as long as you need to use the data. File descriptors are a limited resource.</div>* It requires having contiguous free address space equal to the size of the file. I have seen this cause real-world failures in 32-bit processes.<div class="">* I’m told that iOS limits the amount of memory-mapped address space an app can allocate, even if it’s a 64-bit process. (I have been meaning to test whether this is actually true.)</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><span style="font-family: Alegreya-Regular;" class="">Is streaming IO some kind of C/C++ sickness like macros and templates?</span><br style="font-family: Alegreya-Regular;" class=""></blockquote><br class=""></div><div class="">This isn’t a Playstation-vs-Xbox debate. The mature developer understands that everything has pros and cons.</div><div class=""><br class=""></div><div class="">—Jens</div></body></html>