michalspano / hello-word-and-beyond

Discover the legendary 'Hello world!' program in handful amount of programming languages compiled and executed on any Unix shell.
https://michalspano.github.io/hello-word-and-beyond/
0 stars 0 forks source link
c helloworld-programs language learning-by-doing programming-language

Hello world!

A "Hello, World!" program generally is a computer program that outputs or displays the message "Hello, World!". Such a program is very simple in most programming languages, and is often used to illustrate the basic syntax of a programming language. It is often the first program written by people learning to code. [1]

This list contains programs along with instructions for Unix Shell environment.

  1. Ada
  2. C
  3. C#
  4. C++
  5. Dart
  6. F#
  7. Go
  8. Haskell
  9. JavaScript
  10. Kotlin
  11. Objective-C
  12. Perl
  13. Python
  14. R
  15. Ruby
  16. Rust
  17. Scala
  18. Shell
  19. Swift
  20. Visual Basic

Ada

with Text_IO; use Text_IO;

procedure hello is
begin
   Put_Line("Hello world!");
end hello;
$ gnatmake hello-world.adb
$ ./hello-world

C

#include <stdio.h>

int main(void)
{
    printf("Hello world!\n");
    return 0;
}
$ make hello-world
$ ./hello-world

C

using System;

class Pogram
{
    static void Main(string[] argv)
    {
        Console.WriteLine("Hello world!");    
    }
}
$ csc hello-world.cs
$ mono hello-world.exe

C++

#include <iostream>

int main(void)
{
    std::cout << "Hello world\n";
    return 0;
}
$ g++ -o hello-world hello-world.cpp
$ ./hello-world

Dart

void main()
{
    print("Hello world!");
}
$ dart hello-world.dart

F

open System

[<EntryPoint>]
let main argv =
    printfn "Hello world!"
    0 
$ fsharpc hello-world.fs
$ mono hello-world.exe

Go

package main

import "fmt"

func main()
{
    fmt.Println("Hello world!")
}
$ go run hello-world.go

Haskell

main :: IO ()
main = do
    putStrLn "Hello world!"
    return ()
$ ghc hello-world.hs
./hello-world

Java

public class Main 
{
    public static void main(String[] args)
    {
        System.out.println("Hello world!");
    }
}
$ javac hello-world.java
$ java hello-world

JavaScript

console.log("Hello world!");
$ node hello-world.js

Kotlin

fun main()
{
    println("Hello world!")
}
$ kotlinc hello-world.kt -include-runtime -d hello-world.jar
$ java -jar hello-world.jar

Objective-C

#import <Foundation/Foundation.h>

int main(void) 
{
    NSLog(@"Hello world!");
    return 0;
}
$ clang -framework Foundation hello-world.m -o hello-world
$ ./hello-world

Perl

#!usr/bin/perl

use warnings;

print("Hello world!\n");
$ perl hello-world.pl

Python

print('Hello world!')
$ python3 hello-world.py

R

print("Hello world!", quote=False)
$ chmod +x hello-world.r
./hello-world.r

Ruby

puts "Hello world!"
$ ruby hello-world.rb

Rust

fn main()
{
    println!("Hello world!");
}
$ rustc hello-world.rs
$  ./hello-world

Scala

object Main {
  def main(args: Array[String]): Unit = {
    println("Hello world!")
  }
}
scala hello-world.scala

Shell

echo "Hello world!"
$ sh hello-world.sh

Swift

print("Hello world!")
$ swift hello-world.swift

Visual Basic

Imports System

Module HelloWorld
    Sub Main()
        Console.WriteLine("Hello world!")
    End Sub 
End Module
$ vbc hello-world.vb
$ mono hello-world.exe

Assembly

global    start
    section   .text
start:
    mov       rax, 0x02000004
    mov       rdi, 1
    mov       rsi, message
    mov       rdx, 13
    syscall
    mov       rax, 0x02000001
    xor       rdi, rdi
    syscall 
    section   .data
message:  
    db        "Hello world!", 10
$ ./hello-world