this post was submitted on 21 Dec 2023
2 points (100.0% liked)
Linux
48077 readers
707 users here now
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Rules
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
It’s a system programming language that isn’t C or C++.
Edit to add: How did Go get on that page? That’s a stretch.
That would complicate things even more.
Rust has pretty sophisticated guarantees in terms of memory safety. If you'd add the step of another compiler, you'd have to guarantee that a) the transpiler still produces memory safe C and that a given C compiler actually turns that C code into memory safe assembler.
BTW: you don't have to rewrite everything immediately, you can integrate rust into existing C and vice versa. Apparently it's not trivial, but possible. See https://wiki.mozilla.org/Oxidation
(notice: I am not a Rust or C/C++ expert)
Doing all that is creating a completely separate programming language from C. Rust is that programming language.
Rust does that with modules and crates.
You mean having consistent/universal style guidelines? Rust pretty much has that with rustfmt.
Safe Rust is memory safe (using things like the borrow checker), and Unsafe Rust is (usually?) separated using the
unsafe
keyword.Although Unsafe Rust seems to be quite a mess, idk haven't tried it
Rust has macros, iterators, lambdas, etc. C doesn't have those. C++ probably has those but in a really weird C++ way.
I'd say no. Programming safely requires non-trivial transformation in code and a radical change in style, which afaik cannot be easily done automated.
Do you think that there's any chance to convert from this to this? It requires understanding of the algorithm and a thorough rewrite. Automated tools can only generate the former one because it must not change C's crooked semantics.
Those do exist for rust. https://github.com/immunant/c2rust
It produces a pretty much 1:1 mirror of the c program which means that it's still wildy unsafe and nonidiomatic rust.
But then you can go ahead and part by part convert to safe and idiomatic rust.