Well, it may not be true that C++ is going the way of Cobol, but lately I’ve been learning more about the deep problems of the language. There is true in there, it is a behemoth that keeps evolving and getting bigger. And most new developers would not start with it as the first language, which makes sense if I am honest.
It seems one of the main issue people have with C++ is the committee that is in charge of evolving the language, the way it is composed and the fact that they are trying to keep back compatibility. Why? Because there are so many projects in C++ in big companies, and many of the members of the standard work for those companies, the critics say, that it impedes the evolution of the language. And that sounds a bit like Cobol: there are so many critical systems written in that language that changing it or substituting codebases with something else is too big of a task. Mainly banking systems that are scared of touching code that works.
So that is what I mean about going the Cobol way: there are too many important software in C++ that makes it difficult to consider moving to a different language. But it begs the question: what other language could be suitable as a replacement?
Options
If you want to change the language a system is written you need to use one that allows you to obtain at least the same results, in terms of efficiency in particular. So what alternatives are out there that, in theory at least, provide low level control as C++ but also offers high level functionalities?
The first candidate could be Rust, as it was advertised as C++ replacement. And there are a lot of people really happy about the language. It seems for sure a great language and it comes with some great ideas that I remember using in some projects in C++. That means, we implemented similar functionality in our code to have the same behaviour. That says a lot about the quality of Rust as a language.
But what else? Maybe Golang, but most of the famous languages nowadays have garbage collector, or dynamic typing and those two characteristics discard them as substituting languages for big projects due to the lack of low level control of memory and the ability to control the execution in a tighter way. So we discard Java, Javascript, C#, Python… obviously I am talking about libraries for graphic rendering, operative systems, etc. For most of other projects we could do with some of those languages.
Until recently, the list of candidates for substituting C++ would only contain Rust. But new languages have been designed and we have new potential candidates. The ones I am aware of are Carbon, Odin and Zig. Potential candidates at least.
The next step: choose and learn one
This is something that I have been thinking some time already. Since time ago, Rust was the obvious candidate for me. However until recently, I didn’t find the energy to really start with it, for several reasons, but mainly because the last language I tried to learn let me frustrated and demoralized. It was Scala, and don’t get me wrong, the problem was not the language, but the situation at the time.
However, recently I discovered a lot of options apart from Rust: Carbon, Odin, Jai (although this one is in closed beta) and Zig. That led me to learn more about the biggest pitfalls of C++ and to learn more about languages, and some things about those languages. Carbon seems to be designed “by committee” and looks it will become huge too; Odin is very very interesting, mainly for the designer TheGingerBill who is a very knowledgeable guy with very deep and interesting videos about languages that you should watch, so it is a contender that attracts me a lot; Jai is being created by the famous game designer and programmer Jonathan Blow (Braid, The Witness, anyone?), however it is focused on being a language for game dev and it is still in closed beta, so sadly discarded; and Zig… I don’t know why but it looks interesting.
For some reason, it feels like Zig is easier to learn than Odin. Besides, Odin is a solo-development project as far as I know, and Zig is community driven. That may be good or bad, but in principle, I would expect to find more content and find more help when I’d hit a problem or a blocker. It is just a guess, but as I am serious about learning another low level language, this seems a good thing. And also I read some stuff about it that I do like. For example the approach to memory management, that is one of the powers and pitfalls of C (and to some extent to C++ too). The approach of Zig seems a good solution as you can read here:
Zig doesn't limit you on the way you code as Rust does, helps your remain safe and avoid leaks, but still let you go full rogue as you can do in C. I personally think it might be a convenient middle ground.
So Zig it is.
Closing
Although I have chosen the language, I have not much free time lately. And my daily work programming in C in a kind of embedded-like project doesn’t allow me to use the same dev environment that I like to use. That is Vim (Neovim nowadays) so most of my free time I use it to really configure and customize it in my PC. Last time I used Vim was almost a year ago, in my previous job, and moving to Neovim has proved to be kind of easy, however some tricky problems with how it works internally is holding me back a bit.
However soon I will be able to share here my first impressions and some code of my first tries on it. Wish me luck!