Earlier quoted context omitted.
https://github.com/rust-lang/rust/issues/26097
With the literate style, code is prefixed and comments are raw. So, instead of: -- foo is a function foo :: String -> String It's foo is a function > foo :: String -> String
Corrode: C to Rust translator written in Haskell
51–60 of 127 posts
Re: Corrode: C to Rust translator written in Haskell
#52Re: Corrode: C to Rust translator written in Haskell
#53Earlier quoted context omitted.
Here you go. It didn't like my stdio.h. Apparently enums and unions aren't supported, but: 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 noti…
Shouldn't a C `int` be converted to Rust's `isize`. I think that captures the spirit better.
Re: Corrode: C to Rust translator written in Haskell
#54Earlier 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"…
100% of English speakers who hear the word "rust" will first think of metal oxidation. "Correcting" people who make that "mistake" adds nothing of value to the conversation and just expresses "I know more than you" because you know some obscure minutia that was mentioned in an IRC channel once. Nerds love doing this "I'm smarter than you" kind of shit, so much so that it is developing its own noun, "well actually". It's obnoxious and distracting and contributes nothing, so I called it out.
Re: Corrode: C to Rust translator written in Haskell
#55The name "Corrode" doesn't seem very positive given the purpose of this program...
I've been looking at newer languages recently, and I see a lot of promise in Nim -- which renamed itself from Nimrod after users warned about what it connotes. Rust could take a cue.
Re: Corrode: C to Rust translator written in Haskell
#56Absolutely blown away by the detail of the documentation. The main logic of this project is in a literate haskell file you can easily read on GitHub. https://github.com/jameysharp/corrode/blob/master/src/Langua... I wonder how readable is to someone who isn't experienced in Haskell. To me reads like a breeze, but I have a project using the exact same parsing library so maybe that puts me at an advantage. The language…
Re: Corrode: C to Rust translator written in Haskell
#57Earlier quoted context omitted.
Here you go. It didn't like my stdio.h. Apparently enums and unions aren't supported, but: 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 noti…
Shouldn't a C `int` be converted to Rust's `isize`. I think that captures the spirit better.
On the other hand, at least for Unix systems `long` is often equivalent to Rust's `isize`: 32 bits for 32-bit architectures, and 64 bits for 64-bit architectures, so it would make sense to convert `long` to `isize`.
Re: Corrode: C to Rust translator written in Haskell
#58> Partial automation for migrating legacy code that was implemented in C. (This tool does not fully automate the job because its output is only as safe as the input was; you should clean up the output afterward to use Rust features and idioms where appropriate.) This was my immediate concern. Is there any chance this tool can produce anything close to clean, safe, idiomatic, rust code?
That is generally not possible, unless the C code only uses specific patterns known by the converter tool. That's very unlikely, considering that people write C code to be 'quick' and usually use all kinds of tricks.
Re: Corrode: C to Rust translator written in Haskell
#59Earlier quoted context omitted.
With the literate style, code is prefixed and comments are raw. So, instead of: -- foo is a function foo :: String -> String It's foo is a function > foo :: String -> String
Sorry, I am not understanding what you're implying here. I am well aware of the definition of literate programming. (And what you've said isn't actually enough to be considered literate programming under Knuth's definition: that's just tangle, still missing weave. Though notably, a lot of people argue that weave isn't needed with today's programming languages...)
Edit: I should have looked more closely, sorry.
Re: Corrode: C to Rust translator written in Haskell
#60The name "Corrode" doesn't seem very positive given the purpose of this program...
Well, it's just building off the same (negative) connotations of "Rust", which I think was itself a questionable name, trivial though it might seem. I've been looking at newer languages recently, and I see a lot of promise in Nim -- which renamed itself from Nimrod after users warned about what it connotes. Rust could take a cue.