Live data from Hacker News

Matt Godbolt sold me on Rust by showing me C++

collabora.com

301–310 of 675 posts

Re: Matt Godbolt sold me on Rust by showing me C++

#301

Earlier quoted context omitted.

Just like language shapes the way we think and talk about things, programming languages shape both what libraries are written and how. You could write anything in anything so long as it's Turing complete, but in real life we see clearly that certain design decisions at the language level either advantage or disadvantage certain types of solutions. Everyone could in theory write C without any memory issues, but we all…

The Sapir Whorf hypothesis has long been debunked: https://en.m.wikipedia.org/wiki/Linguistic_relativity

[dead]

Re: Matt Godbolt sold me on Rust by showing me C++

#302
post #76
post #54

Earlier quoted context omitted.

> -Wconversion ... assumes converting 1000.0 to 1000 is ok due to no loss in precision. Additionally, `clang-tidy` catches this via `bugprone-narrowing-conversions` and your linter will alert if properly configured.

My opinion is that if you need to run extra tools/linters in order to catch basic errors, the language & its compiler are not doing enough to protect me from correctness bugs. I do run clippy on my Rust projects, but that's a matter of style and readability, not correctness (for the most part!).

The reason certain warnings are on or off by default in compilers in certain warnings modes depends on whether enough people find them useful enough or not. Rust caters to people who want strictness which makes it annoying to use for others, but if you want this you can also - to a large degree - have this in C and C++.

Re: Matt Godbolt sold me on Rust by showing me C++

#303

Earlier quoted context omitted.

> Every single package manager couldn’t handle my very basic and very popular dependencies Well there's your problem - no serious project uses one. > I’m convinced it’s a bunch of masochists People use cpp because it's a mature language with mature tooling and an enormous number of mature libraries. Same exact reason anyone uses any language for serious work.

How can you simultaneously call cpp a mature language with mature tooling and acknowledge that there's no working package manager used by any "serious" project?

apt install xxxxx-dev

Re: Matt Godbolt sold me on Rust by showing me C++

#304

Earlier quoted context omitted.

And it will look like this: https://rust-unofficial.github.io/too-many-lists/sixth-final... (filled with boilerplate, strange Rust idioms, borrow_unchecked, phantomdata, and you still have to manage lifetimes annotations).

And? I don't really see the issue. It works, it is sound, and it has a nice clean interface for safe code to use. That's all I really ask for. Lots of useful things in programming are quite gnarly under the hood, but that doesn't mean those things aren't worth using.

It is fine, there is just not much Rust safety advantage left then. Also in C/C++ the errors do not usually occur when using a nicely defined API, but when doing the low-level gnarly stuff and getting it wrong. As said before, I think there is some advantage of Rust having a safe and unsafe subset, but is is nowhere as big as people claim it is.

Re: Matt Godbolt sold me on Rust by showing me C++

#305

I already hated C++ (having written 100s of thousands of lines of it in games and at FAANG) I'd be curious to know what if any true fixes are coming down the line. This talk: "To Int or to Uint, This is the Question - Alex Dathskovsky - CppCon 2024" https://www.youtube.com/watch?v=pnaZ0x9Mmm0 Seems to make it clear C++ is just broken. That said, and I wish he'd covered this, he didn't mention if the flags he brings u…

> speaking of which, according to another C++ talk, something like 60% of rust crates are dependent on unsafe rust. It's probably not the source of the stats you had in mind since it's discussing something slightly different, but the Rust Foundation built a tool called Painter [0] for this kind of analysis. According to that [1]: > As of May 2024, there are about 145,000 crates; of which, approximately 127,000 contai…

> there's also a whole other argument that the hardware is unsafe so all Rust code will depend on unsafe somewhere or another to run on actual hardware, but that's probably getting a bit into the weeds.

That's not going into the weeds, by that logic (Nirvana fallacy) no language is safe, you're going to die, so why bother about anything? Just lie down and wait for bugs to eat you.

Re: Matt Godbolt sold me on Rust by showing me C++

#306

What if we have a C that removes the quirks without adding too much brain drain? So no implicit type conversions, safer strings, etc.

I have a plan for a safe subset of C which would just require a compiler to warn about certain constructs. I also have a proposal for a safe string type. I am not so sure about type conversions though, you get useful warnings already with existing compiler flags and you can solve the problem in the article already just by wrapping the types in structs.

Re: Matt Godbolt sold me on Rust by showing me C++

#307

All this has been known in the PL design community for decades if not half a century by now. Two things are incredibly frustrating when it comes to safety in software engineering: 1. The arrogance that "practitioners" have against "theorists" (everyone with a PhD in programming languages) 2. The slowness of the adoption of well-tested and thoroughly researched language concepts (think of Haskell type classes, aka, Ru…

> I like that Rust can pick good concepts and design coherent language from them without inventing its own "pragmatic" solution that breaks horribly in some use cases that some "practitioners" deem "too theoretical."

I've thought Rust picked some pretty nifty middle ground. On one side, it's not mindfucking unsafe like C. It picked to remove a set of problems like memory safety. On the other side, Rust didn't go for the highest of theoretical grounds. It's not guaranteeing much outside of it, and it also relies a bit on human help (unsafe blocks).

Re: Matt Godbolt sold me on Rust by showing me C++

#308
post #261

Earlier quoted context omitted.

The Rust community is helpful... but also quite political and extremely hostile to anyone who doesn't share those politics. Even something as anodyne as saying "let's keep politics out of technical discussion" is frequently met with hostility (because many community members believe that tech is inherently political and that trying to keep politics out is really just a bad faith attempt to frame things in terms of the…

JeanHeyd's side of the RustConf thing: https://thephd.dev/i-am-no-longer-speaking-at-rustconf-2023

To be clear, everyone in Rust community (on Reddit, Twitter, etc) was shocked by this, and people started asking for explanations. This led to several people stepping down, and seems to have been miscommunication between Rust Foundation and Rust Project.

Re: Matt Godbolt sold me on Rust by showing me C++

#309

Earlier quoted context omitted.

I'm inferring that you think Rust adds too much brain drain? If so, what?

The borrow checker rejects loads of sound programs - just read https://rust-unofficial.github.io/too-many-lists/ Aliasing rules can also be problematic in some circumstances (but also beneficial for compiler optimisations). And the orphan rule is also quite restrictive for adapting imported types, if you're coming from an interpreted language. https://loglog.games/blog/leaving-rust-gamedev/ sums up the main issues ni…

> The borrow checker rejects loads of sound programs - just read https://rust-unofficial.github.io/too-many-lists/

It's important to be careful here: a lot (most? all?) of these rejections are programs that could be sound in a hypothetical Rust variant that didn't assert the unique/"noalias" nature of &mut reference, but are in fact unsound in actual Rust.

Re: Matt Godbolt sold me on Rust by showing me C++

#310

Earlier quoted context omitted.

>what are they supposed to do when there is no memory left Well on Linux they are apparently supposed to return memory anyway and at some point in the future possibly SEGV your process when you happen to dereference some unrelated pointer.

You can tell Linux that you don't want overcommit. You will probably discover that you're now even more miserable and change it back, but it's an option.

Whenever I switch off overcommitting, every program on my system (that I'm using) dies, one by one, over the course of 2–5 seconds, followed by Xorg. It's quite pretty.
Post reply on HN