A “Hello, World!” program is a computer program that outputs “Hello, World!” on a display device. It is typically one of the simplest programs possible in almost all computer languages. As such it can be used to quickly compare syntax differences between various programming languages.
Assembler
global _main extern _puts section .text _main: push rbx ; Call stack must be aligned lea rdi, [rel message] ; First argument is address of message call _puts ; puts(message) pop rbx ; Fix up stack before returning ret section .data message: db "Hello World!", 0 ; C strings need a zero byte at the end
C++ language:
#include <iostream> // IO stream library // Body of the program int main() { // Send "Hello World!" to output with end line std::cout << "Hello World!" << std::endl; return 0; }
COBOL:
HELLO IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. PROCEDURE DIVISION. DISPLAY "Hello World!". STOP RUN.
Erlang:
%%%------------------------------------------------------------------- %%% @author fearless %%% @copyright (C) 2020, FEARLESS SPIDER %%% @doc %%% %%% @end %%% Created : 06. gru 2020 7:13 PM %%%------------------------------------------------------------------- -module(hello_world). -author("fearless"). %% API -export([hello_world/0]). hello_world() -> io:fwrite("Hello World!\n").
Go
package main import "fmt" func main() { fmt.Println("Hello World!") }
Java
class HelloWorld { public static void main(String args[]) { System.out.println("Hello World!"); } }
Perl
#!/usr/bin/perl # Modules used use strict; use warnings; # Print function print("Hello World!\n")
Python
if __name__ == '__main__': print("Hello World!")
Ruby
puts "Hello World!"
Swift
print("Hello World!")
All “Hello, World!” programs are here https://github.com/fearless-spider/spider-zine/tree/master/hello_world