Live data from Hacker News

Ask HN: Learn C++11 or Rust in 2022?

news.ycombinator.com

151–160 of 161 posts

Re: Ask HN: Learn C++11 or Rust in 2022?

#151
post #146
post #144

Earlier quoted context omitted.

ah yes, it runs on a lot of mobile phones, and app developers cannot get consistent performance out of all those different phones, thanks to java and the Shit OS that runs on them, which shall remain unnamed. i worked for a startup once that put a java based GUI on top of some C code and used the JNI. the endless issues with java bankrupted the company as the clients who were supposed to adopt the solution refused to…

Not everyone can afford to hire good coders, so they get what they pay for.

java and that OS using java are poor solutions and the idea that you can get consistent performance out of a variety of phones running an OS incorporating java is retarded. at least at Apple they know what they are doing and never made that mistake.

Re: Ask HN: Learn C++11 or Rust in 2022?

#152
post #149
post #102

Earlier quoted context omitted.

I am talking about Rust, not C++

I was agreeing with the comment I replied to, who assessed that Rust was the less "magic"-y language.

it is not less magicy, rust is more magicy. which is why i don’t want it and why i think we don’t need it. a new language cannot abstract you from the machine or OS you write software for.

Re: Ask HN: Learn C++11 or Rust in 2022?

#153
post #138
post #134

Earlier quoted context omitted.

Of course we do. You still need to know how pointers work to use RAII effectively , though.

Not at all, because RAII is about constructors/destructors, and not at all about pointers. Heap allocated data is one special case of OS resources that can be managed by constructor/destructor pairs.

What did being pedantic prove here?

Re: Ask HN: Learn C++11 or Rust in 2022?

#154
post #137
post #135

Earlier quoted context omitted.

Because smart pointers are still pointers under the hood. You're forgetting the time before you know what pointers were - people coming from higher level languages don't immediately grok the concept. By teaching them automatic memory management patterns like we use in C++ without teaching them why you need such things, they'll never fully understand the code they're writing. It's like the "I know React but not JavaSc…

If you think RAII is about smart pointers, you really don't understand it. RAII is about resource management, regardless of where those resources live on. Heap allocated, OS handles, indexes on a fixed sized buffer, network sockets, ...

Yes, I'm aware, thanks. Lifetimes, ownership, etc. are all overlaps of RAII and associated concepts.

Again, what did being pedantic prove here? You clearly understood what I meant.

Re: Ask HN: Learn C++11 or Rust in 2022?

#155
post #142
post #118

Earlier quoted context omitted.

History has demonstrated over and over and over again that c/c++ code above a certain complexity threshold (which is fairly low), _will_ have memory safety issues. It doesn't matter how good you are at engineering.

but all the companies are making people do coding inteviews now. didn't that solve the problem????? apparently not.

If the interview question was find the memory vuln in this giant code base, I would probably fail.

Re: Ask HN: Learn C++11 or Rust in 2022?

#156

I'd say C++ at this point in time. It's getting better by the day, yet it has decades of high quality projects and libs you can rely on. Each new version is better than the last. It may be irritating that few things are ever hard-deprecated, and you have to keep a list of current best practices. On the other hand, concepts, ranges, previously auto and constexpr, are all godsend and make for an expressive language tha…

One of the core benefits of C++ is that it is a high level language that's still super close to the hardware. Switching from C++ to other languages, if you have mastered C++, should largely be a question of "what things are automatically done for me" which is very different from "what are these new things I need to do" that you have to deal with when you switch between other languages.

> One of the core benefits of C++ is that it is a high level language that's still super close to the hardware.

This is also the main selling point of Rust, IMO.

Re: Ask HN: Learn C++11 or Rust in 2022?

#157
post #54

Earlier quoted context omitted.

With C++ realistically memory management is so hard that if you want to go solo, and you don't want to debug segfaults all the time, Rust is definitely the way to go. It teaches you manual memory management like nothing else.

Unless you're manually implementing data structures or something similar you basically never need to manage your memory manually in modern C++. std::vector takes care of most your needs and smart pointers exist for the few cases where it doesn't. There's not really a lot of difference to Rust there except that OOB access is a panic in Rust and (most likely) a segfault in C++ but you can trivially enable that checking…

It's entirely possible to invoke memory unsafety in modern C++.

    std::vector v {1, 2, 3};
    int& x = something(v);
    something_else(std::move(v));
    x = 42;
Is this UB? Impossible to tell without examining the code of the functions involved!

Re: Ask HN: Learn C++11 or Rust in 2022?

#158
post #14

Earlier quoted context omitted.

I'm confused when people preach Zig and then safety in the same sentence. Zig has basically all the same problems that C++ has with a few extra bells and whistles. There are perfectly good reasons to like Zig, but it being "safe" is not one of them. > For example, this comes through in little things like Zig's extreme simplicity and explicitness "Simplicity" does not mean safety. In fact simplicity means you can't de…

> I'm confused Thanks, I've tried to clarify that Zig provides spatial memory safety but not temporal memory safety, so hopefully it's less confusing. > "Simplicity" does not mean safety. Ceteris parabus, complexity breeds bugs and simplicity improves the probability of safety. For example, if I were auditing a piece of code for security, I would prefer the simplest correct program to the most complex correct program…

> Things like checked arithmetic matter and should be enabled by default in safe builds, yet Rust does not actually do this in safe release builds. Zig does and I hope that Rust one day will.

The entire origin of unchecked arithmetic being a problem originates from their use as indexes to buffers. If you solve the indexing buffer issue you don't need to completely expand every single mathematical operation to a checked one which slows down the code. If people want checked artihmetic for some reason in the rare case that it matters in a non-buffer case, then they can used things like checked_add.

Re: Ask HN: Learn C++11 or Rust in 2022?

#159
post #153
post #138

Earlier quoted context omitted.

Not at all, because RAII is about constructors/destructors, and not at all about pointers. Heap allocated data is one special case of OS resources that can be managed by constructor/destructor pairs.

What did being pedantic prove here?

The thread started with you insisting a C-level conception of pointers is essential to coding C++, which turns out to be false.

Learning C first is a very bad way to learn C++. One can pick up pointers later, and asm blocks after that.

Re: Ask HN: Learn C++11 or Rust in 2022?

#160
post #54

Earlier quoted context omitted.

Unless you're manually implementing data structures or something similar you basically never need to manage your memory manually in modern C++. std::vector takes care of most your needs and smart pointers exist for the few cases where it doesn't. There's not really a lot of difference to Rust there except that OOB access is a panic in Rust and (most likely) a segfault in C++ but you can trivially enable that checking…

It's entirely possible to invoke memory unsafety in modern C++. std::vector v {1, 2, 3}; int& x = something(v); something_else(std::move(v)); x = 42; Is this UB? Impossible to tell without examining the code of the functions involved!

Nobody said it's impossible, it's just generally not an issue if you write normal code (read: stop treating C++ as C, they are completely different languages). There's only very little difference in how much you need to think about lifetimes and stuff between Rust and modern C++, it's far from being "hard". Sure Rust holds your hands a bit more in those regards but you can also just turn on address sanitizer and friends and then you have a very similar experience.
Post reply on HN