Comment by sorcerer-mar

4 days ago

> 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?

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.

  • 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.

    • 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.

      11 replies →

> Couldn't you create even faster software if you went down another level? Why don't you?

No, actually, C++ is pretty much as low as you can go.

Well, I mean, you can go lower but you're not going to get performance benefits. You could go down to C. But C is going to be more of the same or, more likely, slower. You're going to be swapping Templates for things like void *.

You could go to assembly, but let's be honest - who can write better assembly than a C++ compiler?

  • > You could go to assembly, but let's be honest - who can write better assembly than a C++ compiler?

    In other words, yes you can eek out more performance at lower levels. Then again at the silicon level. No, it's not worth it in 99.9999% of scenarios (because there are tradeoffs).