5 ms·
Rust is yes to both, although 'the runtime' is disappearing, replaced by just using the system APIs directly (that is, Rust will have no runtime beyond what C/C
by dbaupp 12y ago
Rust is yes to both, although 'the runtime' is disappearing, replaced by just using the system APIs directly (that is, Rust will have no runtime beyond what C/C++ has). The non-Rust code in the main distribution is:
- LLVM for the complier
- hoedown (markdown parser/renderer) for the documentation generator
- miniz for compressing the metadata stored in each library
- a few other tiny wrappers[1] for which I see no reason other than inertia/low-priority for translating into Rust (e.g. there would be no particular build-system benefit to Rustifying them because C/C++ compilers are needed for the other things anyway)
[1]: https://github.com/rust-lang/rust/tree/master/src/rt https://github.com/rust-lang/rust/tree/master/src/rt (the 'rt' = runtime name is a holdover from when the runtime was not written in Rust)
- AceJohnny2 12y ago> beyond what C/C++ has Whoa now, let's not go lumping C and C++ together! C++ has quite a heavier runtime to manage stuff like exceptions and RTTI! (though, to be honest, I don't know what's a C++ program's runtime requirement if compiled with -fno-exceptions, -fno-rtti and the like)
- stormbrew 12y agoGenerally speaking the heavy part of both exceptions and rtti are in codegen (ie. the amount of code generated by the compiler), not in the 'runtime'. Exception jump tables and typeinfo objects are calculated as part of the compile and just referred to at run time. For example, this is the part of libsupc++ (effectively gnu's c++ "runtime") that deals with throwing: https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/libsupc%2B%2B/eh_throw.cc https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-...
- kijiki 12y agoIf you disable rtti and exceptions, the only piece that needs runtime support is global constructors. I've done it in the past with linker tricks to generate an ELF section with the list of ctor addresses. The asm that calls main (which if you're rolling your own runtime, you probably wrote as well) just calls them all right before it calls main().
- pjmlp 12y agoC also has a runtime. It is called UNIX (POSIX).
- qznc 12y ago--freestanding
- kedean 12y agoI define a language without a runtime as one that can run on bare metal without restricting yourself to a subset of the language. To use C on bare metal, the only thing you can't use is the standard library, which is not a part of the language itself (its not in the grammar, you don't need to make sure to avoid certain keywords). More simply, any program written without using an import needs to work without an operating system under it. C++ requires runtime support because if you remove the underlying system, it becomes stunted. Keywords like 'new' and 'delete' stop working entirely, and so a program with no imports is not guaranteed to work. Any language with a GC falls under this, obviously. Rust, if I remember right, requires restricting yourself in order to do things like kernel writing.
- steveklabnik 12y ago> Rust, if I remember right, requires restricting yourself in order to do things like kernel writing. Nope, you just lose the standard library, and have to implement a few language intrinsics yourself.
- kedean 12y agoThat sounds kind of like what I mean. I consider it having a runtime if anything that can be used without importing the standard library won't work out of the box when you boot a machine to it.
- steveklabnik 12y agoWell, the 'standard library' is a bit of a flexible concept in Rust. We have 'libcore' and 'libstd'. core is what's still usable without any runtime support whatsoever, and std does. I mean, none of Rust's _features_ don't work without runtime support, but libraries that need tasks (threads) and task unwinding require the runtime. Those are all library features not language features.
- amelius 12y agoYou say that the runtime is disappearing. But, if LLVM is being used, then since it provides the JIT, I'd say it is a really big part of the runtime, actually.
- steveklabnik 12y ago> since it provides the JIT, Rust doesn't use a JIT, LLVM provided or not.
- dbaupp 12y agoThe "VM" in LLVM is deceiving (and LLVM actually no longer stands for "low-level virtual machine"), its main use now is as an ahead-of-time optimiser/code-generator for the Clang C & C++ compiler. Rust uses it in this capacity too: optimised native code is emitted at compile time and no JITing is necessary. Of course, LLVM can be used as a JIT (e.g. what Apple is doing with javascript), but Rust does not use or need it.
- masklinn 12y ago> Of course, LLVM can be used as a JIT (e.g. what Apple is doing with javascript) Even then, assuming you're talking about FTL LLVM is "just" a codegen backend (w/ optimisations) for an existing JIT pipeline, most of the JIT infrastructure is outside LLVM.