Please enable JavaScript to use CodeHS

Hello world

How to write your first program in a few different languages

By Jeremy Keeshin

CEO of CodeHS

"Hello world" is the name of the first program that many people learn to write.


You first just want to see if you can write anything out to the screen.


Here we'll show you what "Hello world" looks like in a few different programming languages. Click the green Run button below.

This first program is Hello world in python.


You'll notice a few important things. First we use the print function which is what lets us write to the screen. After print we have a parentheses, and in between the parentheses we write whatever we want to print out between quotation marks. So here we have "Hello world" between quotation marks. After the quote we close the parentheses.


Look at another example below with Hello world in JavaScript. Click the green Run button.

What you'll notice here is that instead of using print like in python, the function here is console.log. Otherwise it looks very similar, we write what we want to print--"Hello world" between quotation marks. However here it ends with a semicolon (;), in python you don't need semicolons.


See what happens if you try changing the text. Or removing the quotation marks.


This next one is going to be a little tricker. Let's look at Hello World in Java.

What's interesting about Hello world is you can recognize patterns right away. They all seem to have some function or special word that allows us to print. They all have us write Hello world between quotation marks. But then there are differences.


Here we have lots of extra curly brackets (like { and }), and a line at the top that says a lot of extra things. In Java there is a bit more overhead to getting that first program to work.

This last program is Hello world in C++. Here you see we still have "Hello world" in quotes, which is called a string. But there is a line at the top that adds extra functionality and a few other lines to make it work. As you program more you'll learn more in depth what each of these mean. However, Hello World is a great place to start!


Take the python program below and try to print out your. name instead. Or print out multiple lines to the screen.