News for hackers. Stuff that matters.
Re:C++ vs. Rust Build Times by pjmlp on Friday January 06, 2023 @01:33AM (#34271668)
Thing is, not every C++ project is full of template metaprogramming, and at least on the corporate world it is quite common to use binary libraries, which NuGET, conan, vcpkg, and OS package managers support.

Also at least in VC++, modules are already a thing, no need to keep parsing template code all the time.

Doing a C++23 import std (which imports the whole standard library) takes a fraction of the time of #include <iostream> in VC++.

So a clean build out from repo means compiling only our own code, not the whole world as in Rust.

Still looking forward to binary libraries support in cargo (well one can dream).

Re:C++ vs. Rust Build Times by forrestthewoods on Friday January 06, 2023 @01:44AM (#34271731)
> Doing a C++23 import std

It’ll be nice when this can be reliably used. According to cppreference MSVC has partial support and other compilers have zero support.

I’m not sure modules will be in widespread use before 2029.

https://en.cppreference.com/w/cpp/compiler_support

Re:C++ vs. Rust Build Times by pjmlp on Friday January 06, 2023 @02:31AM (#34271944)
VC++ support is good enough that all my C++ hobby coding is done with modules, not everything we code must be cross-platform from the get go.

GCC is getting there.

clang, well they seem stuck with their own initial modules implementation (module maps based), and now with Apple and Google out of the picture, the various compiler vendors that benefit from MIT license don't seem that eager to contribute to upstream other than LLVM.

Unfortunely everyone else seem to still be catching up with C++14 and C++17, depending on the ecosystem.

Re:C++ vs. Rust Build Times by forrestthewoods on Friday January 06, 2023 @03:10AM (#34272226)
> not everything we code must be cross-platform from the get go.

No, but the code I write for my job does have to be cross-platform from day 0. And that's the code base that is large enough where module improvements to compile time would be most useful! Hobby projects are small enough it's not super important.

So C++20 modules don't help me and probably won't until 2029! To my great dismay.

Re:C++ vs. Rust Build Times by pjmlp on Friday January 06, 2023 @03:16AM (#34272267)
Not only hobby projects, everyone that only depends of Windows and XBox workloads can also make use of modules.

However I agree it is a bummer for cross-platform code and there is a ton of it, with clang being the major culprit holding C++20 back.

Re:C++ vs. Rust Build Times by forrestthewoods on Friday January 06, 2023 @04:12AM (#34272630)
> everyone that only depends of Windows and XBox workloads can also make use of modules.

So that covers projects funded by Microsoft and… almost nothing else. Because if you can ship on Xbox you’d probably be smart to ship on PlayStation and possibly Switch.

The number of real projects that can use modules isn’t zero. But it’s pretty god damn close! This ain’t the hill to die on.

Re:C++ vs. Rust Build Times by pjmlp on Friday January 06, 2023 @05:49AM (#34273266)
Contrary to what FOSS folks think, in the gaming world, many studios actually enjoy the perks that come with being platform exclusives.

Which ironically, both Playstation and Nintendo win over XBox in exclusive titles.

Re:C++ vs. Rust Build Times by forrestthewoods on Friday January 06, 2023 @12:15PM (#34277595)
I’m not an FOSS folk. I’ve shipped a lot of games. I spend 95% of my dev time on Windows.

> many studios actually enjoy the perks that come with being platform exclusives

Yes, building a game for a single fixed piece of hardware is great fun. But we live in the cross-platform age. As practical matter the Xbox One and Xbox Series Blah are losers. Shipping for Xbox but not Playstation (and often times Switch) is just leaving money on the table.

The list of “games released only on Windows and Xbox” is very small.

Re:C++ vs. Rust Build Times by TillE on Friday January 06, 2023 @08:19AM (#34274275)
There is a lot of commercial Windows-only software out there, and most of it is C++.
Re:C++ vs. Rust Build Times by strager on Friday January 06, 2023 @01:46AM (#34271737)
> not every C++ project is full of template metaprogramming

You're right. My project is not one of those projects.

As mentioned in the article, the C++ project has no dependencies (outside googletest and the standard library, whose build time isn't included in the benchmarks).

Also, the project is relatively light on templates compared to most C++ code that I've seen. The biggest offenders are narrow_cast and vector.

> Also at least in VC++, modules are already a thing

I'd love to use them, but I mostly work on Linux and macOS. =[

> Still looking forward to binary libraries support in cargo (well one can dream).

I didn't consider this downside of Rust! I imagine rlibs can be cached manually, right? I don't know if rlibs are portable between machines.

Re:C++ vs. Rust Build Times by tumdum_ on Friday January 06, 2023 @03:26AM (#34272344)
> I imagine rlibs can be cached manually, right? I don't know if rlibs are portable between machines.

Is this not what sccache is already doing?

Re:C++ vs. Rust Build Times by mgaunard on Friday January 06, 2023 @05:19AM (#34273058)
Importing binary packages is a terrible idea, and a source of huge problems.

I don't understand how conan managed to get so much traction, it is so very bad, most of its recipes have billions of options most of which don't work.

The only sensible way to work with C++ is to always build from source, and let the build system transparently cache and reuse binary artifacts as an optimization.

Re:C++ vs. Rust Build Times by pjmlp on Friday January 06, 2023 @05:47AM (#34273251)
Not when one's business depends on shipping binaries, and selling components.

Then again, it isn't something that is relevant in GNU/Linux world, only in other platforms.

Re:C++ vs. Rust Build Times by mgaunard on Friday January 06, 2023 @11:55AM (#34277240)
There is nothing special about GNU/Linux is that respect.

You would still build your code from source, and be very careful handling any dependencies you don't have the source for.

The worst kind of undefined behaviour you can have in C++ is ODR violations, and importing binaries is more likely than not to trigger them, unless you closely manage their ABI.

Re:C++ vs. Rust Build Times by pjmlp on Friday January 06, 2023 @04:06PM (#34281058)
Yes, there is, the culture towards shipping binaries, or selling component libraries.
Re:C++ vs. Rust Build Times by vegerot on Friday January 06, 2023 @06:51PM (#34283120)
I think you two are talking past each other. He’s talking about hypotheticals, and you’re talking about what’s more common
Re:C++ vs. Rust Build Times by strager on Friday January 06, 2023 @05:55AM (#34273317)
> Importing binary packages is a terrible idea, and a source of huge problems.

Importing binary packages is a tradeoff.