DEV Community

Cover image for 'Hello World!' in Different Programming Languages
Philomath
Philomath

Posted on

'Hello World!' in Different Programming Languages

Programming languages are the building blocks of modern technology. Each language has its own syntax and purpose, but they all share one common beginning: the infamous "Hello world!" program. This simple program is often the first step for programmers delving into a new language.

In this post, we will explore how to write "Hello world!" in various programming languages, ranging from popular languages like JavaScript and Python to lesser-known languages like Rust and Perl.

JavaScript

console.log('Hello world!');
Enter fullscreen mode Exit fullscreen mode

Starting with one of the most popular programming languages, JavaScript. Known for its versatility and ubiquity, JavaScript is primarily used for web development. The "Hello world!" program in JavaScript is achieved by using the console.log() function to print the desired message to the browser's console.

Python

print("Hello world!")
Enter fullscreen mode Exit fullscreen mode

Python, known for its simplicity and readability, has gained a massive following in recent years. The "Hello world!" program in Python is elegantly achieved by using the built-in print() function to display the desired message on the console.

Go

package main

import "fmt"

func main() {
    fmt.Println("Hello world!")
}
Enter fullscreen mode Exit fullscreen mode

Go, a language developed by Google, is renowned for its efficiency and performance. To create a "Hello world!" program in Go, we declare a main package and utilize the fmt package's Println() function to print the message on the console.

Java

import java.io.*;

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

Java, a versatile and robust language, has long been a staple in software development. To create a "Hello world!" program in Java, we define a HelloWorld class and use the System.out.println() function to display the message on the console.

PHP

<?php
    echo "Hello world!";
?>
Enter fullscreen mode Exit fullscreen mode

PHP, a server-side scripting language, plays a crucial role in web development. Creating a "Hello world!" program in PHP is as simple as using the echo statement to output the desired message.

C

using System;

namespace HelloWorld
{
    class Hello 
    { 
        static void Main(string[] args)
        {
            System.Console.WriteLine("Hello world!");
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

C#, developed by Microsoft, is widely used for applications on the Microsoft platform. To create a "Hello world!" program in C#, we define a Hello class within the HelloWorld namespace and use the System.Console.WriteLine() function to display the message.

C++

#include <iostream>
using namespace std;

int main()
{
    cout<<"Hello world!";
    return 0;
}
Enter fullscreen mode Exit fullscreen mode

C++, an object-oriented programming language, is renowned for its performance and versatility. Creating a "Hello world!" program in C++ involves utilizing the cout object from the iostream library to display the message on the console.

Coffee Script

console.log("Hello world!")
Enter fullscreen mode Exit fullscreen mode

CoffeeScript, a programming language that compiles to JavaScript, focuses on enhancing code readability. Creating a "Hello world!" program in CoffeeScript is achieved through the console.log statement.

C

#include <stdio.h>

int main()
{
    printf("Hello world!");
    return 0;
}
Enter fullscreen mode Exit fullscreen mode

C, a low-level programming language, underpins much of modern computing. The "Hello world!" program in C uses the printf() function from the stdio.h library to display the message on the console.

R

cat('Hello world!')
Enter fullscreen mode Exit fullscreen mode

R, a language primarily used for statistical analysis, provides a concise way to create a "Hello world!" program. By using the cat() function, we can print the desired message.

Ruby

puts "Hello world!"
Enter fullscreen mode Exit fullscreen mode

Ruby, renowned for its simplicity and readability, offers an expressive and enjoyable programming experience. Creating a "Hello world!" program in Ruby is as simple as using the puts statement to output the desired message.

Rust

fn main() {
    println!("Hello world!");
}
Enter fullscreen mode Exit fullscreen mode

Rust, a modern systems programming language, focuses on both performance and safety. In Rust, we use the println!() macro to display the "Hello world!" message.

Perl

#!/usr/bin/perl

use strict;
use warnings;

print("Hello world!");
Enter fullscreen mode Exit fullscreen mode

Perl, a high-level, general-purpose language, prioritizes easy text processing. In Perl, we use the print function to display the desired message.

Dart

void main() {
 print('Hello world!');
}
Enter fullscreen mode Exit fullscreen mode

Dart, widely used for creating mobile and web applications, allows us to create a "Hello world!" program using the print function within the main function.

Top comments (0)