More then year have passed since I joined the Insolar team and switched from C++ to Golang. C++ was my main programming language for more than 10 years. Here in Insolar we are developing a blockchain platform for businesses.
I know couple companies are migrating their huge codebase from C/C++ to modern languages like Go and Rust. They also are splitting monolith to microservices.
I decided to improve my skills in software architecture, product management and leadership, and I started an open source project. I found several remote programmers and formed a development team. People wanted to get experience and public portfolio, but all of them used different languages. I decided to use microservices because of that.
One guy wanted to use C++ and I asked him to search for good examples of Cpp cloud-native microservice, but he didn’t find any. Then I were googling for several days but didn’t find too. I’ll try to write my own.
C++ is not popular for web development, but modern C++17 and C++20 standards are pretty cool and useful.
GCC 9.1 was released and now it one step closer for support of the new standard.
Why programmers have to rewrite their code to a different language? They could take familiar but modern tools. What do you think?
I also have experience in Java, Ruby, JS, PHP on the backend. And I’ll try to bring the best practices from different worlds.
C++ is not popular for cloud apps because of several reasons.
the language is complex, memory management
the standard library doesn’t provide networking features
dependency and third-party management
complex building system, linking and potential ABI issues
holy wars about code style
tooling, code coverage, linters, code checkers are hard to setup
Let’s talk about this reasons.
I agree, the language is complex with manual memory management, but it follows the zero-overhead principle.
“What you don’t use, you don’t pay for”
A memory leak is a very bad thing, especially in a monolithic architecture. But today you have tools to solve this problem. First, are developer tools such as profiling and code sanitizers.
If you take any modern language, it has package manager. In c++ world people uses several approaches: operating system package managers(apt, yum, homebrew), git submodules and own bicycle scripts written on python, perl, bash, etc. There are also several special package managers: Conan, Hunter, Buckaroo, cpm, qpm.
There are several build systems in C++ world, but CMake became standard de-facto. CMake recipes are not easy to read and understand, but if you look to WebPack or Gradle, you will agree that it complex too. Developers should well study ecosystem tools.
Some languages have a default community accepted coding style: Python PEP-8, PHP PSR-2, but C++ doesn’t. All teams, where I worked, had own coding style usually based on Google C++ Style Guide . Now I’m happy that Golang developers use built-in formatting tool and don’t argue about CamelCase, Egyptian brackets etc.
It doesn’t matter which language developers use, they should follow good practices: code review, unit testing, automated code analysis. There are many tools for that, see below.
You should choose tools and set up your own CI pipeline. Some good tools are paid.
Clang and GCC sanitizers
Static code analyzers: cppcheck, clang-tidy, pvs-studio
Cloud native C++ microservice. Part 3 — Dependencies, Package Managers, Conan.io
Cloud native C++ microservice. Part 4 — Observability
Cloud native C++ microservice. Part 5 — Databases
Cloud native C++ microservice. Part 6 — Auth, JWT
Cloud native C++ microservice. Part 7 — API, REST,GRPC