4 ms·
I know that it's used for more than just C programs, but it still seems a little perverse to rewrite the C standard library in something other than C. Imagine i
by MichaelBurge 11y ago
I know that it's used for more than just C programs, but it still seems a little perverse to rewrite the C standard library in something other than C. Imagine if someone had a preference for writing his Python libraries in Perl that emitted Python bytecode. Or if C++'s Boost was the output of a Haskell program.
- dalailambda 11y agoOn the other hand, how many languages use libraries that are written in C? Especially in the higher level scripting language ecosystems(JS, Python, Lua) a lot of libraries interface with C/C++ libraries. If instead they used Rust, would that not result in a gain for those languages(even if there was a small C wrapper around it)?
- Santosh83 11y agoI get what you mean, but I guess calling it the "C Standard Library" is really a historical holdover from times when the entire system was written only in C (with the exception of a smattering of assembly). In the current context it should probably be called the "System Standard Library" and when you consider it like that, a system standard library in another language isn't all that weird. They all compile down to machine code anyway, so the Python-Perl analogy doesn't quite match.
- pjmlp 11y agoUNIX is the C runtime, kid of. They just didn't want to force it into other OSes when ANSI C was defined and eventually POSIX took up that role.
- _yosefk 11y agoActually many people have a preference for writing their Python libraries in C :-) Python was explicitly designed under the assumption that much of the heavy lifting will happen in C. And C programmers write their parsers in Yacc, etc. (This is not to say that rewriting libc is a good way for people knowing Rust to spend their time. It's a ton of effort with the result most likely to be unused and if it is used, then it provides a small benefit to C and C++ programs at the expense of a rather scarce resource - Rust developers - having been diverted from benefiting Rust programs. If I were a Rust enthusiast, I'd much rather write libraries in Rust designed to be used in Rust programs so that more such programs get written more quickly than use Rust to put lipstick on the pigs that are C and C++.)
- nickpsecurity 11y agoIt seemed perverse to me to write our desktops and servers in C given how it was "designed:" http://pastebin.com/UAQaWuWG http://pastebin.com/UAQaWuWG Once one understands it, getting rid of as much of it as possible makes a lot more sense. The replacement should ideally stand alone eventually, have stronger memory/type/integration safety, not assume what calls it (eg C code) will do things right, and integrate with C easily. Not sure how much Rust fits that as I lack details. Result would've eliminated all kinds of crashes and host compromises due to C-specific errors. It is ironic that one of the best ways for a C application to be safe while using 3rd party code is avoiding C in that 3rd party code. :)
- carussell 11y agoWhat about a C compiler written with C++? If it helps any, `getaddrinfo` is actually part of POSIX and not an essential part of C.