←back to thread

837 points turrini | 9 comments | | HN request time: 0s | source | bottom
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 #
_aavaa_ ◴[] No.43972050[source]
Except we've squandered that 1000x not on bounds checking but on countless layers of abstractions and inefficiency.
replies(6): >>43972103 #>>43972130 #>>43972215 #>>43974876 #>>43976159 #>>43983438 #
Gigachad ◴[] No.43972215[source]
Am I taking crazy pills or are programs not nearly as slow as HN comments make them out to be? Almost everything loads instantly on my 2021 MacBook and 2020 iPhone. Every program is incredibly responsive. 5 year old mobile CPUs load modern SPA web apps with no problems.

The only thing I can think of that’s slow is Autodesk Fusion starting up. Not really sure how they made that so bad but everything else seems super snappy.

replies(40): >>43972245 #>>43972248 #>>43972259 #>>43972269 #>>43972273 #>>43972292 #>>43972294 #>>43972349 #>>43972354 #>>43972450 #>>43972466 #>>43972520 #>>43972548 #>>43972605 #>>43972640 #>>43972676 #>>43972867 #>>43972937 #>>43973040 #>>43973065 #>>43973220 #>>43973431 #>>43973492 #>>43973705 #>>43973897 #>>43974192 #>>43974413 #>>43975741 #>>43975999 #>>43976270 #>>43976554 #>>43978315 #>>43978579 #>>43981119 #>>43981143 #>>43981157 #>>43981178 #>>43981196 #>>43983337 #>>43984465 #
sorcerer-mar ◴[] No.43972248[source]
I think it's a very theoretical argument: we could of course theoretically make everything even faster. It's nowhere near the most optimal use of the available hardware. All we'd have to give up is squishy hard-to-measure things like "feature sets" and "engineering velocity."
replies(2): >>43973093 #>>43973523 #
CyberDildonics ◴[] No.43973523[source]
we could of course theoretically make everything even faster. It's nowhere near the most optimal use of the available hardware. All we'd have to give up is squishy hard-to-measure things like "feature sets" and "engineering velocity."

Says who? Who are these experienced people that know how to write fast software that think it is such a huge sacrifice?

The reality is that people who say things like this don't actually know much about writing fast software because it really isn't that difficult. You just can't grab electron and the lastest javascript react framework craze.

These kinds of myths get perpetuated by people who repeat it without having experienced the side of just writing native software. I think mostly it is people rationalizing not learning C++ and sticking to javascript or python because that's what they learned first.

replies(2): >>43973895 #>>43975467 #
sorcerer-mar ◴[] No.43973895[source]
> These kinds of myths get perpetuated by people who repeat it without having experienced the side of just writing native software. I think mostly it is people rationalizing not learning assembly and sticking to C++ or PERL because that's what they learned first.

Why stop at C++? Is that what you happen to be comfortable with? Couldn't you create even faster software if you went down another level? Why don't you?

replies(2): >>43974060 #>>44001898 #
CyberDildonics ◴[] No.43974060[source]
Couldn't you create even faster software if you went down another level? Why don't you?

No and if you understood what makes software fast you would know that. Most software is allocating memory inside hot loops and taking that out is extremely easy and can easily be a 7x speedup. Looping through contiguous memory instead of chasing pointers through heap allocated variables is another 25x - 100x speed improvement at least. This is all after switching from a scripting language, which is about a 100x in itself if the language is python.

It isn't about the instructions it is about memory allocation and prefetching.

replies(1): >>43974682 #
sorcerer-mar ◴[] No.43974682[source]
Sorry but it is absolutely the case that there are optimizations available to someone working in assembly that are not available to someone working in C++.

You are probably a lazy or inexperienced engineer if you choose to work in C++.

In fact, there are optimizations available at the silicon level that are not available in assembly.

You are probably a lazy or inexperienced engineer if you choose to work in assembly.

replies(1): >>43978276 #
CyberDildonics ◴[] No.43978276[source]
Go ahead and give me examples of what you mean.

I'm talking about speeding software up by 10x-100x by language choice, then 7x with extremely minimal adjustments (allocate memory outside of hot loops), then 25x - 100x with fairly minimal design changes (use vectors, loop through them straight).

I'm also not saying people are lazy, I'm saying they don't know that with something like modern C++ and a little bit of knowledge of how to write fast software MASSIVE speed gains are easy to get.

You are helping make my point here, most programmers don't realize that huge speed gains are low hanging fruit. They aren't difficult, they don't mean anything is contorted or less clear (just the opposite), they just have to stop rationalizing not understanding it.

I say this with knowledge of both sides of the story instead of guessing based on conventional wisdom.

replies(1): >>43978366 #
sorcerer-mar ◴[] No.43978366[source]
So you agree there’s a trade off between developer productivity and optimization (coding in assembly isn’t worth it, but allocating memory outside of hot loops is)

You agree with my original point then?

replies(1): >>43978451 #
CyberDildonics ◴[] No.43978451[source]
Are you seriously replying and avoiding everything we both said? I'll simplify it for you:

Writing dramatically fast software that is 1,000x or even 10,000 times faster than a scripting language takes basically zero effort once you know how to do it and these assembly optimization are a myth that you would have already shown me if you could.

replies(1): >>43978459 #
1. sorcerer-mar ◴[] No.43978459[source]
“Zero effort once you know how to do it” is another way of saying “time and effort.”

Congratulations you’ve discovered the value of abstractions!

I mean, you’re the one who started this off with the insane claim that there’s no tradeoff, then claimed there are no optimizations available below C++ (i.e. C++ is the absolute most optimized code a person can write). Not my fault you stake out indefensible positions.

replies(1): >>43979077 #
2. CyberDildonics ◴[] No.43979077[source]
Your original comment was saying you have to give up features and development speed to have faster software. I've seen this claim before many times, but it's always from people rationalizing not learning anything beyond the scripting languages they learned when they got in to programming.

I explained to you exactly why this is true, and it's because writing fast software just means doing some things slightly differently with a basic awareness of what makes programs fast, not because it is difficult or time consuming. Most egregiously bad software is probably not even due to optimization basics but from recomputing huge amounts of unnecessary results over and over.

What you said back is claims but zero evidence or explanation of anything. You keep talking about assembly language, but it has nothing to do with getting huge improvements for no time investment, because things like instruction count are not where the vast majority of speed improvements come from.

I mean, you’re the one who started this off with the insane claim that there’s no tradeoff, then claimed there are no optimizations available below C++ (i.e. C++ is the absolute most optimized code a person can write).

This is a hallucination that has nothing to do with your original point. The vast majority of software could be sped up 100x to 1000x easily if they were written slightly different. Asm optimizations are extremely niche with modern CPUs and compilers and the gains are minuscule compared to C++ that is already done right. This is an idea that permeates through inexperienced programmers, that asm is some sort of necessity for software that runs faster than scripting languages.

Go ahead and show me what specifically you are talking about with C++, assembly or any systems language or optimization.

Show me where writing slow software saves someone so much time, show me any actual evidence or explanation of this claim.

replies(2): >>43981618 #>>43983666 #
3. ryao ◴[] No.43981618[source]
For what it is worth, there is room for improvement in how people use scripting languages. I have seen Kodi extensions run remarkably slowly and upon looking at their source code to see why, I saw that everything was being done in a single thread with blocking on relatively slow network traffic. There was no concurrency being attempted at all, while all of the high performance projects I have touched in either C or C++ had concurrency. The plugin would have needed a major rewrite to speed things up, but it would have made things that took minutes take a few seconds if it were done. Unfortunately, doing the rewrite was on the wrong side of a simple “is it worth the time” curve, so I left it alone:

https://xkcd.com/1205/

Just today, I was thinking about the slow load times of a bloated Drupal site that heard partially attributable to a YouTube embed. I then found this, which claims to give a 224x performance increase over YouTube’s stock embed (and shame on YouTube for not improving it):

https://github.com/paulirish/lite-youtube-embed

In the past, I have written electron applications (I had tried Qt first, but had trouble figuring out how what I wanted after 20 hours of trying, and got what I needed from electron in 10). The electron applications are part of appliances that are based on the Raspberry Pi CM4. The electron application loads in a couple seconds on the CM4 (and less than 1 second on my desktop). Rather than using the tools web developers often use that produce absurd amounts of HTML and JS, I wrote nearly every line of HTML and JavaScript by hand (as I would have done 25 years ago) such that it was exactly what I needed and there was no waste. I also had client side JavaScript code running asynchronously after the page loaded. To be fair, I did use a few third party libraries like express and an on screen keyboard, but they were relatively light weight ones.

Out of curiosity, I did a proof of concept port of one application from electron to WebKitGTK with around 100 lines of C. The proof of concept kept nodejs running as a local express server that was accessed by the client side JavaScript running in the WebKitGTK front end via HTTP requests. This cut memory usage in half and seemed to launch slightly faster (although I did not measure it). I estimated that memory usage would be cut in half again if I rewrote the server side JavaScript in C. Memory usage would likely have dropped even more and load times would have become even quicker if I taught myself how to use a GUI toolkit to eliminate the need for client side HTML and JavaScript, but I had more important things to do than spend many more hours to incrementally improve what already worked (and I suspect many are in the same situation).

To give a final example, I had a POSIX shell script that did a few tasks, such as polling a server on its LAN for configuration updates to certain files and doing HA failover of another system were down, among other things. I realized the script iterated too slowly, so I rewrote it to launch a subshell as part of its main loop that does polling (with file locking to prevent multiple sub shells from doing polling at the same time). This allowed me to guarantee HA failover always happens within 5 seconds of another machine going down, and all it took were using concepts from C (threading and locking). They were not as elegant as actual C code (since subshells are not LWPs and thus need IPC mechanisms like file locks), but they worked. I know polling is inefficient, but it is fairly foolproof (no need to handle clients being offline when it is time for a push), robustness was paramount and development time was needed elsewhere.

In any case, using C (or if you must, C++) is definitely better than a scripting language, provided you use it intelligently. If you use techniques from high performance C code in scripting languages, code written in them often becomes many times faster. I only knew how to do things in other languages relatively efficiently because I was replicating what I would be doing in C (or if forced, C++). If I could use C for everything, I would, but I never taught myself how to do GUIs in C, so I am using my 90s era HTML skills as a crutch. However, reading this exchange (and writing this reply) has inspired me to make an effort to learn.

4. sorcerer-mar ◴[] No.43983666[source]
So again, what you're saying is there is a tradeoff. You just think it should be made in a different place than where the vast majority of engineers in the world choose to make it. That's fine! It's probably because they're idiots and you're really smart, but it's obviously not because there's no tradeoff.

> that asm is some sort of necessity for software that runs faster than scripting languages.

It seems you're not tracking the flow of the conversation if you believe this is what I'm saying. I am saying there is always a way to make things faster by sacrificing other things developer productivity, feature sets, talent pool, or distribution methods. You agree with me, it turns out!

replies(1): >>43984814 #
5. CyberDildonics ◴[] No.43984814{3}[source]
So again, what you're saying is there is a tradeoff. You just think it should be made in a different place than where the vast majority of engineers in the world choose to make it.

Show me what it is I said that makes you think that.

That's fine! It's probably because they're idiots and you're really smart, but it's obviously not because there's no tradeoff.

Where did I say any of this? I could teach anyone to make faster software in an hour or two, but myths like the ones you are perpetuating make people think it's difficult or faster software is more complicated.

You originally said that making software faster 'decreases velocity and sacrifices features' but you can't explain or backup any of that.

You agree with me, it turns out!

I think what actually happened is that you made some claims that get repeated but they aren't from your actual experience and you're trying to avoid giving real evidence or explanations so you keep trying to shift what you're saying to something else.

The truth is that if someone just learns to program with types and a few basic techniques they can get away from writing slow software forever and it doesn't come at any development speed, just a little learning up front that used to be considered the basics.

Next time you reply show me actual evidence of the slow software you need to write to save development time. I think the reality is that this is just not something you know a lot about, but instead of learning about it you want to pretend there is any truth to what you originally said. Show me any actual evidence or explanation instead of just making the same claims over and over.

replies(1): >>43984985 #
6. sorcerer-mar ◴[] No.43984985{4}[source]
> I could teach anyone to make faster software in an hour or two,

Is one or two hours of two engineers' time more than zero hours, or no?

> just a little learning up front

Is a little learning more than zero learning, or no?

IMO your argument would hold a lot more weight if people felt like their software (as users) is slow, but many people do not. Save for a few applications, I would prefer they keep their same performance profile and improve their feature set than spend any time doing the reverse. And as you have said multiple times now: it does indeed take time!

If your original position was what it is now, which is "there's low hanging fruit," I wouldn't disagree. But what you said is there's no tradeoff. And of course now you are saying there is a tradeoff... so now we agree! Where any one person should land on that tradeoff is super project-specific, so not sure why you're being so assertive about this blanket statement lol.

replies(1): >>43985630 #
7. CyberDildonics ◴[] No.43985630{5}[source]
Now learning something new for a few hours means we'd have to give up is squishy hard-to-measure things like "feature sets" and "engineering velocity." ?

You made up stuff I didn't say, you won't back up your claims with any sort of evidence, you keep saying things that aren't relevant, what is the point of this?

This thread is john carmack saying the world could get by with cheaper computers if software wasn't so terrible and you are basically trying to argue with zero evidence that software needs to be terrible.

Why can't you give any evidence to back up your original claim? Why can't you show a single program fragment or give a single example?

replies(1): >>43986120 #
8. sorcerer-mar ◴[] No.43986120{6}[source]
Okay let's do it this way.

It's obviously true the world could get by with cheaper computers if software was more performant.

So why don't we?

replies(1): >>43986756 #
9. CyberDildonics ◴[] No.43986756{7}[source]
Because people spread and believe misinformation about it being difficult to avoid writing grossly inefficient software.

We know that it isn't difficult because if it was you would have had a single shred of evidence after a dozen comments of me asking for it.