Re:Sans-IO: The secret to effective Rust for network services
by wh33zle on Thursday July 04, 2024 @07:40AM
(#40874082)
The line between applications and libraries is fairly blurry, isn't it? In my experience, most applications grow to the point where you have internal libraries or could at least split out one or more crates.
I would go as far as saying that whatever functionality your application provides, there is a core that can be modelled without depending on IO primitives.
Re:Sans-IO: The secret to effective Rust for network services
by K0nserv on Thursday July 04, 2024 @08:43AM
(#40874467)
Yes true, the one difference might be that you don't expect other consumers with a different approach to IO to use your internal libraries, although it does help you if you want to change that in the future and the testability is still useful
Re:Sans-IO: The secret to effective Rust for network services
by binary132 on Thursday July 04, 2024 @01:43PM
(#40876706)
In my eyes an ideal library should not contain state, internally allocate (unless very obviously), or manage processes. The application should do that, or provide primitives for doing it which the library can make use of. That makes applications and libraries very very different in my mind.
Re:Sans-IO: The secret to effective Rust for network services
by K0nserv on Thursday July 04, 2024 @03:21PM
(#40877349)
The thing about state is a good point. With the sans-IO pattern we have inversion of IO and Time, but adding memory to that would be a nice improvement too.
Re:Sans-IO: The secret to effective Rust for network services
by binary132 on Thursday July 04, 2024 @04:41PM
(#40877882)
Those C libraries that have initializers which take ** and do the allocation for you drive me nuts! I’m sure there’s some good reason, but can’t you trust me to allocate for myself, you know?
My feeling is that sans-IO is particularly useful for libraries, although it can be used for applications too. In a library it means you don't force decisions about how I/O happens on your consumer, making it strictly more useful. This is important for Rust because there's already a bunch of ecosystem fragmentation between sync and async IO(not to mention different async runtimes)