Home Hello World!
Post
Cancel

Hello World!

  • This is the testing post I put for my blog website.
  • I will use several programming languages to write everyone’s first program Hello World.
  • Also, I will put the console command that compiles/runs the source code for different languages.

C

Code

1
2
3
4
5
6
#include <stdio.h>

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

Compile/Run

1
2
3
$ gcc -o helloWorld.c helloWorld
$ ./helloWorld
Hello World!

C++

Code

1
2
3
4
5
6
#include <iostream>

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

Compile/Run

1
2
3
$ g++ -o helloWorld.cpp helloWorld
$ ./helloWorld
Hello World!

Python

Code

1
print('Hello World!')

Compile/Run

1
2
$ python3 helloWorld.py
Hello World!

Javascript

Code

1
console.log("Hello World!")

or

1
window.alert("Hello World!")

Compile/Run

Here we use the console in f12 debugger from browser.

1
2
$ console.log("Hello World!")
Hello World!

Java

Code

1
2
3
4
5
public class HelloWorld{
    public static void main(String[] args){
        System.out.println("Hello World!");
    }
}

Compile/Run

1
2
3
$ javac HelloWorld.java
$ java HelloWorld
Hello World!

VB.NET

Code

1
2
3
4
5
6
7
Imports System
Module HelloWorld 
   Sub Main()
      Console.WriteLine("Hello World!")
      Console.ReadKey()
   End Sub
End Module

Compile/Run

1
2
$ vbc HelloWorld.vb
Hello World!

Haskell

Code

1
2
3
main :: IO() 
main = do 
   print ("Hello World!")

Compile/Run

1
2
3
$ ghc -o HelloWorld HelloWorld.hs
$ ./HelloWorld
"Hello World!"

or

1
2
3
$ ghci
Prelude> print ("Hello World!")
Hello World!

Prolog

Code

1
2
main :- 
    write('This is sample Prolog program').

Compile/Run

Here we are using swipl to interpret prolog file

1
2
3
4
5
$ swipl
?- [HelloWorld]
?- main.
Hello World!
true.

Erlang

Code

1
2
3
4
5
-module(helloworld).
-export([start/0]).

start() ->
    io:fwrite("Hello, World!~n").

Compile/Run

1
2
3
4
5
6
$ erl
1> c(helloworld).
{ok,helloworld}
2> helloworld:start().
Hello, World!
ok
This post is licensed under CC BY 4.0 by the author.

-

Getting started with Git