←back to thread

218 points signa11 | 4 comments | | HN request time: 0.82s | source
Show context
lou1306 ◴[] No.43681059[source]
> Using a stricter language helps with reducing some classes of bugs, at the cost of reduced flexibility in expressing a solution and increased effort creating the software.

First of all, those languages do not "help" "reducing" some classes of bugs. They often entirely remove them.

Then, even assuming that any safe language with unsafe regions (Rust, C#, etc) would not give you comparable flexibility at a fraction of the risk... if your flexible, effortless solution contains entire classes of bugs, then there is no point in comparing "effort". You should at least take into account the effort in providing a software with a high confidence that those bugs are not there.

replies(3): >>43681118 #>>43681160 #>>43684056 #
immibis ◴[] No.43681118[source]
If the language has unsafe regions, it doesn't entirely remove classes of bugs, since they can still occur in unsafe regions.

(Predictable response: "But they can only occur in unsafe regions which you can grep for" and my response to that: "so?")

replies(4): >>43681325 #>>43681630 #>>43682375 #>>43682796 #
1. sjamaan ◴[] No.43681630[source]
I suppose the better response is that it removes those classes of bugs where they are absolutely unnecessary. Tricky code will always be tricky, but in the straightforward 80% (or more) of your code such bugs can be completely eliminated.

It's unfortunate that C has so many truly unnecessary bugs which are only caused by stupid overly "clever" exploitation of undefined behaviour by compilers.

replies(1): >>43684127 #
2. codr7 ◴[] No.43684127[source]
Unfortunate, yes.

But what bugs? Suboptimal choices maybe; but any backwards compatible, popular language is going to have its share of those.

replies(1): >>43685099 #
3. immibis ◴[] No.43685099[source]
The ones GP is referring to all go away when you use -O0. They're completely artificially constructed by compiler writers language-lawyering the language. They were unforeseeable to the people who actually wrote the language, who expected interpretations like "dereferencing null crashes the program" or "dereferencing null accesses the interrupt vector table" and absolutely were not expecting "dereferencing null deletes the previous three lines of code"
replies(1): >>43685523 #
4. codr7 ◴[] No.43685523{3}[source]
Which I would definitely recommend as a strong default.