Code360 powered by Coding Ninjas X Code360 powered by Coding Ninjas X
Table of contents
Carbon Programming Language
Problem Statement
Hello World Implementation
Time Complexity
Space Complexity
Frequently Asked Questions 
Who created Carbon?
Can Carbon compile a C++ code?
What type of language is Carbon?
Where can I run my Carbon code?
Is Carbon similar to C++?
Last Updated: Mar 27, 2024

Hello World in Carbon

0 upvote
Leveraging ChatGPT - GenAI as a Microsoft Data Expert
Prerita Agarwal
Data Specialist @
23 Jul, 2024 @ 01:30 PM


Hello Ninjas! This article will teach us how to get started with Carbon Programming Language and write a Hello World in Carbon. A Hello World in Carbon is generally used to introduce a language and its syntax. We will understand all parts of the “Hello World in Carbon” code in detail as we move along. So whether you are new to this language or here to learn, we will discuss everything about Carbon. Let's get started.

Hello World in Carbon Programming Language

Carbon Programming Language

Carbon programming language is a general-purpose programming language designed by Google. It was first introduced by Chandler Carruth at a conference in Toronto in July 2022. Carbon is an improvised version of C++ with some modified and some similar features. Carbon offers development ideas like generics and memory safety to meet the growing needs of the new age developers. The design, implementation, tools, and documentation related to Carbon are hosted on GitHub


Note that Carbon is in the experimental stage and is not ready for use yet. This project is accepting contributions from developers on GitHub.  

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job

Problem Statement

Write a program to print Hello World in Carbon language.

Hello World Implementation

package sample api;
fn Main() -> i32 {
Print("Hello World in Carbon");
return 0;


Output of the program


Let us understand the syntax of Carbon Language.

  • "package" is a keyword that declares packages. It is a default file in the library.
  • "fn" is an introducer keyword that declares functions. Continuing "Main() -> i32 {...}" declares the main function. Here the Main function would return zero. The type of return of the given line of code is i32, an integer. 
  • "Print("Hello World in Carbon");" this line of the code prints the desired output, which in our case is Hello World in Carbon. Did you notice how it is similar to C language?
  • "return 0;" is the exit code line of the program. It means that function doesn't return any value.


Let us look at the time and space complexities.

Time Complexity

The time complexity of this program is O(1).

Reason: O(1) means constant time. Here the time complexity is O(1) as the code takes constant time to execute.

Space Complexity

The space complexity of this program is O(1).

Reason: We are not using any extra space for our code, so the space complexity is O(1).

Read More - Time Complexity of Sorting Algorithms


Listed below are some advantages of Carbon Programming Language

  • Carbon is designed to match the performance of C++. Therefore, speed here is not an issue.
  • Carbon can compile your existing C++ programs.
  • Carbon promises a memory-safe subset path.
  • It is user-friendly and easy to learn.


Listed below are some disadvantages of Carbon Programming Language

  • This language doesn’t promise any scope as it is new to the market.
  • Carbon is in its experimental stage; therefore, it is bound to undergo several changes before becoming a standard language like C++ and Python.
  • Carbon is in its experimental stage and is not supported by any compiler like Microsoft Visual Code. 
  • As mentioned earlier, carbon is user-friendly and easy to learn. But it is more challenging than some established languages like Python; therefore, some users might find it challenging to learn. 

Frequently Asked Questions 

Who created Carbon?

Google designs carbon programming language. Chandler Carruth first introduced it at a conference in Toronto in July 2022.  

Can Carbon compile a C++ code?

Yes, Carbon can compile C++ code. It is intended to be compatible with C++.

What type of language is Carbon?

Carbon programming language is a general-purpose and interpreted programming language.

Where can I run my Carbon code?

As Carbon is not ready for use yet, you can use online compilers for running Carbon codes. One such online compiler is compiler explorer.

Is Carbon similar to C++?

Carbon is an improvised version of C++ with some modified and similar features.


We learned about the Carbon Programming Language in this article and wrote our first Hello World in Carbon program together in Carbon. You can explore some simple problems in Carbon, like a Program to find if a number is even or odd in Carbon or Find Fibonacci Numbers in Carbon
If you want to dig deeper into the Carbon Programming language, here are some related articles - 

You may refer to our Guided Path on Code Studios to enhance your skill set on DSACompetitive ProgrammingSystem Design, and much more. Check out essential interview questions, practise our available mock tests, look at the interview bundle for interview preparations, and so much more!

Live masterclass