C++ build times at Figma were getting so long that it was reducing dev productivity. Figma was able to reduce build times by 50% by using libclang's Python bindings to identify and remove unnecessary header file inclusions, reducing the amount of code the compiler needs to process. It also used a tool to track and address build time regressions over time and “fwd.h” files to centralize forward declarations within code directories.
Monday, April 29, 2024It is a common misconception that `emplace_back` in C++ automatically enables move semantics. `emplace_back` is not magic and does not implicitly move objects. Using `std::move` is necessary to explicitly request a move operation. While both `push_back` and `emplace_back` can achieve the same result with `std::move`, `push_back` should be used by default for better compile-time performance, as `emplace_back` involves more complex template instantiation.
The Safe C++ Extensions proposal, recently published by the C++ community, aims to address the challenge of ensuring that C++ code is free of memory safety bugs. Private and public sector organizations have been pushing programmers to write new applications and rewrite old ones in memory safe languages over the past two years. The majority of serious vulnerabilities in large codebases come from memory safety flaws. The Safe C++ project adds new technology for ensuring memory safety, preventing users from writing unsafe code. It allows existing code to work as always and ensures stakeholders have control for incrementally opting into safety.