On this page
Every new space starts somewhere. This one starts with two familiar words: Hello, world.
This article is a reading and rendering sample. It brings together small programs, public tutorial examples, and the ordinary details of a Markdown page.
A first program#
The simplest Rust program needs a function and something to say. This example comes from The Rust Programming Language.
fn main() {
println!("Hello, world!");
}
Save it as main.rs, compile it, and run the result:
rustc main.rs
./main
Hello, world!
The same greeting, different languages#
Python#
def greet(name: str) -> str:
return f"Hello, !"
print(greet("world"))
JavaScript#
function greet(name) {
return `Hello, !`;
}
console.log(greet("world"));
C#
#include <stdio.h>
int main(void) {
printf("Hello, world!\n");
return 0;
}
Bash#
printf '%s\n' 'Hello, world!'
Zig#
const std = @import("std");
pub fn main() void {
std.debug.print("Hello, world!\n", .{});
}
Java#
public class Main {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
C++#
#include <iostream>
int main() {
std::cout << "Hello, world!\n";
return 0;
}
Assembly#
This example uses GNU assembler Intel syntax on x86-64 Linux.
.intel_syntax noprefix
.section .rodata
message:
.ascii "Hello, world!\n"
.section .text
.global _start
_start:
mov eax, 1
mov edi, 1
lea rsi, [rip + message]
mov edx, 14
syscall
mov eax, 60
xor edi, edi
syscall
A little more than hello#
The Python tutorial uses the Fibonacci sequence to introduce assignment and loops. The following short adaptation keeps the state visible and the output easy to check. Python documentation examples are available under the Zero Clause BSD license.
current, following = 0, 1
while current < 10:
print(current)
current, following = following, current + following
The greeting function below is adapted from the MDN JavaScript introduction. It writes to the console so the example does not need a dialog.
function greetMe(yourName) {
console.log(`Hello `);
}
greetMe("World");
Reading details#
A sentence can contain emphasis, a quieter aside, an old idea, and
inline code. A link should remain easy to recognize without taking attention
away from the words around it.
A short quotation gives a paragraph room to breathe.
This is sample text written for this page.
A small table#
| Language | Entry point | Greeting |
|---|---|---|
| Rust | fn main() | println! |
| Python | Module execution | print |
| JavaScript | Script execution | console.log |
| C | int main(void) | printf |
| Bash | Script execution | printf |
| Zig | pub fn main() | std.debug.print |
| Java | public static void main | System.out.println |
| C++ | int main() | std::cout |
| Assembly | _start | Linux write syscall |
Lists and tasks#
- Read the example.
- Copy the code.
- Run it in a suitable local environment.
-
Keep functions small.
-
Give values useful names.
- Let indentation show the structure.
- Explain a decision when a comment helps.
-
A first article
-
Examples in several languages
-
More things to write
A long line#
The following line is deliberately long. It should scroll inside its code block while the article remains within the page width.
Hello, world! This deliberately long line keeps going so that horizontal scrolling can be checked on a narrow screen without stretching the article, moving the page edges, or reducing the code font size.
Plain text#
An unfamiliar language label should still produce a readable block.
hello -> world
Mathematics#
Mathematics can sit inside a sentence, such as
Matrices and aligned equations#
A small macro#
Definitions can shorten a formula while keeping its meaning explicit:
The source stays literal in code: $E = mc^2$. An ordinary dollar sign is escaped:
$25. A display formula that is wider than the screen scrolls within the article.
Words beyond English#
Hello, world. 你好,世界。こんにちは、世界。안녕하세요, 세계. Bonjour, le monde.
مرحبًا بالعالم.
Accented letters and combining marks belong in the same reading experience: café, naïve, résumé, café. A small wave belongs here too: 👋.
One last detail#
Footnotes can carry an aside without interrupting a paragraph.1 The headings on this page also provide direct links for the table of contents.
This footnote is part of the Markdown rendering sample.
That is enough for a beginning. Hello, world.