Time to start sending PRs [1], :P [1] https://github.com/search?utf8=%E2%9C%93&q=language%3Ac
I would hope that when this project is far enough along to feasibly do such a thing, that people don't. It's really rude.
Corrode: C to Rust translator written in Haskell
21–30 of 127 posts
Re: Corrode: C to Rust translator written in Haskell
#22I understand the world play, but perhaps it's a misunderstanding of Rusts name origin ? https://www.reddit.com/r/rust/comments/27jvdt/internet_archa... It's after a fungus https://en.wikipedia.org/wiki/Rust_(fungus)
This is of itself a misunderstanding of the origin: that's one of many reasons it's called Rust, not the only one. There's no single reason for the name.
Re: Corrode: C to Rust translator written in Haskell
#23I understand the world play, but perhaps it's a misunderstanding of Rusts name origin ? https://www.reddit.com/r/rust/comments/27jvdt/internet_archa... It's after a fungus https://en.wikipedia.org/wiki/Rust_(fungus)
Oh great, I can't wait to hear this "well, actually"[1] for the rest of my life. [1] https://www.recurse.com/manual#sub-sec-social-rules
... but that's a really good link that you provided. I've never read that before & it's a great resource for thinking about how to behave socially as a programmer. While I don't agree with all of it, I love their "don't pile-on" and "don't bring negativity from outside" approach. (Plus I'm guilty of the 'feigning surprise' rule.)
+1 for the really excellent link.
Re: Corrode: C to Rust translator written in Haskell
#24The name "Corrode" doesn't seem very positive given the purpose of this program...
You could say it's what this project does.
Re: Corrode: C to Rust translator written in Haskell
#25Earlier quoted context omitted.
> Because the project is still in its early phases, it is not yet > possible to translate most real C programs or libraries. It is currently trying to port over semantics exactly, so the Rust code is far from idiomatic Rust. Doesn't mean it's not useful, just saying that it's trying to be 1:1.
I guess the next stage would involve translating common non-idiomatic patterns into idiomatic Rust. Looks like this could be a job for a community-managed database!
Re: Corrode: C to Rust translator written in Haskell
#26as many "transpilers" / compilers, whatever you might name them, it lacks example input output. I want to see how my new rust code base looks light, does it compile with some heuritics, or just 1:1 C to rust primitives?
extern int printf(char *, ...);
int main(int argc, char argv[]) {
printf("Hello, world!\n");
return 0;
}
Was turned into: extern {
fn printf(arg1 : *mut u8, ...) -> i32;
}
#[no_mangle]
pub unsafe fn main(mut argc : i32, mut argv : *mut u8) -> i32 {
printf(b"Hello, world!\n\0".as_ptr() as (*mut u8));
0i32
}
edit: Also worth noting, it removes all comments. I believe this to be a limitation of language-c [1]Re: Corrode: C to Rust translator written in Haskell
#27Re: Corrode: C to Rust translator written in Haskell
#28Earlier quoted context omitted.
Oh great, I can't wait to hear this "well, actually"[1] for the rest of my life. [1] https://www.recurse.com/manual#sub-sec-social-rules
I was going to downvote you for a snarky response (I felt the reply explaining that Rust also has iron/oxidation references was a better response)... ... but that's a really good link that you provided. I've never read that before & it's a great resource for thinking about how to behave socially as a programmer. While I don't agree with all of it, I love their "don't pile-on" and "don't bring negativity from outside"…
Re: Corrode: C to Rust translator written in Haskell
#29Earlier quoted context omitted.
> Because the project is still in its early phases, it is not yet > possible to translate most real C programs or libraries. It is currently trying to port over semantics exactly, so the Rust code is far from idiomatic Rust. Doesn't mean it's not useful, just saying that it's trying to be 1:1.
I guess the next stage would involve translating common non-idiomatic patterns into idiomatic Rust. Looks like this could be a job for a community-managed database!
But that actually could work! Clippy has a ton of lints that make your code more idiomatic, and rustfix basically takes diagnostic output and applies suggestions (still WIP).
Clippy is geared towards making human-written unidiomatic code better, so it might not catch some silly things in this tool's output but or certainly could be extended to do that.