Hello world!

Hello World!

Printing hello world is a time honored tradition of developer.  Allegedly, the tradition was introduced in 1978 as an example in the book The C Programming Language, by Dennis Ritchie and Brian Kernighan. Here is hello world in a few different languages.

C

#include<stdio.h>
main()
{
printf("Hello World");
}

 

JavaScript

console.log('Hello World!')

Note: If you are using node, you can run your hellWorld.js script from the command line like so:

$node helloWorld.js

PHP

<?php
print 'Hello World!'
//or
echo 'Hello World!'
?>

Python

print 'Hello World!'

Java

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

c++

#include <iostream>
int main()
{
std::cout << "Hello, world!\n";
}

NASM (Assembly)

; ----------------------------------------------------------------------------------------
;Source: http://cs.lmu.edu/~ray/notes/x86assembly/
;Writes "Hello, World" to the console using only system calls. Runs on 64-bit Linux only.
; To assemble and run:
;
; nasm -felf64 hello.asm && ld hello.o && ./a.out
; ----------------------------------------------------------------------------------------
global _start
section .text
_start:
; write(1, message, 13)
mov rax, 1 ; system call 1 is write
mov rdi, 1 ; file handle 1 is stdout
mov rsi, message ; address of string to output
mov rdx, 13 ; number of bytes
syscall ; invoke operating system to do the write
; exit(0)
mov eax, 60 ; system call 60 is exit
xor rdi, rdi ; exit code 0
syscall ; invoke operating system to exit
message:
db "Hello, World", 10 ; note the newline at the end