EN ES
Home > Web development > How to Create Your First "Hello World" Program in Several Programming Languages

How to Create Your First "Hello World" Program in Several Programming Languages

Diego Cortés
Diego Cortés
September 30, 2024
How to Create Your First "Hello World" Program in Several Programming Languages

Creating a "Hello World" program is one of the first tasks programming students undertake. This simple exercise helps familiarize beginners with the basic structure of a program in a specific language. In this article, you will learn how to create your first "Hello World" program using several popular programming languages.

What is the "Hello World" Program?

The "Hello World" program is a standard example used to illustrate the minimum syntax of a programming language. Typically, the program prints "Hello World" to the console or standard output. Below, we will explore how to accomplish this task in different programming languages.

Featured Programming Languages

1. Python

Python is a high-level language known for its simplicity and readability.

print("Hello World")

To run this program, you can use any integrated development environment (IDE) or simply the terminal if you have Python installed.

2. Java

Java is a widely used language in desktop and mobile application development.

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

To compile and run this program, save the code in a file named HelloWorld.java and use these commands in the terminal:

javac HelloWorld.java
java HelloWorld

3. JavaScript

JavaScript is the primary programming language for the web.

console.log("Hello World");

You can run this code in your browser console or in a Node.js environment.

4. C

C is a general-purpose programming language widely used in operating systems and embedded applications.

#include <stdio.h>

int main() {
    printf("Hello World\n");
    return 0;
}

To compile and run the program, save the code in a file named hello_world.c and use the following commands:

gcc hello_world.c -o hello_world
./hello_world

5. C++

C++ is a language derived from C, known for its use in high-performance software development.

#include <iostream>

int main() {
    std::cout << "Hello World" << std::endl;
    return 0;
}

Similar to the C program, compile and run using:

g++ hello_world.cpp -o hello_world
./hello_world

6. Ruby

Ruby is a programming language focused on simplicity and productivity.

puts "Hello World"

Run this code in any terminal with Ruby installed:

ruby hello_world.rb

7. PHP

PHP is a programming language primarily used in web development.

<?php
echo "Hello World";
?>

Save the code in a file named hello_world.php and run it from the command line or on a web server.

php hello_world.php

8. Swift

Swift is the programming language used to develop applications on Apple platforms.

print("Hello World")

You can run this code in an Xcode development environment or in the terminal if you have Swift installed.

9. Go

Go is a programming language created by Google that emphasizes simplicity and efficiency.

package main

import "fmt"

func main() {
    fmt.Println("Hello World")
}

Compile and run the program from the command line:

go run hello_world.go

Conclusion

Creating a "Hello World" program is an excellent first step in getting started with programming. Through this article, you have learned how to implement this simple program in different programming languages. Each language has its own syntax and style, but the goal remains the same.

Now that you have taken your first steps, it’s time to explore more and keep learning!

Diego Cortés
Diego Cortés
Full Stack Developer, SEO Specialist with Expertise in Laravel & Vue.js and 3D Generalist

Categories

Page loaded in 30.07 ms