Carbon is an experimental general-purpose programming language by google. It was announced by the “CPP NORTH” conference on July 2022, as a successor. Carbon also has shortcomings of intense specific several sorts. It provides similar features to CPP. It has the bi-directional inner operability of CPP. So, the existing CPP library can be used in carbon. Carbon also looked upon memory safety patterns to allow initialize variables. The language was developed as free and open source on GitHub. Google has a successful track record of developing and maintaining computer languages such as Go and dart.

This new programming language might change the future. Carbon is a possible successor of CPP developed by Google engineers. Those who are frustrated with the slow evolution of CPP carbon are now overcoming the speed of CPP. It is a modern language compatible with existing CPP and is very user-friendly if you know the fundamentals of CPP.

But why was carbon developed in the first place?

Carbon

Google engineers are frustrated with CPP because of numerous issues that bug the developers. And many years of technical development and research Carbon is an open-source project by Google. But the team is looking to reduce the contributions from google.

Why not use rust a memory-saving and modern language?

All CPP developers actually like rust. But most importantly carbon is designed for easy adoption by existing CPP code base and developers. It has bi-directional inner operability with CPP, which means you can use existing CPP libraries and carbon seamlessly or vice versa.

Basic information on how to run ‘carbon’.

You will need to install Google’s build tools like BAZEL and LLVM to build it to write hello world. In this language, there is the main function that uses print with a string literal and it looks pretty simple. But if you have never seen a CPP hello world that uses this character “cout” then it looks like a revolutionary improvement. But a big feature is the fact that it supports a modern generic system.

C++

Generics allow you to pass different types as parameters to classes and function in a common pattern in statically typed languages. But CPP takes a different approach that is often misused and abused called templates. Carbon still supports templates but generics will provide a bunch of advantages in most situations. More importantly, carbon looked to improve upon memory safety patterns. More often than not, uninitialized variables result in bugs and memory access in CPP.

var x: i32 = 0;
while (not (x == 3)) {
    Print("I am number {0}", x);
    x = x + 1;
}
Print("Done!");

Bugs can be risky when hackers learn to exploit them. Carbon has an entire doc on its safety strategy and basically, it tries to be as safe as possible without hurting performance or interoperability with CPP and it can run in different modes like debug performance.

Conclusion

So was this blog helpful enough for you to know carbon better? We tried to compare carbon with CPP and rust as well. The modern-day features and performance improvements make it more appealing. Tell us in the comments what are your thoughts.

By Tanmay

Leave a Reply

Your email address will not be published. Required fields are marked *