4 ms·
First and foremost that Rust is a systems programming language that shouldn't have any kind of implicit runtime. If you run any implicit eventloop, that proper
by Matthias247 5y ago
First and foremost that Rust is a systems programming language that shouldn't have any kind of implicit runtime.
If you run any implicit eventloop, that property would no longer be given.
Next, it wouldn't even be desirable for lots of applications. Async IO and functions are not necessarily be faster than synchronous operations - it might as well the opposite if you don't have a lot of concurrency. E.g. if you read from one blocking socket, you do a single `read()` syscall. Add async IO, and you need an additional `select/epoll_wait` call.
Then there is an actual cost for composing Futures which are large values on the stack, sometimes having to box them (since otherwise recursion won't work and dynamic dispatch will neither, etc). The latter might certainly be avoidable with a different kind of "async design" than what Rust currently has, but there will always be some tradeoffs.
- pjmlp 5y agoC and C++ happen to have a runtime, or whatever you feel like calling the code that calls main(), runs functions registered on executable load, registered atexit(), soft floating point emulation, running constructors/destructors on start/exit, handling exceptions, threading support.
- deleted 5y ago[deleted]
- scoutt 5y agoBut it's not implicit and/or required. In embedded you can use C/C++ without a runtime. > calling the code that calls main(), runs functions registered on executable load, registered atexit(), soft floating point emulation, running constructors/destructors on start/exit, handling exceptions, threading support. You call main() (or whatever) from your reset handler, there is no "executable load", there is no "atexit()", floating point can be hard-instructions (if available), call __libc_init_array() to call constructors if required, you usually don't use exception handling, and of course there is no threading support. Perhaps you can call "runtime" the instructions inserted to call constructors/destructors but I think it doesn't qualify.
- pjmlp 5y agoA runtime is everything that the compiler generates in addition to the code that is written so that it runs at all. The embedded use of C and C++ dialects rely on compiler specific extensions and are per ISO standard implementation-defined, without any guarantee of code portability as per freestanding definition.