Ever wondered what your very first line of code looks like in a new language?

Almost every programming book and tutorial starts with the same tiny program, "Hello World". It shows how a language prints text, where the program starts and what its syntax looks like.

The short answer: almost every language here has a way to print a line of text, and the samples below show it in 26 languages.

I first published this list in 2016. For this update, I went through every single sample and fixed the ones that were broken.

I also swapped a few old languages for ones people learn today, like Rust, Go and Kotlin.

Also Read: 9 Best Android Apps to Learn to Code in 2026

Hello World in different programming languages

TL;DR

  • Almost any language: the first program prints one line of text, usually "Hello, world!". HTML is markup, so its sample shows a heading instead.
  • Want to try without installing? Go, Rust and Kotlin have free official playgrounds in your browser. In JavaScript, press F12 and use the console.
  • Where to start: C is a great first language if you want to understand how computers work. Python is one of the easiest languages for scripts.
  • Old samples: several 2016 samples were broken or outdated, so use the fixed versions below.

What Is a Hello World Program?

A Hello World program is a tiny program that prints one line of text, usually "Hello, world!".

It's the first program in almost every book and tutorial because it shows the basics of a language in one go.

Hello World in 26 Languages at a Glance

Here's the print command each language uses. The full sample for each one is in the list below.

LanguagePrint command
Cputs()
C++std::cout
C#Console.WriteLine()
JavaSystem.out.println()
JavaScriptconsole.log()
HTML<h1> heading
Pythonprint()
PascalWriteLn()
Rubyputs
Visual Basic .NETConsole.WriteLine()
MATLABdisp()
PHPecho
Bashecho
Perlprint
BASICPRINT
Objective-CNSLog()
Kotlinprintln()
TypeScriptconsole.log()
Logoprint
Rustprintln!()
Gofmt.Println()
DelphiWriteln()
Juliaprintln()
Processingprintln()
Rcat()
Swiftprint()

Do You Need Special Software?

In 2016, I said you needed Turbo C or Borland C to write C programs. Those tools are long gone.

Today, most people use a free code editor like Visual Studio Code, plus the compiler for their language. For C and C++, that's usually GCC or Clang.

You don't need to install anything to try some of these, though. Go, Rust and Kotlin have free official playgrounds in your browser:

Also Read: 10 Best Notepad Tricks and Hacks for Windows 11

How to Say 'Hello World' in 26 Different Programming Languages

Some of these are one line. Some take a few more.

1. C

#include <stdio.h>

int main(void)
{
    puts("Hello, world!");
    return 0;
}

2. C++

#include <iostream>

int main()
{
    std::cout << "Hello, world!\n";
    return 0;
}

The 2016 version was missing <iostream> after #include, so it wouldn't compile.

3. C#

using System;

class Program
{
    static void Main()
    {
        Console.WriteLine("Hello, world!");
    }
}

In a new .NET console project, this one line is enough:

Console.WriteLine("Hello, world!");

4. Java

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}

Save it as HelloWorld.java and run it with java HelloWorld.java.

Since Java 25, you can write it even shorter:

void main() {
    IO.println("Hello, world!");
}

My 2016 sample opened a whole Swing window just to say hello. It worked, but a plain console program is how most people start now.

5. JavaScript

console.log("Hello, world!");

Run it in your browser's console (press F12) or with Node.js.

6. HTML

<!DOCTYPE html>
<html>
  <head>
    <title>Hello</title>
  </head>
  <body>
    <h1>Hello, world!</h1>
  </body>
</html>

HTML is a markup language, not a programming language. But your first web page still counts!

7. Python

print("Hello, world!")

My 2016 version was print "Hello, world!". That's Python 2, which reached its end of life on January 1, 2020.

In Python 3, print needs brackets.

8. Pascal

program HelloWorld;
begin
  WriteLn('Hello, world!');
end.

9. Ruby

puts "Hello, world!"

10. Visual Basic .NET

Imports System

Module Module1
    Sub Main()
        Console.WriteLine("Hello, world!")
    End Sub
End Module

11. MATLAB

disp('Hello, world!')

This also works in GNU Octave, a free alternative to MATLAB.

12. PHP

<?php
echo "Hello, world!\n";

The 2016 list had jQuery here. jQuery is a JavaScript library, not a language, so I replaced it with PHP, which still runs a huge part of the web.

13. Bash

#!/bin/bash
echo "Hello, world!"

14. Perl

print "Hello, world!\n";

15. BASIC

PRINT "Hello, world!"

16. Objective-C

#import <Foundation/Foundation.h>

int main(void)
{
    @autoreleasepool {
        NSLog(@"Hello, world!");
    }
    return 0;
}

17. Kotlin

fun main() {
    println("Hello, world!")
}

Kotlin is Google's preferred language for Android apps. It replaces XSLT from my 2016 list, whose sample was blank anyway.

18. TypeScript

const message: string = "Hello, world!";
console.log(message);

TypeScript is JavaScript with types. It replaces CoffeeScript, which very few new projects use today.

Remember the turtle from school computer class? That's Logo.

20. Rust

fn main() {
    println!("Hello, world!");
}

Rust replaces VBScript, which Microsoft is phasing out of Windows.

21. Go

package main

import "fmt"

func main() {
    fmt.Println("Hello, world!")
}

Go replaces Clipper, a database language from the 1980s.

22. Delphi

program HelloWorld;

{$APPTYPE CONSOLE}

begin
  Writeln('Hello, world!');
end.

Delphi is based on Pascal. The {$APPTYPE CONSOLE} line tells it to make a console app instead of a window.

23. Julia

println("Hello, world!")

24. Processing

void setup() {
  println("Hello, world!");
}

25. R

cat("Hello, world!\n")

26. Swift

print("Hello, world!")

My 2016 sample used println(). Swift renamed it to print() back in 2015, so the old one doesn't run anymore.

Is C the Base of Every Programming Language?

No. I heard this at a seminar around the time I started learning, and it isn't quite true.

When I first wrote this in 2016, I was two years into my BSc (IT), a Bachelor of Science in Information Technology. My professor started us off with C++, which is basically a more advanced version of C, with some of the syntax changed.

Python, Ruby and Kotlin are not based on C. But a lot of popular languages, like C++, C#, Java, JavaScript and Go, borrowed C's style of curly braces and semicolons.

So once you know C, many other languages feel familiar. That's why I still say C is a great first language if you want to really understand how computers work.

Are C and C++ Outdated?

No. People say they are, but they're not.

Facebook's owner, Meta, still uses C++ for a lot of the heavy work behind its apps. Its open-source C++ library, Folly, says it's "used extensively at Meta."

What Changed Since 2016

Here's a quick summary of everything I fixed or replaced:

  • C and C++ were missing the header names after #include.
  • Python used old Python 2 syntax.
  • Swift used println(), which no longer exists.
  • Java now uses a normal console program instead of a Swing window.
  • JavaScript uses console.log() instead of document.write().
  • jQuery, XSLT, CoffeeScript, VBScript and Clipper made way for PHP, Kotlin, TypeScript, Rust and Go.

Worth knowing: the shorter Java version needs Java 25 or later, Python 2 has reached its end of life, and Swift's println() doesn't run anymore. Check the version you're running before you copy an old sample.

The original 2016 samples came from AllTechBuzz, and I've rewritten them all since.

Which Language Should You Start With?

Choose your programming field properly. It depends on what you want to build:

  • Understand how computers work: C. It's the language I'd pick for a first look at what's happening under the hood.
  • Write quick scripts: Python. The name sounds scarier than the language.
  • Make web pages: start with HTML, then add JavaScript to make the page do things.
  • Build Android apps: Kotlin, Google's preferred language for Android apps.
  • Try a language without installing anything: Go, Rust or Kotlin in their free browser playgrounds.

Also Read: Xtreme Tricks Introduction and All About It

Final Thoughts

Hello World is a small start, but it shows you how a language prints text, where the program begins and what the syntax looks like.

My advice is to pick one language, run its Hello World, and then change the text. That's how most programmers begin.

Languages and their versions keep moving on, so check the official docs for the version you install. And don't drop a language just because someone calls it outdated.

FAQs

What is a Hello World program?

It's a tiny program that prints "Hello, world!" to the screen. It shows how a language prints text, where the program starts and what its syntax looks like.

Do I need to install anything to try Hello World?

Not for Go, Rust or Kotlin, which have free browser playgrounds, or JavaScript, which runs in any browser console. Other languages need a code editor like Visual Studio Code plus that language's compiler.

Which programming language should I learn first?

C is a great first language if you want to really understand how computers work. If you just want to write scripts, start with Python, which is one of the easiest languages to learn.

Are C and C++ outdated?

No. Meta still uses C++ for a lot of the heavy work behind its apps, and its open-source C++ library Folly says it's "used extensively at Meta."

Why doesn't my old Hello World code run?

Some 2016 samples had errors. C and C++ were missing header names after #include, Python used Python 2 syntax, and Swift's println() was renamed to print().

Still stuck? Tell me through the contact page.

Xaif (Huzaifa Dhapai) started TechVerge in 2015. He's a web developer and long-time Android enthusiast who writes about Android tricks, apps, Windows and the tech he uses every day.

Topics

Comments (3)

  1. Hiren

    Hi bro
    Can you help me
    Sent me your theme plz
    I like your site very much
    But my site on blogger
    Plz sent me mail

    Pardeshihiren53@gmail.com

    1. XaifAuthor

      This site is on WordPress and the theme doesn't supports blogger

  2. career

    Now, You know How You Can Say Hello World In 26 Different Programming Languages. I hope you love this article. Choose your programming field properly.

Comments are closed. Have a question about this article? Ask through the contact page.