c2rust VS librope

Compare c2rust vs librope and see what are their differences.

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
c2rust librope
46 4
3,673 265
2.7% -
9.5 0.0
6 days ago over 2 years ago
Rust C
GNU General Public License v3.0 or later GNU General Public License v3.0 or later
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

c2rust

Posts with mentions or reviews of c2rust. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2024-01-10.
  • Converting the Kernel to C++
    3 projects | news.ycombinator.com | 10 Jan 2024
    A recent practical example of the former: the fish shell re-wrote incrementally from C++ to Rust, and is almost finished https://github.com/fish-shell/fish-shell/discussions/10123

    An example of the latter: c2rust, which is a work in progress but is very impressive https://github.com/immunant/c2rust

    It currently translates into unsafe Rust, but the strategy is to separate the "compile C to unsafe Rust" steps and the "compile unsafe Rust to safe Rust" steps. As I see it, as it makes the overall task simpler, allows for more user freedom, and makes the latter potentially useful even for non-transpiled code. https://immunant.com/blog/2023/03/lifting/

  • Best tools to convert code between languages?
    1 project | /r/learnprogramming | 11 Apr 2023
    But not all transpilers are between languages where at least one of them is designed to be transpiled. For example, c2rust can transpile, as the name suggests, C to (ugly, unsafe) Rust. A while ago there was a Java -> C compiler in GCC (GCJ), but it's pretty out of date now.
  • Translate C code to Rust working with libc
    1 project | /r/rust | 3 Apr 2023
    I do not know about your specific issue but you may be interested by https://github.com/immunant/c2rust
  • Rewrite in Rust or Use Rust-bindings
    1 project | /r/rust | 21 Mar 2023
    You should also consider using C2Rust (they're even working on C -> safe Rust translation)
  • Emitting Safer Rust with C2Rust
    3 projects | news.ycombinator.com | 15 Mar 2023
    > The date at the bottom of the article is 2022-06-13. Has there been further progress?

    The article links to their github repo:

    https://github.com/immunant/c2rust

    There's commits in the last hour, so at least some signal of life.

  • Writing an OS in Rust to run on RISC-V
    8 projects | news.ycombinator.com | 1 Mar 2023
    This is arguably already the state of things.

    Rust might get compiled down through MIR, down through LLVM IR, down to assembly or wasm... which then might be JIT or AOT (re)compiled into other bytecodes... which might perhaps be decompiled back up to C... and C might be retranslated back to horrific unsafe-spamming Rust by the likes of https://c2rust.com/. We've come full circle!

    The main issue is that retranslating high level languages into other high level languages isn't something that there's actually a lot of demand for, especially commercially, especially given the N x M translation matrix going on. So a lot of the projects "stabilize" (get abandoned). And automatically translating between the idioms of those languages gets even nastier in terms of matrix bloat.

    Well, you've got stuff like MSIL and JVM bytecodes which are higher level, and preserve more type information, and can be compiled to / decompiled from while still preserving more structure, but they still form competing incompatible ecosystems.

  • Will Carbon Replace C++?
    14 projects | news.ycombinator.com | 27 Feb 2023
    That's the wrong direction. What's needed are intelligent converters which convert less-strict languages to more-strict ones.

    Non-intelligent converters just make a mess. Here's c2rust.[1]

    Classic C++ to modern C++, plus a compiler flag to lock out all the old unsafe stuff, would be an achievement.

    [1] https://c2rust.com/

  • What would you rewrite in Rust?
    44 projects | /r/rust | 11 Feb 2023
  • Red Black Tree in Rust
    4 projects | /r/rust | 4 Jan 2023
    Well, technically, it's not hard to build such data structures. If you are willing to liberally use raw pointers, UnsafeCell, MaybeUninit and ManuallyDrop, then you can more-or-less write C-equivalent code in unsafe Rust. (there are even transpilers from C to Rust)
  • In Rust We Trust – A Transpiler from Unsafe C to Safer Rust
    1 project | /r/programmingcirclejerk | 5 Dec 2022
    /uj This transpiles from C to unsafe Rust using an existing tool, then strips the unsafe keyword from the generated function signatures

librope

Posts with mentions or reviews of librope. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2022-12-03.
  • Show HN
    3 projects | news.ycombinator.com | 3 Dec 2022
  • The case against an alternative to C
    9 projects | news.ycombinator.com | 8 Aug 2022
    Yep. A few years ago I implemented a skip list based rope library in C[1], and after learning rust I eventually ported it over[2].

    The rust implementation was much less code than the C version. It generated a bigger assembly but it ran 20% faster or so. (I don't know why it ran faster than the C version - this was before the noalias analysis was turned on in the compiler).

    Its now about 3x faster than C, thanks to some use of clever layered data structures. I could implement those optimizations in C, but I find rust easier to work with.

    C has advantages, but performance is a bad reason to choose C over rust. In my experience, the runtime bounds checks it adds are remarkably cheap from a performance perspective. And its more than offset by the extra optimizations the rust compiler can do thanks to the extra knowledge the compiler has about your program. If my experience is anything to go by, naively porting C programs to rust would result in faster code a lot of the time.

    And I find it easier to optimize rust code compared to C code, thanks to generics and the (excellent) crates ecosystem. If I was optimizing for runtime speed, I'd pick rust over C every time.

    [1] https://github.com/josephg/librope

    [2] https://github.com/josephg/jumprope-rs

  • Why Is C Faster Than Java (2009)
    8 projects | news.ycombinator.com | 26 Dec 2021
    > it’s not clear if this will be a positive for native dev advocacy

    I've rewritten a few things in rust. Seems pretty positive to me, because you can mix some of the best optimizations and data structures you'd write in C, with much better developer ergonomics.

    A few years ago I wrote a rope library in C. This is a library for making very fast, arbitrary insert & delete operations in a large string. My C code was about as fast as I could make it at the time. But recently, I took a stab at porting it to Rust to see if I could improve things. Long story short, the rust version is another ~3x faster than the C version.

    https://crates.io/crates/jumprope

    (Vs in C: https://github.com/josephg/librope )

    The competition absolutely isn't fair. In rust, I managed to add another optimization that doesn't exist in the C code. I could add it in C, but it would have been really awkward to weave in. Possible, but awkward in an already very complex bit of C. In rust it was much easier because of the language's ergonomics. In C I'm using lots of complex memory management and I don't want to add complexity in case I add memory corruption bugs. In rust, well, the optimization was entirely safe code.

    And as for other languages - I challenge anyone to even approach this level of performance in a non-native language. I'm processing ~30M edit operations per second.

    But these sort of performance results probably won't scale for a broader group of programmers. I've seen rust code run slower than equivalent javascript code because the programmers, used to having a GC, just Box<>'ed everything. And all the heap allocations killed performance. If you naively port python line-by-line to rust, you can't expect to magically get 100x the performance.

    Its like, if you give a top of the line Porsche to an expert driver, they can absolutely drive faster. But I'm not an expert driver, so I'll probably crash the darn thing. I'd take a simple toyota or something any day. I feel like rust is the porsche, and python is the toyota.

  • Rust is now overall faster than C in benchmarks
    9 projects | news.ycombinator.com | 3 Jan 2021
    > I have no idea whether that matters or even easy to measure...

    It is reasonably easy to measure, and the GP is about right. I've measured a crossover point of around a few hundred items too. (Though I'm sure it'll vary depending on use case and whatnot.)

    I made a rope data structure a few years ago in C. Its a fancy string data structure which supports inserts and deletes of characters at arbitrary offsets. (Designed for text editors). The implementation uses a skip list (which performs similarly to a b-tree). At every node we store an array of characters. To insert or delete, we traverse the structure to find the node at the requested offset, then (usually) memmove a bunch of characters at that node.

    Q: How large should that per-node array be? A small number would put more burden on the skip list structure and the allocator, and incur more cache misses. A large number will be linearly slower because of all the time spent in memmove.

    Benchmarking shows the ideal number is in the ballpark of 100-200, depending on CPU and some specifics of the benchmark itself. Cache misses are extremely expensive. Storing only a single character at each node (like the SGI C++ rope structure does) makes it run several times slower. (!!)

    Code: https://github.com/josephg/librope

    This is the constant to change if you want to experiment yourself:

    https://github.com/josephg/librope/blob/81e1938e45561b0856d4...

    In my opinion, hash tables, btrees and the like in the standard library should probably swap to flat lists internally when the number of items in the collection is small. I'm surprised more libraries don't do that.

What are some alternatives?

When comparing c2rust and librope you can also consider the following projects:

min-sized-rust - πŸ¦€ How to minimize Rust binary size πŸ“¦

mu - Soul of a tiny new machine. More thorough tests β†’ More comprehensible and rewrite-friendly software β†’ More resilient society.

subsurface - This is the official upstream of the Subsurface divelog program

c3c - Compiler for the C3 language

checkedc - Checked C is an extension to C that lets programmers write C code that is guaranteed by the compiler to be type-safe. The goal is to let people easily make their existing C code type-safe and eliminate entire classes of errors. Checked C does not address use-after-free errors. This repo has a wiki for Checked C, sample code, the specification, and test code.

proposal-explicit-resource-management - ECMAScript Explicit Resource Management

zz - πŸΊπŸ™ ZetZ a zymbolic verifier and tranzpiler to bare metal C [Moved to: https://github.com/zetzit/zz]

jumprope-rs

rtorrent - rTorrent BitTorrent client

buffet - All-inclusive Buffer for C

langs

search-benchmark-game - Search engine benchmark (Tantivy, Lucene, PISA, ...)