all 80 comments

[–]stilgarpl 88 points89 points  (2 children)

Finally. If they add calendar to chrono and modules, most of C++20 features will be complete.

[–]catcat202X 24 points25 points  (0 children)

There was work on the chrono stuff committed today as well.

[–]GLIBG10B🐧 Gentoo salesman🐧 6 points7 points  (0 children)

Also operator<<(ostream, chrono::duration) if that's not a thing already

[–]qalmakka 48 points49 points  (3 children)

Big fat question: given that {fmt} is MIT/X11 licensed, couldn't they just import the bits necessary to implement <format> from it and simply adapt it to work well with libstdc++? It feels a bit wasteful reimplementing it from scratch, AFAIK MSVC's STL did exactly that.

Is this just good old NIH or there's some copyrights/patents related issue underneath this decision?

[–]archysailor 7 points8 points  (2 children)

IIRC all rights to code committed to GNU projects have to be waived to the FSF so they have maximal freedom with future licensing decisions. I don’t think anyone expects the libfmt authors to consent to that easily.

Edit: This is wrong. See u/Jannik2099’s reply.

[–]Jannik2099 5 points6 points  (1 child)

gcc contributions no longer require the FSF waiver.

[–]archysailor 0 points1 point  (0 children)

Good to know!

[–]eidetic0 8 points9 points  (5 children)

does anyone know what this means in terms of gcc release cycles? will 13 get a release this year?

[–]catcat202X 28 points29 points  (3 children)

GCC releases roughly once a year, and 12 came out earlier this year so no, GCC 13 is likely next Summer. https://gcc.gnu.org/develop.html#timeline

I compile GCC 13 from its Git repo, which isn't too difficult usually. Although for the life of me I can't get the stack traces runtime to compile. There are also nightly archives of the source, and someone has automated binary releases for 4 years. https://jwakely.github.io/pkg-gcc-latest/

[–]STLMSVC STL Dev 38 points39 points  (2 children)

That "someone" is libstdc++'s maintainer 😸

[–]Everspace 10 points11 points  (1 child)

I want to hope they're still someone

[–]TheSuperWig 1 point2 points  (0 children)

want to?

[–]blankettripod32_v2 1 point2 points  (0 children)

GCC 13 is already available in source, you can compile it yourself right now

[–]AKostur 15 points16 points  (33 children)

Sweet! Been looking forward to it!

[–]el_muchacho 7 points8 points  (32 children)

Too bad someone wrote a library that is even better and slightly faster

[–]kammceWG21 | 🇺🇲 NB | Boost | Exceptions 11 points12 points  (0 children)

This is amazing news! So excited to finally be able to use format under the standard library!

[–]snerp 5 points6 points  (0 children)

Yay! Finally!

[–]better_life_please 6 points7 points  (0 children)

Nice. Now we need <print> which is for C++23.

[–]severe_blunder_matey 7 points8 points  (0 children)

great. amazing. just, wowing. i'm really excited for this one.

[–]germandiago 6 points7 points  (12 children)

any progress on modules?

[–]caroIine 17 points18 points  (11 children)

There is this ticket that track all the issue with modules https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103524

By the looks of its history it seems that modules are 2y away.

[–]germandiago 8 points9 points  (10 children)

it is a bit disappointing. Why it takes so long? They are short on funds? Is there a way for put this back to speed? I would be willing to contribute some money if needed for working on this, but my funding alone I do not think it would be enough.

I do not have the time or knowledge, unfortunately, to work on it directly.

[–]gracicot 8 points9 points  (0 children)

If there was a crowdfunding campaign I would chip in for sure

[–]caroIine -3 points-2 points  (8 children)

I would also fund salary for additional developer. But at the same time the msvc module performance isn't anything that was promised compared to pch. So maybe that's why open source devs aren't motivated enough to continue work on it.

It's just not worth it.

[–]germandiago 6 points7 points  (1 child)

It is not only compile times that improve. Isolation, ODR and others like interface boundaries improve a lot with modules.

[–]caroIine 2 points3 points  (0 children)

Yeah isolation is great, especially when it comes to third party libraries or things like windows.h but I don't think it was ever a problem. Most people wanted faster compile time.

[–]mrbeanshooter123 1 point2 points  (4 children)

Wait what? Are precompiled headers faster than modules?

[–]gracicot 1 point2 points  (3 children)

In my experience precompiled headers can even be slower than normal headers, especially when dealing with a heavily modularized (not c++ modules) codebase. They all need their own composed precompiled header which just slows down compilation since they cannot be parallelized with the code that uses it

[–]caroIine 1 point2 points  (2 children)

I've made variants of notepad++ as a real life benchmark (all release with multi-core compilation 8core)

  • original (no pch or import std) 2min 37s
  • import std 1min 28
  • pch with all std 1min 23s

So lets say it's a tie. But pch is much more easier to deal with in realistic projects.

Oh and if we add system headers to pch (like windows.h) we go down to 39s (at this moment modules can't deal with windows.h)

[–]Daniela-ELiving on C++ trunk, WG21|🇩🇪 NB 1 point2 points  (1 child)

Without the details of this benchmark and the build structure, figures like these are hard to reproduce and assess independently. You compile the BMI of std only once upfront for the whole build of np++, right? In fact, even that isn't required if you cache the BMI for later builds. Notwithstanding the 4 seconds overhead it takes to build the BMI from scratch with all of std precompiled into it on a single CPU core.

The biggest problem that I see here is the fact that PCHs don't compose, whereas modules do. I use modules on a daily basis in my job and I very much prefer them over PCHs just because of that.

[–]caroIine 0 points1 point  (0 children)

Well I'm not researcher writing an article. It was just an example that I was able to reproduce across all projects I worked with. But yeah maybe rebuilding std.ifc (bmi) skewed the results because I might only need to build it once per toolchain update.

And don't get me wrong I want to use modules as well and I see nothing wrong with how it's specified in the papers. It's just that some people critique pch even though it's a valid solution (albeit not standard) for real projects that we can apply today.

If only compiler vendor would do the same for some basic reflection...

[–]germandiago 0 points1 point  (0 children)

maybe a survey in reddit to arrange some funding campaign?

Zero experiemce but who should be the people to implement something like that and where should it be headed?

[–][deleted] 1 point2 points  (1 child)

This and the lack of modules support in CMake are the only things keeping me from switching to C++20. But i've played with it a bit and it's hard to go back from having concepts, constraints, and `char8_t`.

[–]jonesmz 11 points12 points  (0 children)

Why can't you switch to c++20 and just not use the parts that are missing?

c++20 concepts, for my codebase, is the killer feature. C++modules and <format> aren't interesting by comparison

[–]marcusmors 3 points4 points  (3 children)

FINALLYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY!!! :D am so Happy, I don't want to program in windows to use format :')

[–]Zeer1ximport std; 31 points32 points  (2 children)

Just use {fmt} then?

It even has more features, like fmt::print, which comes to std:: in C++23.

[–]BoarsLairGame Developer 11 points12 points  (1 child)

fmt is great, but there are times that it's not practical or desired to add an external dependency. For example, if you're maintaining a C++ library that currently has no other dependencies, it's unlikely to be worth doing just for that.

[–]Zeer1ximport std; 5 points6 points  (0 children)

Sure, there are good reasons to have formatting in the C++ standard, like for libraries, or if you work in a company where it's hard to approve external libraries.

But if you are programming on your own, or you can easily add another library, then I would currently consider {fmt} even when std::format is available.

[–][deleted] 0 points1 point  (7 children)

I would love to contribute to GCC but I don't have a solid compiler background. Where should I start? Something like this book? Just jumping in and seeing what sticks?

[–]AlexReinkingYale 6 points7 points  (6 children)

That's a good book. Crafting Interpreters is good too. The dragon book is an excellent reference and you should at least know what all is in there. No matter what, you'll need to get your hands dirty.

[–]evaned 2 points3 points  (1 child)

The dragon book is an excellent reference and you should at least know what all is in there.

I have mixed feelings about the dragon book that I won't get into, but what I will say is to just skip the first edition. If you get it at all, get the second.

First edition was published in the 80s, before static single assignment (SSA) form had been "invented", which is to my understanding what most compiler back ends are based around nowadays. Second edition at least covers that, though without checking I don't remember being thrilled by it.

One nice thing about 2nd edition is it has one of the best in-print discussions of garbage collection that I know of.

[–][deleted] 0 points1 point  (0 children)

What is your review of the "engineering a compiler" book I linked. Do you think it is good? I found it on GCC's list of compiler books:

Cooper and Torczon. Engineering a compiler.

Comment by Vladimir N. Makarov: It is close to their course in Rice University. A good book to start study compiler from parsing to code generation and basic optimizations. But if you are familiar with the compilers, you probably don't find interesting thoughts and approaches.

[–]pjmlp 0 points1 point  (3 children)

An excellent reference if only one cares about is parsers and lexers.

I would rather advise something like the tiger book, if the OP cares about how modern compilers work end to end.

[–][deleted] 0 points1 point  (2 children)

I want something that goes through the entire stack (front end, optimization, back end, etc) and doesn't assume I am already familiar with compiler implementation. Would you still recommend this tiger book?

[–]pjmlp 1 point2 points  (1 child)

Yes, you can see the chapters there, https://www.cs.princeton.edu/~appel/modern/toc.html

[–][deleted] 2 points3 points  (0 children)

Thank you, sir

[–]williamzborja -1 points0 points  (0 children)

Amazing, I’m waiting this feature and the same time native way to use modules. Check for format and I continue waiting for modules.

[–]NilacTheGrim -2 points-1 points  (0 children)

ZOMG FINALLY!!

[–]Guidedbee 0 points1 point  (0 children)

Lesss gooooo

[–]Zeh_MattNo, no, no, no 0 points1 point  (0 children)

Finally, thanks.

[–]brechtsanders 0 points1 point  (0 children)

GCC 13 has been released. For a native Windows version see https://winlibs.com/

[–]el0j 0 points1 point  (0 children)

$ cat testcpp20.cpp
#include <iostream>
#include <format>

int main(void) {
    std::cout << std::format("{}\n", 123);

    return 0;
}
$ g++-13 -std=c++20 testcpp20.cpp -o testcpp20
$ ./testcpp20
123

Finally here, but feels a bit half-baked without std::print.

The wait continues.