Live data from Hacker News

Rust to C compiler – 95.9% test pass rate, odd platforms

fractalfir.github.io

231–240 of 264 posts

Re: Rust to C compiler – 95.9% test pass rate, odd platforms

#231
post #71
post #65

Earlier quoted context omitted.

It is not terribly hard to generate C code that does not use undefined behavior.

Maybe. But when carefully investigated, the overwhelming majority of C code does in fact use undefined behaviour, and there is no practical way to verify that any given code doesn't.

It is easy to create code where this can be verified. It is difficult to verify for arbitrary code.

Re: Rust to C compiler – 95.9% test pass rate, odd platforms

#232
post #142

Earlier quoted context omitted.

It is, but it is still tiny compared to C/C++. And many people also do not like it.

There are two categories of people who don’t like Rust: 1. C/C++ developers who are used to C/C++ and don’t want to learn Rust. 2. Go developers who claim Rust is too difficult and unreadable. Which one is you?

I think the "don't want to learn" is a very poor argument. I learn stuff every day, but I want want to decide myself what I learn to solve my problems, not because Rust folks think everybody has to learn Rust now. I learned a bit of Rust out of curiosity, but not so much I could do a lot with it. I do not want to learn more, because I think the language has severe flaws and and much less suitable than C for my use cases.

Re: Rust to C compiler – 95.9% test pass rate, odd platforms

#233
post #216

Earlier quoted context omitted.

Fair point on CSRs, though I'd count that as a subset of unsupported/not-yet-specified instructions; pretty sure all of the "reserved"s in the spec are effectively not-yet-defined instructions too, which'll have equivalents in any architecture with encoding space left for future extensions, not at all unique to RISC-V. But yeah, no try-running-potentially-unsupported-things-to-discover-what-is-supported; essentially…

Yeah I guess the difference is once an instruction/CSR has been defined in x86 or ARM the only two options are a) it doesn't exist, and b) it's that instruction. In RISC-V it can be anything even after it has been defined. Actually... I say that, but they do actually reserve spaces in the CSR and opcode maps specifically for custom extensions so in theory they could say it's only undefined behaviour in those spaces a…

On getting supported extension status - there's a C API spec that could potentially become an option for an OS-agnostic way: https://github.com/riscv-non-isa/riscv-c-api-doc/blob/main/s.... libc already will want to call whatever OS thing to determine what extensions it can use for memcpy etc, so taking the results from libc is "free".

Re: Rust to C compiler – 95.9% test pass rate, odd platforms

#234
post #208

Earlier quoted context omitted.

It really is not that complicated. You just use -llibrary when linking and it links.

Oh I never realized I was supposed to install -dev packages, I thought I had to compile myself.

Whether you need -dev packages (for headers) depends on your operating system. I run Gentoo. All headers are always on the system. Other distributions ship the headers separately in -dev packages to save space and you need to install them. You likely can install all -dev packages for everything on your system so you do not need to get the individual ones.

Re: Rust to C compiler – 95.9% test pass rate, odd platforms

#235
post #212

Earlier quoted context omitted.

Are you unable to use search engines: https://www.learn-c.org/ There are so many free learning resources for these languages that it is ridiculous to say that you need books to learn them. The books are great, but non-essential. If you insist on reading books, there is an ancient invention called a library that you can use for free.

What C standard does that website describe?

[deleted]

Re: Rust to C compiler – 95.9% test pass rate, odd platforms

#236
post #212

Earlier quoted context omitted.

Are you unable to use search engines: https://www.learn-c.org/ There are so many free learning resources for these languages that it is ridiculous to say that you need books to learn them. The books are great, but non-essential. If you insist on reading books, there is an ancient invention called a library that you can use for free.

What C standard does that website describe?

At a glance, the code is compatible with all C standards ever published. You are too fixated on learning the latest. The latest is largely just a superset of the earlier standards and the new features are often obscure things you are unlikely to need or want to use.

The main exceptions that you actually would want to use would be the ability to declare variables anywhere in a block and use single line // comments from C++ in C99. Most C programmers do not even know about most of the things added in newer C standards beyond those and perhaps a handful of others.

Re: Rust to C compiler – 95.9% test pass rate, odd platforms

#237
post #214

Earlier quoted context omitted.

I was not asking for that. I was answering your question. You asked for evidence of rust releases being abandonware. I gave it to you. Someone else trying to ameliorate Rust releases does not change this reality.

Well “abandonware” is a strange way to call that because nothing is actually abandoned.

Use language features not considered “stable rust” that are later discarded and you will learn it is abandonware very quickly. In any case, you asked for proof and now have it. You should be saying thank you instead of trying to argue.

Re: Rust to C compiler – 95.9% test pass rate, odd platforms

#238
post #210

Earlier quoted context omitted.

C and C++ are two different languages. They are versioned by years. Rust technically does not have versions. The rust tools have versions. Basically all versions of C are binary compatible with each other. I suggest you actually learn and use C rather than asking questions since you are never going to ask the right things to understand how it works without having firsthand experience.

> C and C++ are two different languages. They are versioned by years. That sounds like Rust editions.

Only superficially. You cannot specify a past version of Rust where features existed that have since been removed by doing that. You also do not have a situation where two different incompatible languages are being accepted by the same compiler and as long as you specify which one is used, the compiler will properly compile code for it. For example, C will not accept headers with C++ exclusive features like namespaces and C++ will not accept headers with C exclusive features like variably modified types.

The only reason you see people grouping the two languages together is due to history. They are both derivatives of an ancient prestandard form of C called K&R C. They both have different standards committees who had different ideas about how to move forward from K&R C. The result is that C compilers were extended to support both, and that extension continues to this day despite the divergence between the two languages. The C standards committee accepted some of the changes the C++ committee made to K&R C, although the C++ standards committee does not reciprocate by accepting changes made by the C standards committee. This is making them increasingly different languages.

Try to spend time learning how other things work instead of posting replies that attempt to reinterpret everything people tell you through a Rust lens whenever someone is kind enough to answer your questions like you are doing here. It is like asking people how Chinese works and then telling them “English does it this way”. The “nothing matters but ” mentality that causes that is going to annoy a large number of people from whom you would otherwise be able to learn.

Re: Rust to C compiler – 95.9% test pass rate, odd platforms

#239
post #209
post #198

Earlier quoted context omitted.

Do a web search for rdrand and systemd.

> Do a web search for rdrand and systemd. RDRAND always returning all-FF is exactly the kind of thing that's an obvious bug, not a plausible-but-wrong result.

The other guy said "Maybe your program worked due to the bug they fixed.". The RDRAND fix achieved exactly that.

Re: Rust to C compiler – 95.9% test pass rate, odd platforms

#240

Earlier quoted context omitted.

> edit2: networking, signal processing, automotive, learning about industry protocols and devices of any sort... I admit there is many great products that are written in C that aren’t going anywhere any time soon, notably SQLite, but there is no reason to write new software in C or C++.

There's tools that can prove the absence of runtime errors in industrially-useful subsets of C. Frama-C, RV-Match, and Meta's Infer come to mind. That code is then usable in about anything because so much of it is written in or can call C. Until Rust has that combo, there's still a reason to use C. Personally, I'd use both Rust and C with equivalent code. The Rust types and borrow checker give some extra assurance th…

Astree claims to be able to prove the absence of runtime errors in both C and C++, without requiring the use of subsets:

https://www.absint.com/astree/index.htm

By the way, C has a formally verified C compiler:

https://compcert.org/compcert-C.html

Post reply on HN