5 ms·
This is the beauty of modern C++. The code has become so hard to read (without years of prior knowledge) that as a human, it's rather hard to find any possible
by jussij 4y ago
This is the beauty of modern C++. The code has become so hard to read (without years of prior knowledge) that as a human, it's rather hard to find any possible errors. The code can take on a Schrodinger state where it appears both right and wrong.
- simplotek 4y agoThe code is not hard to read. People write code that is hard to read. English is a great language, but some people write stuff down in good plain English that is hard to parse. The same goes for any programming language. If you want to write code that's hard to read, that's what you will get.
- bArray 4y agoI don't not think that English isn't difficult to parse. I agree completely that it's all about the code you write. You can write nice C++ that is easy to understand, easy to debug, and that you can be quite certain is bug free. Something like Rust appears to eliminate one class of bugs, but then people still write bugs. Just look at the Rust language issue tracker on GitHub [1]. Fundamentally, you cannot get around the need for good code design. Any useful programming language will always have the ability to mishandle data. [1] https://github.com/rust-lang/rust/issues https://github.com/rust-lang/rust/issues
- galangalalgol 4y agoRust doesn't create any new classes of bugs, and it eliminates some old ones. Isn't that all positive? Rust also turns a lot more bugs from UB and/or exploitable, into a panic. That is still potentially a ddos, but it is better than code injection. And therebare tools like prusti to find panics, and you can use tricks with linking a nostd library to see if you got them all. Probably better ways than that now. We can obviously write bugs in any language, but it is just as obvious that some languages make finding some bugs easier. Rust makes some bugs easy to find, the compuler points them out, and unless it makes other bugs harder to find it is all upside (from the correctness standpoint, not all standpoints)
- kllrnohj 4y ago> Rust also turns a lot more bugs from UB and/or exploitable, into a panic. Sadly for some of them (like integer overflow), that's only true in debug builds. Having a debug build that just force-enables santizers is a great thing, but also one easily replicated in a C/C++ ecosystem, too.
- hra5th 4y agoRust integer overflow bugs in release mode are still much safer than C++ integer overflows -- Rust integer overflow is well-defined to wrap in release mode, whereas it is UB in C++.
- kllrnohj 4y agoThat's not meaningfully safer which is why it's still a panic in debug builds. It's really just kinda worse even. You can't use it as a programmer (because it panics) and the compiler can't use it even though you've already promised (and debug mode verified) that it never happens.
- galangalalgol 4y agoIf you want an add to wrap, you should use a wrapped_add, useful for angle math or whatever. If you want it to saturate, use a saturating_add, and if you want to check for overflow, use a checked_add. If I were to write a rust coding standard it would prohibit + in favor of explicitly using those functions.
- kilgnad 4y agoCategorically not true. Assembly language, for example is harder to read then say python when written by the same person. Therefore programming languages can be intrinsically hard to read. I think you're just an exception. You're likely a programming genius with 250 IQ so everything is easy to read. From your perspective, the problem has nothing to do with languages... it's all the people with iqs below you that's the problem.
- jeroenhd 4y agoI don't think it's C++'s fault necessarily. The C/C++ ecosystem seems to attract more of a certain type of developer who will tell you to just "get good" at the language so you van decipher their code and use it without a billion memory bugs, but the language doesn't specify any of it. It's easy to point out an example of unreadable code in any language because every language has their weird programmers. If you stick to modern tools with strict linting and good design, you can write perfectly readable C++ code. I don't use C++ often, but I find the code over at https://github.com/SerenityOS/serenity https://github.com/SerenityOS/serenity to be more legible than many large code bases in other languages.
- pjmlp 4y agoModern tooling that usually only 11% of the community that bothers to answer surveys uses.