> On 31 Jul 2018, at 18:28, Damien Pollet <damien.pollet+ph...@gmail.com> wrote:
> 
> Hi Sven… a couple questions:

Very interesting questions, Damien.

> - is there a preferred order of composition between the encoding and 
> buffering streams ? If yes, it the same for read and write stream, or 
> reversed ?
> E.g. if Stdio binaryStdin was implemented, Stdio stdin should be decoded, but 
> buffering it as well would be a problem for interactive applications.

Buffering typically makes a huge (an order of magnitude) difference since in 
most cases, bathing up a number of more expensive operations is a good idea. 
How big a difference depends on the access pattern (many small operations are 
more costly and big IO operation will not see much difference - actually 
ZnBuffered[Read|Write]Stream bypasses the buffer if more than have the buffer 
size is requested).

Buffering makes sense both at the lower binary level as well as at the 
character level. Benchmarks will tell.

I never thought about having a different buffering approach to reading and 
writing, but indeed that could make sense too.

There is also a cost to buffering: an additional indirection, management and 
memory usage.

> - what's your opinion on convenience composition messages, e.g. aBinaryStream 
> buffered decoded: 'utf-8' ?

I like these kinds of messages, but I keep saying that I prefer smaller stream 
APIs, not larger ones, hence I am hesitant to add more API (since every new 
stream has to understand these new cool messages).

> On Tue, 24 Jul 2018 at 10:13, Sven Van Caekenberghe <s...@stfx.eu> wrote:
> 
> 
> > On 23 Jul 2018, at 12:07, Sven Van Caekenberghe <s...@stfx.eu> wrote:
> > 
> > Stdio stdout and friends just return a binary stream, hence they need 
> > wrapping for encoding.
> > 
> > Maybe
> > 
> >  Stdio stdoutAsText
> > 
> > might be an idea, but this is so uncommon that I am not sure this is a good 
> > idea.
> 
> Given all remarks and comments (thanks BTW), I now think that
> 
> - textual stdio streams are the more common case
> - binary stdio streams are the primitive ones that are seldom used
> - another encoding than UTF-8 seems uncommon
> - these are streams that exist and need no real opening/closing
> 
> So,
> 
>   Stdio stdout
> 
> should return return a character write stream with UTF-8 encoding while
> 
>   Stdio binaryStdout
> 
> should be the lower level binary one.
> This would be more in line with the other streams.
> A non-UTF-8 encoding can be used as per Pavel's example.


Reply via email to