Live data from Hacker News

I stopped everything and started writing C again

kmx.io

401–410 of 475 posts

Re: I stopped everything and started writing C again

#401
> who can write a strategy game with thousands of units each having their own vision of the world, without having a garbage collector running like hell

Even in ecosystems where you don't have a way to opt-out of GC, there are strategies for dramatically minimizing the impact. Just because you have some aspects of the product rely on it should not be fatal unless we are being a bit hyperbolic about the purity of tech. If your allocation rate is Additionally, I don't think this is a fair take on how an RTS game would be engineered in practice. Each unit should be part of a big contiguous array in memory somewhere. The collection of garbage can be made largely irrelevant in the scenario of managing game state if you are willing to employ approximately the same approach you'd use in many other languages. Nothing stops you from newing up a 2 gig byte array and handing out spans to consumers just because you have GC turned on.

Re: I stopped everything and started writing C again

#402
post #150

Earlier quoted context omitted.

> Similar to C, but with much more help from the compiler with all sorts of things. Is that not the problem rust was created to solve?

Indeed. I'm still not entirely sure why Rust was created when we have Ada, but if I had to guess it's mainly because Rust has slightly more advanced tricks for safe memory management, and to some degree because Rust has curly braces.

Ada doesn't attempt to statically exclude data races or aliasing bugs. Rust does. I guess you're calling that "slightly more advanced tricks for safe memory management", which sounds wildly inaccurate to me; those problems aren't usually considered "memory management" at all. Rust also has better error handling, a stronger static type system, a Turing-complete compile-time macro system, and much less verbose code.

Re: I stopped everything and started writing C again

#403
post #399

Earlier quoted context omitted.

> Do you mean No I don't mean. I said what I said. If you click the C program right next to the Rust program for "spectral-norm" you get the equally unreadable - https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Do you mean the "Rust" programs are assembly but the "C" programs forced them to be that way? https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

No I don't mean.

It is possible to write idiomatic Rust and C. It is possible to write assembly in the form of Rust and C. In both cases, they're comparable in performance.

But leaving toy programs like Benchmarks Game and AoC aside, I gave 6 examples of Rust outperforming C. Do you have any examples of C outperforming Rust?

Re: I stopped everything and started writing C again

#405

Earlier quoted context omitted.

Not really. I have written a lot of C and Rust. The notion that identical projects written in both languages would have identical numbers of (or even severity of) bugs is laughable on its face. I mean, literally just not being able to deref a NULL pointer by itself is enormous.

You can dereference null pointers in Rust, it's also easy to make null pointers. The thing is I'm not surprised you didn't realise this is possible because you would never actually do this in Rust since it's obviously a bad idea. let p: *const i32 = std::ptr::null(); // Pointer to a signed 32-bit integer, but it's null unsafe { some_local = *p }; // Dereferencing the null pointer, bang If we instead use references th…

Of course it’s possible. I am well aware it’s possible. You can also just call into a C library that hands you a null pointer. Further, it’s wholly possible to invalidate every single one of Rust’s safety guarantees if you try hard enough.

In practice I have never encountered a null pointer in Rust. Most Rust programmers have never encountered a null pointer. For most non-FFI practical purposes you can act as if they don’t exist.

Re: I stopped everything and started writing C again

#406

Earlier quoted context omitted.

You come off as incredibly arrogant too, you just don't realise it because you have the current mainstream opinion and the safety of a crowd. Do you know how fucking obnoxious it is when 200 people like you come into every thread to tell 10 C or Javascript developers that they can't be trusted with the languages and environments they've been using for decades? There are MILLIONS of successful projects across those tw…

Nobody is telling JS developers that Rust will save them, chill.

Well, not 100% true... With Rust being the principal language that compiles to webassembly, I'm sure there is quite a lot of JS code being re-written in Rust right now.

Re: I stopped everything and started writing C again

#407
post #399

Earlier quoted context omitted.

Do you mean the "Rust" programs are assembly but the "C" programs forced them to be that way? https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

No I don't mean. It is possible to write idiomatic Rust and C. It is possible to write assembly in the form of Rust and C. In both cases, they're comparable in performance. But leaving toy programs like Benchmarks Game and AoC aside, I gave 6 examples of Rust outperforming C. Do you have any examples of C outperforming Rust?

> Do you have any examples of C outperforming Rust?

I don't have a pony in that race.

> uutils/sort outperforms coreutils/sort by 6x

"He used the hyperfine command-line benchmarking tool to run a test ten times; sorting a text file containing all of Shakespeare's works to see which implementation was faster. The first time he performed the test, he used a debug build of the Rust version of sort. In that demo, Rust's version was 1.45x faster than the GNU version. Then he ran the test again using a non-debug version, which showed the Rust version performing the test six times faster than GNU's implementation."

Might it be that a new implementation in C would also have been faster?

Re: I stopped everything and started writing C again

#408

Earlier quoted context omitted.

I started programming with Python years and years ago. My journey has led me to preferring low-level languages (currently in a Zig bout), and revisiting Python has been a disappointing experience. Not necessarily bad , but instead of focusing efforts where it really matters, such as eliminating GIL, they seem to be focused on adding new syntactic sugar.

They are very much focusing efforts on eliminating GIL.

Now they're finally getting around to it. They hadn't been.

Re: I stopped everything and started writing C again

#409
post #146

Earlier quoted context omitted.

> I think Rust is harder to learn, but once you grok it, I don't think it's harder to use, or at least to use correctly. It's hard to write correct C because the standard tooling doesn't give you much help beyond `-Wall`. When I say Rust is harder to use (even after learning it decently well), what I mean is that it's still easier to write a pile of C code and get it to compile than it is to write a pile of Rust code…

Getting something to compile is never the end-goal. It takes 0 effort to get Python compile.

It can feel like a real milestone though

Re: I stopped everything and started writing C again

#410
post #407

Earlier quoted context omitted.

No I don't mean. It is possible to write idiomatic Rust and C. It is possible to write assembly in the form of Rust and C. In both cases, they're comparable in performance. But leaving toy programs like Benchmarks Game and AoC aside, I gave 6 examples of Rust outperforming C. Do you have any examples of C outperforming Rust?

> Do you have any examples of C outperforming Rust? I don't have a pony in that race. > uutils/sort outperforms coreutils/sort by 6x "He used the hyperfine command-line benchmarking tool to run a test ten times; sorting a text file containing all of Shakespeare's works to see which implementation was faster. The first time he performed the test, he used a debug build of the Rust version of sort. In that demo, Rust's…

Might not.

The Rust standard library has a state of the art sort implementation. There’s nothing faster, in any language - https://github.com/rust-lang/rust/pull/124032.

And sure, it’s possible that someone could write a C program that compares in speed to all the Rust programs I’ve mentioned. C is a Turing complete language after all. I’m only pointing out that it hasn’t happened in practice.

Also check the Android Binder code before (C https://github.com/torvalds/linux/blob/master/drivers/androi...) and after (Rust - https://android.googlesource.com/platform/frameworks/native/...). Same speed but the quality difference, it’s incomparable.

Post reply on HN