Start programming with Go/Golang / Hello World!

Hello World!

"Hello, World!" is often the first program written by new programmers when learning a language. It's a simple program that displays the text "Hello, World!" on the screen. This program has become a tradition in computer programming, marking the start of one's journey in learning a new language or exploring programming for the first time.

The Origin of "Hello, World!"

The tradition of "Hello, World!" dates back to the 1970s. It was popularized by Brian Kernighan in the book "The C Programming Language," co-authored with Dennis Ritchie, the creator of C. The program was used as an example to demonstrate the basic syntax of the C language, and since then, it has become a universally recognized example in programming education.

Why Start with "Hello, World"?

"Hello, World!" is simple, but it serves several important purposes for beginner programmers:

  • Familiarization: It helps learners become familiar with the basic structure of a program in any language, from defining a function to outputting text.
  • Immediate Feedback: It provides quick feedback—if the program runs and displays the correct message, the learner knows that the setup is correct and the code works.
  • Build Confidence: Successfully running a "Hello, World!" program gives beginners a sense of accomplishment, motivating them to explore more complex concepts.
  • Standard Starting Point: Since almost every language has an example of a "Hello, World!" program, it’s an easy way to compare different languages.

Examples of "Hello, World!" in Various Programming Languages

Let’s take a look at how the "Hello, World!" program looks in several popular programming languages.

1. Go (Golang)

package main

import "fmt"

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

2. Python

print("Hello, World!")

3. JavaScript (Browser Console)

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

4. C

#include <stdio.h>

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

5. Java

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

Running Your First "Hello, World!" Program

Let’s say you want to run your first "Hello, World!" program in Go. Here’s how you can do it:

Step 1: Install Go

If you don’t have Go installed, head over to the Go Downloads page and install it on your system. Once installed, verify the installation by running:

go version

Step 2: Create Your First Go Program

Create a new file named main.go and add the following code:

package main

import "fmt"

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

Step 3: Run the Program

In your terminal, navigate to the directory containing main.go and run:

go run main.go

You should see the output:

Hello, World!

Expanding Beyond "Hello, World!"

Once you’ve successfully run "Hello, World!" programs in a language, the next step is to explore more complex concepts like variables, control structures, functions, and data structures. "Hello, World!" is just the beginning, and from here, the possibilities are endless.

Conclusion

The "Hello, World!" program is more than just a piece of tradition. It’s a symbol of new beginnings for programmers across the world. While it may seem simple, it serves as the first step in a much larger learning process that leads to mastering programming languages and solving real-world problems through code.