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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
main() | |
{ | |
printf("Hello World"); | |
} |
JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('Hello World!') |
Note: If you are using node, you can run your hellWorld.js script from the command line like so:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$node helloWorld.js |
PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
print 'Hello World!' | |
//or | |
echo 'Hello World!' | |
?> |
Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print 'Hello World!' |
Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HelloWorld { | |
public static void main(String[] args) { | |
System.out.println("Hello, World"); | |
} | |
} |
c++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int main() | |
{ | |
std::cout << "Hello, world!\n"; | |
} |
NASM (Assembly)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ---------------------------------------------------------------------------------------- | |
;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 |