r/programming • • Dec 08 '20

Qt 6.0 Released

https://www.qt.io/blog/qt-6.0-released
664 Upvotes

229 comments sorted by

View all comments

Show parent comments

2

u/granadesnhorseshoes Dec 08 '20

except its not really a 2 cm stone and the platform aint a 10 passenger jet. It's a 75lb Buddha statue and the platforms a single engine Cessna.

It'll still go just fine and your happy to have it along but it aint free and its usefulness is entirely in who you ask.

0

u/[deleted] Dec 08 '20

[deleted]

5

u/rurabori Dec 08 '20

C is literally faster than C++

Ya have any benchmarks for that?

2

u/otterom Dec 09 '20

I dunno if this is valid, but it seems like C and C++ are good at various things. Just like any other language.

https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/gcc-gpp.html

0

u/[deleted] Dec 09 '20

[deleted]

3

u/rurabori Dec 09 '20

If you write bad code it's gonna run slow, surprise surprise. The c++ version involves creating multiple temporaries and allocating on the heap. This is not what string operator+ is for. If we want to be fair (and actually use the language as intended) rerun the benchmark with std::format or rather fmt::format_to because snprintf doesn't allocate but uses a buffer on stack just like format_to would.

I'll take a wild guess and say you aren't very experienced with this stuff. First of all, once the code is compiled to IR, most backends are the same (rustc uses llvm just like clang does for example). So much of C and C++ code runs through the same optimization pipelines. The advantage for C++ is, for example some of the computation can be made once during compilation (constexpr, consteval, TMP) etc. and sometimes its stronger type system can lead to optimization wins too.

Not to say the language is without faults, it's obviously not. But these sentiments about C being inherently faster are just not true. Just like statements like C++ is inherently faster than Rust aren't true. Well written code is the most important factor in it being fast.