Earlier quoted context omitted.
> unlike everybody else, they actually have the combination of wisdom, skills, and discipline to not fall into this trap I'm constantly reminded of the NPC in Half Life 1 who says something like "Take me with you, I'm the one man who knows everything!" I know many programmers who think their one way of writing C++ will not cause any issues. None of them are 100% correct as I can always find a bug that a higher level…
And, you only know programmers who know no more than you.
Writing New System Software
141–150 of 158 posts
Re: Writing New System Software
#142Earlier quoted context omitted.
Never contain programs so few bugs, as when no debugging tools are available - Niklaus Wirth Fuzzers and testing can detect bugs but I don't see how they can make a contribution to a reasonable software structure (I believe that bad structure is the prime cause of bugs).
The other tools being talked about are static analysis tools or runtime instrumentation both designed specifically to try to find bad memory use patterns. I don’t mean this in a rude way, but I don’t care what you believe, because the thing I care about is evidence. If you have some actual evidence for your claim, I would be interested. (I also believe there can be improvements from better code structure in a rewrite…
I would be interested what is the evidence that you're talking about. If my experience doesn't speak to your experience, so be it.
Re: Writing New System Software
#143Earlier quoted context omitted.
I do not have single explicit memory management call in my product of very decent size written in modern C++. So no , I have no idea where did you fish your "evidence" from.
I don’t understand what you’re trying to say? Do you mean that you don’t call malloc? Because that is totally not the point. For example, you could create a new object, pass a reference to it to some function that stores it in a hash table, reach the end of your function where the object is automatically deleted, and then have something try to read the object out of the hashtable. Nowhere do you need to call malloc o…
Re: Writing New System Software
#144Earlier quoted context omitted.
Yes. Legacy in every sense, including "abandonware".
Educate yourself on Android source code. You can even start by the new entries related to Rust. https://source.android.com/setup/build/rust/building-rust-mo...
I have no need to read hype about Rust, regardless of where it might run. And, I have no desire to build Android apps, in any language.
Re: Writing New System Software
#145Re: Writing New System Software
#146Earlier quoted context omitted.
> Basically, non-local control flow is dangerous (...) This is the crux of the error you're making. Exceptions are not about control flow. Exceptions are a transparent and clean way to handle exceptional events. Exceptions are not intended to, say, handle the status code of a HTTP requests. Exceptions are intended to handle exceptional and potentially unrecoverable errors in a safe and controlled manner, such as fail…
> Exceptions are a transparent and clean way to handle exceptional events. I'd sum up this argument as: Exceptions are syntax sugar that allow callers of a function to ignore the error cases of something they are calling and depend on something that calls into them to handle the error case. An example: void HandleRequest(const Request &request, KV &kv) { ... kv.set("a", 10); ... } In this example KV.set will raise an…
Exceptions are a way to ensure that failures are directed immediately to a place designated to deal with such a failure.
They are, in particular, not any sort of "syntax sugar", unlike "?" in certain other languages, or your StatusOr thing. A function that throws an exception does not, in any sense, return to its caller. It does not construct any sort of return value. It does not consult the stack to see where it came from and resume running there.
And, exceptions are totally auditable. There is never any hint of ambiguity or uncertainty about where an exception will take you.
You can be confident that if a function was thrown from, it was because it could not perform the requested action. And, you can be confident that if an exception was not thrown the function called satisfied whatever postconditions it promised.
So, you don't need to know if a function might throw. You may instead assume any function might throw. If it doesn't, then it has satisfied its documented postconditions. Your obligation is only to ensure that destructors clean up any intermediate state on the way out. These identical destructors get exercised every time through the code, so are exercised frequently.
Error-handling code at places where the error cannot actually be dealt with properly, that just tries to propagate the failure up the call chain, is typically not well tested, and often cannot even be triggered in testing.
Re: Writing New System Software
#147Earlier quoted context omitted.
> 2. I basically don’t believe that memory management is not hard. If you try to write Java in C++ then probably the result is verbose. With some practice though, memory management needn't be hard - if memory management is hard that hints lack of organization. Smaller, script-like programs where there is no place for large-scale organization, are a different story (especially in C and C-like C++) and GC'ed languaged…
Also known as MFC, PowerPlant, Turbo Vision, CSet++, Taligent, OWL, ATL, Symbian, Motif++,... all on average 5 years old when Java came into the world.
Re: Writing New System Software
#148Earlier quoted context omitted.
Measuring overhead of debug builds is a rookie mistake.
I'm not talking about code performance, I'm talking about human time of having to step through extra things while using a debugger to work out what's going on.
Re: Writing New System Software
#149Earlier quoted context omitted.
Chrome is not coded in anything even slightly resembling modern C++. So, no conclusions about modern C++ can be drawn from it. Except, maybe, that it takes a long time to modernize old code.
I’m merely trying to respond to a comment that claims that chrome should have few memory management bugs. I don’t really have an opinion about whether it is modern. I don’t care enough about the distinction between C++ styles to know where to find evidence of the rate of memory management problems in modern C++ codebases. Perhaps I would just find that the definition of modern C++ is ‘the style of C++ where you don’t…
You may read in numerous places what modern C(+ code looks like. There is no need to guess.
Re: Writing New System Software
#150Earlier quoted context omitted.
And, you only know programmers who know no more than you.
This isn't a "know more" or "know less" than me thing. This is being-a-human thing. I've never written a large amount of C++ without a similar mistake creeping in. Humans make mistakes.