Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

It's quite like any other C codebase, especially the driver code Rust is targetting initially.


sort by: page size:

Isn't that rust thing just a binding to the C library?

Is it purely rust? or some C dependencies are there currently?

It's all good. For what it's worth, I agree with you generally that a lot of the C code I see is like, "differently shaped" than the Rust, so it's not super simple to port directly over.

I find it ironic that the "system" that you're writing Rust code for is entirely built in C :)

It's a C library. If it were a Rust or C++ library it would be written in those languages.

"the libc is written in Rust"

This is cool, are there any downsides to calling Rust code from C? I guess it's basically a black box that behaves like a regular C library from the outside?


I don’t understand how Just being written in rust as opposed to C has anything to do with this?

Ok, maybe stupid: why the core is in C and not Rust? Easy to targeting?

Is this purely rust? Or is there some C code dependencies? If yes, can you share the breakup of language composition in the codebase?

nothing, but a programmer who does so knows they are creating an abomination while in C, it's just a normal day. (and for anyone looking at the code, the rust version will look like a buggy mess, while the C version will look like correct C code).

My understanding is that this exposes a C ABI so that it's not purely for Rust programs.

> Also it's written in Rust

The core library is in C.


The C version was ported to be the Rust one, it seems, and uses those intrinsics too. And, eventually this code will get to be a bit higher level while having the same output; those libraries are still a bit experimental though.

Overall, good points!


It shares the code generator with gcc. It doesn't transpile C to Rust or vice versa. The goal is to produce machine code directly.

It is. I haven’t checked the complete source code. What I know for sure is that a program using Rust’s std still requires the C runtime to link and run, and from that perspective, it doesn’t really matter if some or even many parts of the std don’t actually use it.

I haven't used it yet, but Rust supposedly works very well with C libraries, both calling into them and being called from them.

Rust can be compiled to be called from C too.

It's the same as the normal rust compiler. The support demands are pretty much identical to open source rust.

The post does address this and shows their attempt to produce higher quality Rust. I've also seen it used to move off of a C toolchain and onto a pure Rust toolchain by porting C code to Rust.
next

Legal | privacy