←back to thread

838 points turrini | 4 comments | | HN request time: 0.837s | source
Show context
titzer ◴[] No.43971962[source]
I like to point out that since ~1980, computing power has increased about 1000X.

If dynamic array bounds checking cost 5% (narrator: it is far less than that), and we turned it on everywhere, we could have computers that are just a mere 950X faster.

If you went back in time to 1980 and offered the following choice:

I'll give you a computer that runs 950X faster and doesn't have a huge class of memory safety vulnerabilities, and you can debug your programs orders of magnitude more easily, or you can have a computer that runs 1000X faster and software will be just as buggy, or worse, and debugging will be even more of a nightmare.

People would have their minds blown at 950X. You wouldn't even have to offer 1000X. But guess what we chose...

Personally I think the 1000Xers kinda ruined things for the rest of us.

replies(20): >>43971976 #>>43971990 #>>43972050 #>>43972107 #>>43972135 #>>43972158 #>>43972246 #>>43972469 #>>43972619 #>>43972675 #>>43972888 #>>43972915 #>>43973104 #>>43973584 #>>43973716 #>>43974422 #>>43976383 #>>43977351 #>>43978286 #>>43978303 #
monkeyelite ◴[] No.43972915[source]
> If dynamic array bounds checking cost 5% (narrator: it is far less than that)

It doesn’t work like that. If an image processing algorithm takes 2 instructions per pixel, adding a check to every access could 3-4x the cost.

This is why if you dictate bounds checking then the language becomes uncompetitive for certain tasks.

The vast majority of cases it doesn’t matter at all - much less than 5%. I think safe/unsafe or general/performance scopes are a good way to handle this.

replies(3): >>43973436 #>>43975046 #>>43976715 #
1. timbit42 ◴[] No.43975046[source]
Your argument is exactly why we ended up with the abominations of C and C++ instead of the safety of Pascal, Modula-2, Ada, Oberon, etc. Programmers at the time didn't realize how little impact safety features like bounds checking have. The bounds only need to be checked once for a for loop, not on each iteration.
replies(1): >>43976530 #
2. monkeyelite ◴[] No.43976530[source]
> The bounds only need to be checked once for a for loop, not on each iteration.

This is a theoretical argument. It depends on the compiler being able to see that’s what you’re doing and prove that there is no other mutation.

> abominations of C and C++

Sounds like you don’t understand the design choices that made this languages successful.

replies(1): >>43978367 #
3. timbit42 ◴[] No.43978367[source]
I understand the design choices and they're crap. Choosing a programming language shouldn't be a popularity contest.
replies(1): >>43979314 #
4. timewizard ◴[] No.43979314{3}[source]
There are inevitably those who don't know how to program but are responsible for hiring those that can. Language popularity is an obvious metric with good utility for that case.

Even so you haven't provided any compelling evidence that C or C++ made it's decisions to be more appealing or more popular.