Company
Date Published
Author
MongoDB
Word count
1447
Language
English
Hacker News points
None

Summary

The MongoDB team successfully implemented ClangFormat to apply a globally consistent format to their C++ codebase, making it effortless for developers to produce properly formatted code and integrating automated checks at every phase of their development process. The difficulty of maintaining consistent formatting was addressed by planning and coordinating the implementation, ensuring that the tool was integrated into the workflow seamlessly. A manual and insufficient formatting process is doomed to be abandoned, as evidenced by the MongoDB team's previous attempts at automating code formatting. ClangFormat utilizes the clang tokenizer to parse C, C++, Objective C, Java, and JavaScript files, supporting the same C++ constructs as the clang compiler. The tool's success depends on thoughtful planning, buy-in from developers, and a willingness to compromise on formatting rules.