Weird
Weird
Posted Aug 15, 2016 19:39 UTC (Mon) by halla (subscriber, #14185)In reply to: Weird by excors
Parent article: Better types in C using sparse and smatch
a) use a C library
b) handle file io and other standard stuff
c) provide a base for the C++ libraries to build onto
d) make it possible to write plugins in C++ or Python that this core library can load
I'm sure the a) and b) are provided for -- but I cannot figure out whether c) and d) are possible.
Posted Aug 15, 2016 19:49 UTC (Mon)
by Cyberax (✭ supporter ✭, #52523)
[Link] (12 responses)
Rust also is really easy to expose to C or C++, it doesn't have any runtime with garbage collector or static initializers that live before main(). You really can treat it as a safe version of C.
Of course, translating a huge codebase is not going to be easy. To get advantage of Rust you really need to encode Rust's notion of ownership into the interface with C/C++ and that's not always trivial.
Posted Aug 15, 2016 19:56 UTC (Mon)
by halla (subscriber, #14185)
[Link] (2 responses)
Posted Aug 16, 2016 3:12 UTC (Tue)
by ncm (guest, #165)
[Link] (1 responses)
Posted Aug 19, 2016 15:15 UTC (Fri)
by ncm (guest, #165)
[Link]
Posted Aug 17, 2016 22:46 UTC (Wed)
by lsl (subscriber, #86508)
[Link] (8 responses)
Not quite, as you must not fork a program linked to Rust code. You only get a spawn-like interface where the runtime takes care to safely fork the program, followed by an immediate call to exec (just like with Go).
Did this really change recently? Not long ago, the Rust developers' position was something along the lines of "fork won't ever be safe to do in Rust".
Posted Aug 17, 2016 23:06 UTC (Wed)
by Cyberax (✭ supporter ✭, #52523)
[Link] (7 responses)
You can fork as much as you want with Rust. It doesn't create any threads behind the scenes.
Of course, if you use TLS or create threads yourself then you're on your own.
Posted Aug 17, 2016 23:40 UTC (Wed)
by lsl (subscriber, #86508)
[Link] (6 responses)
Posted Aug 17, 2016 23:54 UTC (Wed)
by Cyberax (✭ supporter ✭, #52523)
[Link] (3 responses)
Posted Aug 18, 2016 2:02 UTC (Thu)
by lsl (subscriber, #86508)
[Link] (2 responses)
So while the new Rust with mostly-excised runtime itself might be used in forking programs, touching the standard library is still considered to result in nasal demons by its developers.
Posted Aug 18, 2016 3:32 UTC (Thu)
by Cyberax (✭ supporter ✭, #52523)
[Link]
Standard library does NOT run any background threads and RNG duplication might be an expected outcome.
I can't find any recent admonitions to not use libstd in forking programs and having actually used it, I kinda doubt that there are any serious issues.
Posted Aug 23, 2016 20:43 UTC (Tue)
by mathstuf (subscriber, #69389)
[Link]
Posted Aug 18, 2016 8:55 UTC (Thu)
by farnz (subscriber, #17727)
[Link] (1 responses)
I can't find any such limitation in versions of Rust post the decision to not use a green-threading model. In prerelease versions, the userspace thread manager could get confused by fork(), but the thread manager has gone away.
Posted Aug 18, 2016 9:46 UTC (Thu)
by micka (subscriber, #38720)
[Link]
Especially from comment
which states (if I understand correctly) that it was unsafe to fork when rust used a runtime, but when the runtime was removed, the only problem left was the hashmap implementation using a rng with a shared seed (the rng being used to prevent DOS by hashmap collision).
Weird
Weird
Weird
Weird
Weird
Weird
Weird
Weird
Weird
Weird
Really? How? Borrow checker is entirely compile time and after forking the new copy will go on independently.
Weird
Weird
Weird
https://github.com/rust-lang/rust/issues/16799
https://github.com/rust-lang/rust/issues/16799#issuecomme...