News for hackers. Stuff that matters.
Re:Announcing Rust 1.20 by steveklabnik on Thursday August 31, 2017 @06:52PM (#15144662)
Rust doesn't have any more runtime than C, and also doesn't have a GC. Servo has bindings into SpiderMonkey's GC so that the JavaScript stuff works properly, but that's only that part.

That said, I don't think there are any direct blog posts about it; Firefox's other code just sees Rust as C code, as far as I know. (I don't work on Firefox though so I could be wrong about some details.)

Re:Announcing Rust 1.20 by oscargrouch on Thursday August 31, 2017 @07:08PM (#15144772)
> That said, I don't think there are any direct blog posts about it; Firefox's other code just sees Rust as C code, as far as I know.

So it means the compiled binary ends up in a simple compatible C ABI? thats pretty nice, if thats the case.

But giving the project is using LLVM, even C++ ABI would be achievable without too much effort (i guess).

Re:Announcing Rust 1.20 by burntsushi on Thursday August 31, 2017 @07:18PM (#15144828)
To clarify, Rust has its own ABI, just like C++ has its own ABI. And just like C++, you can expose a C ABI if you want by defining special functions. In C++, it's an `extern "C" { ... }` block, and in Rust, it's a `extern "C" fn foo() ...` function declaration. You can see an example here: https://github.com/rust-lang/regex/tree/master/regex-capi

Adding C++ ABI support is a significant effort.

Re:Announcing Rust 1.20 by oscargrouch on Friday September 01, 2017 @05:23AM (#15147138)
> To clarify, Rust has its own ABI, just like C++ has its own ABI. And just like C++, you can expose a C ABI if you want by defining special functions. In C++, it's an `extern "C" { ... }` block, and in Rust, it's a `extern "C" fn foo() ...` function declaration.

Ohh, Now i got it. But its pretty good thing to have anyway. C ABI is the lingua franca anyway to communicate to any language, even C++.

> Adding C++ ABI support is a significant effort.

Ok. So if has its own ABI, im sure it would be a pretty hard undertaking to be compatible with C++.

I was guessing if maybe Rust had managed to squeeze and reuse the C++ ABI.. but sure, giving Rust is not that much alike C++ this would probably be a bad decision for small gains.

Thanks for clarifying.

Re:Announcing Rust 1.20 by vvanders on Thursday August 31, 2017 @11:24PM (#15145885)
Yup, with bindgen and rusty-cheddar you can build interfaces both ways that just talk over a C ABI. It's really, really nice.

In fact Rust in general is awesome for going to a wide range of platforms. I've got a project right now that runs on MSVC-x64/x86, Linux-x64, OSX-x64, Android-armv7, Android-x86, Linux-armv7 and Emscripten. Single codebase and interacting with various languages(C#, C++, Java) via the C ABI. Rust even cross-compiles my C source via GCC crate so I can use C libraries and build for any of those targets from my host(win32) machine.

Also, having just spent a few hours fucking around with linker flags in Qt I can't stress enough how awesome Cargo, Crates.io, Rustup and the sane defaults Rust has. It really is an incredible ecosystem.

Re:Announcing Rust 1.20 by Manishearth on Thursday August 31, 2017 @07:53PM (#15145029)
bindgen actually has the option to generate wrappers for C++ methods and other stuff for Rust to call. We don't use this, but we do use its ability to generate templates and stuff.

The other way around -- getting Rust to use the C++ abi -- needs compiler changes and also has questionable benefits.

Re:Announcing Rust 1.20 by oscargrouch on Friday September 01, 2017 @05:24AM (#15147143)
> getting Rust to use the C++ abi -- needs compiler changes and also has questionable benefits.

Yes.. Im sure is not worthy it overall.

Re:Announcing Rust 1.20 by smegel on Thursday August 31, 2017 @07:03PM (#15144725)
I swear I had read Rust had optional GC at one point. And similarly Rust wanting to own main(). Maybe not then.
Re:Announcing Rust 1.20 by burntsushi on Thursday August 31, 2017 @07:07PM (#15144758)
I don't know the precise history, but at one point, it did have a "gc" type, which I believe was demarcated by the `@` sigil. So, for example, `@T` was a garbage collected pointer to `T`. IIRC, the actual garbage collector was simplistic, and was mostly just reference counting under the hood. At some point (in 2014, I think), the GC type went away. Since then, there has never been any serious talk of adding an optional GC to Rust proper, although many folks have worked/written about writing their own.
Re:Announcing Rust 1.20 by steveklabnik on Thursday August 31, 2017 @07:26PM (#15144879)
This is pretty accurate; however, a very long time ago there was a tracing GC!
Re:Announcing Rust 1.20 by iopq on Thursday August 31, 2017 @08:15PM (#15145149)
Are you sure? I thought @ was reference counted in 0.6 and then removed after. Was it before that?
Re:Announcing Rust 1.20 by steveklabnik on Thursday August 31, 2017 @08:29PM (#15145219)
I don't have any citation beyond "Graydon told me one time". It was like, very very long ago, possibly before @T even existed.
Re:Announcing Rust 1.20 by Rusky on Thursday August 31, 2017 @10:09PM (#15145612)
IIRC it was a mark and sweep GC in the OCaml implementation.
Re:Announcing Rust 1.20 by steveklabnik on Thursday August 31, 2017 @11:11PM (#15145830)
That sounds about right.
Re:Announcing Rust 1.20 by jacobush on Friday September 01, 2017 @03:27AM (#15146775)
Wow, I can't believe I have been reading up lately on official Rust documentation and still I was under the impression that Rust had optional GC. Thanks for sorting me out...
Re:Announcing Rust 1.20 by kbenson on Friday September 01, 2017 @08:21PM (#15153380)
Well, I think is sort of does when you use the Rc types, right? It's just much more explicit than a type modifier, it's a type wrapper that requires requires some level of additional code ornamentation in some instances when using later as well. It's just not really any different than using a library in C++ that offers the same, except that in Rust's case the library is part of the stdlib.
Re:Announcing Rust 1.20 by steveklabnik on Thursday August 31, 2017 @07:35PM (#15144929)
Rust had almost everything at some point :)

Rust binaries do define a "main", and setting that up is the runtime's job, like C. But you can also make a library that needs no main at all.