Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
kllrnohj
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
54 ms
·
961.
▲
by
kllrnohj
4y ago
I use vector all the time, but that doesn't mean it's without any legacy baggage. It didn't get a clean sheet reboot in "Modern C++" The argument was "this bug exists in pop_back, therefore Modern C++ is a fail
962.
▲
by
kllrnohj
4y ago
That'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&#x
963.
▲
by
kllrnohj
4y ago
I didn't say it wasn't recommended or should be avoided, but it definitely has "legacy" to it. It's not an exclusively "Modern C++" container.
964.
▲
by
kllrnohj
4y ago
> I use Windows 10. Been using Firefox as the default browser since the day I installed it 7 years ago. It has never nagged me about Edge. Windows 10 definitely nags you about Edge from time to time. Some windows updates will re-trigge
965.
▲
by
kllrnohj
4y ago
The sanitizers are not incompatible with optimizations. asan with -O2 is a perfectly valid & useful combination. It's much faster than valgrind or anything like that, very usable levels of performance. And on an increasingly comm
966.
▲
by
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 thi
967.
▲
by
kllrnohj
4y ago
> But std::vector isn't legacy Oh yes it is. std::vector is hella legacy. That's not a C++11 addition (where "Modern C++" began). And it has all sorts of very-legacy warts like https://en.cppreference.com&#
968.
▲
by
kllrnohj
4y ago
pop_back is about to invoke a destructor. Remember unlike what the name would suggest, it's not actually returning the element it removed - it's equivalent to erase(end() - 1). So adding a bounds check is going to be inconsequenti
969.
▲
by
kllrnohj
4y ago
> STL, which these containers are part of, is famously speed-optimized. STL (like C++) was designed for speed first (if at all possible then zero-cost abstractions) and thus does very little error checking on its own. Only kinda? A bunch
970.
▲
by
kllrnohj
4y ago
You meant this as a sarcastic response, but literally all VR headsets are just 2 displays, 1 per eye. The same thing is true about audio & ears. If you've got a speaker that you know is dedicated strictly to a single ear, then all
971.
▲
by
kllrnohj
4y ago
I can do that in C/C++ where regular signed integer overflow is otherwise undefined behavior. The point is just Rust defining the behavior (no UB!) didn't do a damn thing to help anyone since if you actually want and expect overfl
972.
▲
by
kllrnohj
4y ago
Most of the UB hate is that bugs that always existed only recently became exposed. "This code worked fine for years why is the compiler breaking it!" is always the rant, but it's misplaced. It should instead be "why didn
973.
▲
by
kllrnohj
4y ago
By far my favorite thing about his builds is they are also very actually DIY. Like, basic hand tools are all that's required most of the time and actually affordable parts. So many youtuber "DIY's" are like "today I
974.
▲
by
kllrnohj
4y ago
It was more than that. Microsoft was giving IE special APIs that it wasn't letting others have, and was also deeply integrating IE into the broader OS (eg, embedding it into the file explorer) Which is also what Apple is doing but then
975.
▲
by
kllrnohj
4y ago
Nobody is arguing Safari shouldn't exist. They're arguing that Apple shouldn't get to force monopolize it on iOS even more aggressively than Microsoft was doing with IE 20 years ago.
976.
▲
by
kllrnohj
4y ago
> But we’re a full decade back of beefiness. Really it's where the beefiness always should have been for the performance class / power envelope they are (and have been) targeting. But yeah, a large screen thin & light seems
977.
▲
by
kllrnohj
4y ago
C++ provides tools that C does not (and cannot with just a library) to aid in managing the complexity of the space. Adding complexity to a language can reduce the complexity in using it. This is the case for C++, Rust, D's betterC, e
978.
▲
by
kllrnohj
4y ago
Yeah but I'd file that under C++'s ABI problems category. I don't think anything in std::optional's spec requires that it has additional padding. It could have an optimized representation for known types of T & thu
979.
▲
by
kllrnohj
4y ago
C is a simpler compiler and language spec but I think where we're disagreeing is on whether or not it's simpler to use . I'm saying it's not simpler to use , not that it's not simpler to make a compiler for it
980.
▲
by
kllrnohj
4y ago
https://en.cppreference.com/w/cpp/utility/optional/value_or value_or's parameter type is U&&, so no there's no additional copy there. There's only the explicitly visible default co
981.
▲
by
kllrnohj
4y ago
A "move" of a POD value type is still a copy and std::move/std::forward don't do anything (same in Rust for Copy traits). Rather the Rust feature that's missing here is the compiler automatically converting pass-by-
982.
▲
by
kllrnohj
4y ago
You're right, of course. In C I don't even know if the code works at all, whereas I can be reasonably confident it does in C++. But hey, it's apparently more important to know it's a memcpy than to know it works! Such si
983.
▲
by
kllrnohj
4y ago
C is a minefield of complexity, though, why are you so desperate to pretend it isn't? The reality is that much of the language complexity of things like C++ or Rust is because the problem space is actually complex. C's language ju
984.
▲
by
kllrnohj
4y ago
In C I don't even have a clue if the copy is even valid at all or if I was supposed to call some bespoke function or use some wacky macro somewhere. C++ is a strict improvement in that you can at least generally assume the assignment o
985.
▲
by
kllrnohj
4y ago
`return opt.value()` is not forced to be a copy, no. It is, as you noted, a reference return. You can of course continue to propagate that as a reference if you want, assuming that makes sense. I don't think I'd agree with a chara
986.
▲
by
kllrnohj
4y ago
If you're going to say "you need to be careful about copies when passing-by-value and moves are complicated" then I 100% agree. BUT if you're going to say "you need to be careful about std::optional" then I c
987.
▲
by
kllrnohj
4y ago
That can be about literally any change, how does std::optional meaningfully change things here to warrant calling out that you need care when using it specifically?
988.
▲
by
kllrnohj
4y ago
Other than operator overloads, you have all those same problems with C. Only with the extra "benefit" that the compiler won't help you with jack shit. C is not a simple language. You're either naive or lying to yourself
989.
▲
by
kllrnohj
4y ago
But why focus on optional then instead of just passing anything by-value? And why not actually dive into when/where this could be of a concern and how to recognize it? It seems like an article aimed neither at beginners nor experts.
990.
▲
by
kllrnohj
4y ago
What innocent looking change are you thinking of that becomes an issue as a result of this? If your function is currently taking a parameter by-value, and you replace it with std::optional<T>, you're still taking it by value and
More ›