C++ Modules Are Here to Stay

(faresbakhit.github.io)

34 points | by faresahmed 6 days ago ago

17 comments

  • reactjs_ 31 minutes ago

    Here’s the thing I don’t get about module partitions: They only seem to allow one level of encapsulation.

        Program
        - Module
          - Module Partition
    
    whereas in module systems that support module visibility, like Rust’s, you can decompose your program at multiple abstraction levels:

        Program
        - Private Module
          - Private Module
            - Private Module
            - Public Module
          - Public Module
    
    Maybe I am missing something. It seems like you will have to rely on discipline and documentation to enforce clean code layering in C++.
  • w4rh4wk5 29 minutes ago

    https://arewemodulesyet.org/ gives you an overview which libraries already provide a module version.

    • srcreigh 11 minutes ago

      Wow, the way this data is presented is hilarious.

      Log scale: Less than 3% done, but it looks like over 50%.

      Estimated completion date: 10 March 2195

      It would be less funny if they used an exponential model for the completion date to match the log scale.

  • cmovq an hour ago

    Can someone using modules chime in on whether they’ve seen build times improve?

    • nickelpro 21 minutes ago

      import std; is an order of magnitude faster than using the STL individually, if that's evidence enough for you. It's faster than #include <iostream> alone.

      Chuanqi says "The data I have obtained from practice ranges from 25% to 45%, excluding the build time of third-party libraries, including the standard library."[1]

      [1]: https://chuanqixu9.github.io/c++/2025/08/14/C++20-Modules.en...

      • luke5441 7 minutes ago

        Yeah, but now compare this to pre-compiled headers. Maybe we should be happy with getting a standard way to have pre-compiled std headers, but now my build has a "scanning" phase which takes up some time.

  • TimorousBestie 20 minutes ago

    I can’t deploy C++ modules to any of the hardware I use in the shop. Probably won’t change in the near-to-mid future.

    It seems likely I’ll have to move away from C++, or perhaps more accurately it’s moving away from me.

    • bluGill 11 minutes ago

      If you tools are not updated that isn't the fault of C++. You will feel the same about Rust when forced to used a 15 year old version too (as I write this Rust 1.0 is only 10 years old). Don't whine to me about these problems, whine to your vendors until they give you the new stuff.

  • feelamee an hour ago

    why use modules if PCH on your diagram is not much worse in compile times?

    • nickelpro 19 minutes ago

      Macro hygiene, static initialization ordering, control over symbol export (no more detail namespaces), slightly higher ceiling for compile-time and optimization performance.

      If these aren't compelling, there's no real reason.

    • bluGill 10 minutes ago

      modules are the future and the rules for are well thought out. Ever compiler has their own version of PCH and they all work different in annoying ways.

  • whobre an hour ago

    > auto main() -> int {

    Dude…

    • few 24 minutes ago

      And their code example doesn't actually return a value!

      • Davidbrcz 23 minutes ago

        For main it's explicitly allowed by the standard, and no return is equal to return 0

    • CamperBob2 39 minutes ago

      It's like calling a Ford Mustang Mach-E the "Model T++."

    • on_the_train an hour ago

      It's been the go-to syntax for 15 years now

      • Night_Thastus 6 minutes ago

        Go-to? I've never seen a project use it, I've only ever seen examples online.