Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Regarding runtime overhead, I'd assume you would still need an io implementation, it is just showing it to you explicitly instead of it being hidden behind the std lib.

For simple projects where you don't want to pass it around in function parameters, you can create a global object with one implementation and use it from everywhere.



You still have to pass arguments to library functions that need to allocate or do I/O ... but the alternative is worse. This is really a bogus issue ... no one is crying over having to pass a `this` pointer to every single call of a method in other languages. Context pointers are a requirement in any sizeable or multi-threaded program, and Zig gives the user full control over what the context object looks like.


Yeah thing is it's usually better to have allocator in particular defined as a parameter so that you can use the testing allocator in your tests to detect memory leaks, double frees, etc. And then you use more optimal allocators for release mode.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: