Live data from Hacker News

Discipline Doesn’t Scale

sicpers.info

151–160 of 173 posts

Re: Discipline Doesn’t Scale

#151
post #10

Earlier quoted context omitted.

I think this is a little oversimplified, because I’m pretty sure C++0x had move semantics and usable smart pointers prior to Rust really entering the public conscience/probably before it existed . AFAICT Rust takes a lot of inspiration from how you would “fix” C++, in ways that you could never actually do in C++ because it would break backwards compatibility.

Everybody and their uncle have an idea about how they would "fix C++" - but these ideas mostly contradict each other and would make for rather different languages :-)

Uh, you're too optimistic:

Everybody and their uncle had a lot of ideas about how they would fix "C++". Eventually all those contradicting ideas got merged into the C++ standard.

:)

Re: Discipline Doesn’t Scale

#152
post #147

Earlier quoted context omitted.

> Smart pointers + static analysis + sanitizers I feel like you just defeated your point; those are bolted on instead of a natural part of the language.

What was my point, then?

Good question. I'd pick one of:

(a) Smart pointers + static analysis + sanitizers make C++ pretty usable

(b) C++ usability requires brittle, half-baked add-ons such as smart pointers and non-deterministic/heuristic/unreliable/NP-hard development tools such as static analysis + sanitizers.

Re: Discipline Doesn’t Scale

#153
I'm reminded of the blameless postmortem training we got john allspaw from etsy. "Try harder", "do better", "be more safe" are all discipline based solutions, and they don't scale. You have to outline specific steps, checklists, procedures, etc that will allow you avoid mental discipline and use processes. The same thing applies to dev work. IDEs, pipelines, scripts, etc, but also language design. Let type systems do the heavy lifting. You should shift as much from your head to a machine/process as possible. Less artisan, but more efficient.

Re: Discipline Doesn’t Scale

#154
post #128
post #7

Over a decade ago I used to argue this with the C++ committee people. Back then, they were not concerned about memory safety; they were off trying to do too much with templates. The C++ people didn't get serious about safety until Rust came along and started looking like a threat. Now they're trying to kludge Rust features into C++ by papering over the unsafe stuff with templates, with some success. But the rot under…

"The encouraging thing today is that we're kind of converging on good practices in language design." - doubtful that we'll arrive at good practices in language design through incremental steps from a flawed base. All the mentioned languages are low-level.

Therefore... what? Just give up? Or start over from a non-flawed base? Which is what? Still to be created, or does it exist?

And in your view, are the bases flawed because they are low level?

Re: Discipline Doesn’t Scale

#155
Starting the article with the history of “but you know what’s better?” just reinforces that there’s always a level where discipline is important. We will never reach the end of the “you know what’s better” cycle. So discipline itself, though not a particular discipline, is something a good programmer always needs. (Which is true of every other craft/skill as well.)

For the record, I do tell people they should learn C so they have a better idea of how computers work. That emphatically does not mean I want them to start writing actual production code in C, unless there’s an extremely good reason (and that hasn’t happened for me in a decade or two). Advising people to gain a deeper understanding of their tools is not “hazing”.

Re: Discipline Doesn’t Scale

#156
post #116
post #70

Earlier quoted context omitted.

I thought Java's locking worked fine as long as you didn't make your locks public or lock on `this`. What is Rust doing that's an improvement?

What is wrong with locking on "this" ? Making the locks public, I sort of get (like making any field public) -- you have multiple locks, you need to ensure they are accessed in a certain order and if you make them public, you cannot enforce that order.

>What is wrong with locking on "this" ?

Instance.this is implicitly public because something else could have a reference to instance.

    synchronize(this){}
that will lock with the following if its inside instance.

    synchronize(instance){}

Re: Discipline Doesn’t Scale

#157
post #147

Earlier quoted context omitted.

What was my point, then?

Good question. I'd pick one of: (a) Smart pointers + static analysis + sanitizers make C++ pretty usable (b) C++ usability requires brittle, half-baked add-ons such as smart pointers and non-deterministic/heuristic/unreliable/NP-hard development tools such as static analysis + sanitizers.

OK. I think some people mistook me as making a value judgement about C++. This is not true, I am merely saying I have doubts that Rust has had a serious impact on C++ design (yet; if it does it will start showing up soon, though.) If you don't believe me please carefully reread my comments; I really wasn't trying to say anything overall good or bad about C++, just observation about trajectory.

My personal opinions on C++ are not very positive, but it's a language I literally grew with. My experience is that C++ code very gradually became more stable and less buggy. The thing is, some of that is just improved discipline, some of it is static analysis, etc. But a lot of it, is genuinely C++0x/C++11 and features that built on top of this.

So the idea that Rust showed up and suddenly C++ cared about safety? I don't really see it. I think C++ developers started caring about safety and then Rust showed up because of that.

P.S.: While the borrow checker and ownership semantics is really cool, I think a programming language's ecosystem and the 'best practices' it lends itself well to have a greater impact that people completely miss. Rust, Go, Zig are all clearly trying to foster a culture of writing more correct and complete programs. Error handling doesn't just feel like a couple control flow mechanisms you can use, but a responsibility that you have. Modern C++ is getting better probably more because of this than any committee; although I really wish the Expected type would've gone somewhere, since I feel Rust's `Result` type and Go's multiple-return with `error` are being proven right as ways to handle errors robustly even with their caveats. (I've heard Zig's error handling is really cool too, but I haven't had a chance to write a serious Zig program. I'll get to it soon.)

Re: Discipline Doesn’t Scale

#159

Earlier quoted context omitted.

This week I had to deal with the exact thing you mention. A pull request for "performance optimization", basically a proposal to unwrap a higher abstraction to do it at a lower level, manually and directly. Yes, it does save a few function calls and instantiating a class - but that's not where the real bottleneck is. The proposed changes would require rewriting large amounts of code elsewhere, making the logic more v…

That burden of proof sounds backward; the person making the optimization should be benchmarking. Rather than rejecting outright, did you consider blocking the pull request and asking for benchmarks demonstrating that the optimization was worth the complexity increase? Maybe they would learn more from that process than from an explanation of why they are misguided.

Good point - I could have asked for a benchmark to prove that the optimizations are worth it.

The person put effort into the code, and I didn't feel that they were convinced of my argument against it. Their changes were more efficient logically, and I'm sure it would have saved a few milliseconds per call - whereas my claim of increased complexity was a more subjective judgement.

In the end, it came down to trust/authority - but they might have been more convinced, or felt better about the decision, if I could produce some numbers from my side, like a measurement of cyclomatic complexity based on static code analaysis.

Perhaps that could have justified the existing higher abstractions, to weigh their (almost negligible) performance cost against the value of reduced complexity - keeping the code base simpler to understand.

Re: Discipline Doesn’t Scale

#160
post #143
post #81

Earlier quoted context omitted.

That’s... something. For the most part users or companies buy features, not performance. You can have the fastest software ever but if it doesn’t have the features I actually need to use it then, sorry, no dice. If performance is one of your features then fair enough, but it’s not for a lot of software.

> not performance This is NOT true. There is almost always an expectation that your application have a reasonable performance profile. It's often not a captured requirement, but I guarantee you once things slow to a crawl you WILL get an escalation. Do you know what happens when escalations become too frequent? Progress grinds to a halt as developers have to churn out of what they're doing to address non-functional i…

The problem with your statement is that it was unbounded. What you are saying is “when your performance is bad, features should take a back seat”. That i agree with.

But “reasonable performance” is relative and context dependent

Post reply on HN