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.
Ask HN: Learn C++11 or Rust in 2022?
151–160 of 161 posts
Re: Ask HN: Learn C++11 or Rust in 2022?
#152Earlier 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.
Re: Ask HN: Learn C++11 or Rust in 2022?
#153Earlier 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.
Re: Ask HN: Learn C++11 or Rust in 2022?
#154Earlier 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, ...
Again, what did being pedantic prove here? You clearly understood what I meant.
Re: Ask HN: Learn C++11 or Rust in 2022?
#155Earlier 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.
Re: Ask HN: Learn C++11 or Rust in 2022?
#156I'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.
This is also the main selling point of Rust, IMO.
Re: Ask HN: Learn C++11 or Rust in 2022?
#157Earlier 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…
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?
#158Earlier 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…
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?
#159Earlier 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?
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?
#160Earlier 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!