C — Hello World
The classic hello-world in C — an include, main, and printf — for testing highlighters, C compilers, and parsers against the canonical first program.
The source-code category is a syntax-highlighting, linting, and parser fixture set: one idiomatic hello-world plus one realistic snippet in each of sixteen languages, all original and documented. HTML, CSS, JavaScript, and TypeScript (shipped as .mts to sidestep the MPEG-TS .ts collision) cover the web front-end; Python, Ruby, PHP, and Shell the scripting side; Java, Kotlin, Swift, Go, and Rust the application languages; C and C++ the systems layer; and SQL the database. Each hello-world is the minimal correct program for that language, and each snippet exercises the constructs a highlighter or parser actually has to get right — comments and doc-comments, string escapes and interpolation, numeric literals, functions, classes or structs, generics, enums, pattern matching, and error handling. Everything opens in the in-browser editor, previews inline as text, and is free to copy. Use these to test syntax highlighters, tree-sitter and language grammars, linters and formatters, code editors, diff viewers, and language detection — against short, known-correct source rather than a scraped repository.
The classic hello-world in C — an include, main, and printf — for testing highlighters, C compilers, and parsers against the canonical first program.
A realistic C program: a singly linked list with a typedef struct, malloc/free memory management, pointer walking, and error handling — for testing highlighters, compilers, and static analysers.
The classic hello-world in C++ — iostream and std::cout — for testing highlighters, C++ compilers, and parsers.
A realistic C++ snippet with a class template, STL algorithms (max_element, accumulate), std::move, and range handling — for testing highlighters, g++/clang++, and parsers against real templates.
A realistic component stylesheet using custom properties, flexbox, a fluid clamp() font size, color-mix(), a keyframe animation, and a media query — for testing CSS parsers, linters (stylelint), and highlighters.
A minimal stylesheet that centres a heading with grid — the simplest useful CSS file for testing highlighters, CSS parsers, and minifiers.
The classic hello-world in Go — package main, an import, and fmt.Println, tab-indented like gofmt — for testing highlighters, the Go compiler, and parsers.
A realistic Go program: a worker pool with structs and methods, goroutines, buffered channels, and a sync.WaitGroup — tab-indented like gofmt, for testing highlighters, go vet, and parsers.
A minimal, valid HTML5 document — doctype, head, and a single heading — for testing HTML parsers, highlighters, and validators against the simplest well-formed page.
A realistic semantic HTML page with landmark elements (header, nav, main, article, footer), a figure with alt text and caption, and lists — for testing HTML parsers, accessibility tooling, and highlighters.
A realistic Java class with a package declaration, fields, a nested record, methods that throw exceptions, and formatted output — for testing highlighters, javac, Checkstyle, and parsers.
The classic hello-world in Java — a public class with the standard main method — for testing highlighters, javac, and Java parsers.
The classic hello-world in modern JavaScript — a minimal function calling console.log, for testing highlighters, Node, and JS parsers.
A realistic JavaScript snippet with an ES class, private #fields, arrow functions, template literals, a getter, and async/await — for testing highlighters, ESLint, Prettier, and bundlers.
The classic hello-world in Kotlin — a top-level main function — for testing highlighters, the Kotlin compiler, and parsers.
A realistic Kotlin snippet with data classes, an enum, a sealed result interface, extension functions, and when expressions — for testing highlighters, the Kotlin compiler, ktlint, and parsers.
The classic hello-world in PHP — an opening tag and echo — for testing highlighters, the PHP interpreter, and parsers.
A realistic modern-PHP snippet with strict types, a namespace, a backed enum, a final class with constructor-promoted readonly properties, and array_reduce with an arrow function — for testing highlighters, PHPStan, and parsers.
A realistic Python snippet exercising type hints, an lru_cache-memoised recursive function, a generator, and a frozen dataclass — for testing syntax highlighters, linters (ruff/flake8), and formatters (black).
The classic hello-world in idiomatic Python 3, with a shebang, a module docstring, and the standard main guard — the minimal correct program for testing highlighters and interpreters.
The classic hello-world in Ruby — a single puts — for testing highlighters, the Ruby interpreter, and parsers.
A realistic Ruby snippet: a Stack class that mixes in Enumerable, yields blocks, raises a custom error class, and uses string interpolation and symbol-to-proc — for testing highlighters, RuboCop, and parsers.
The classic hello-world in Rust — fn main and the println! macro — for testing highlighters, rustc, and parsers.
A realistic Rust snippet with an enum carrying data, a trait and impl, exhaustive match, iterators, and Option handling — for testing highlighters, rustc, clippy, and parsers against real ownership-era code.
A realistic Bash script using strict mode (set -euo pipefail), functions, default parameters, a loop, and conditionals — an illustrative fixture (review before running) for testing highlighters, ShellCheck, and shfmt.
The classic hello-world in Bash — a shebang and echo, with LF line endings so it runs on Unix — for testing highlighters, ShellCheck, and shell parsers.
The classic first query in SQL — a single SELECT of a literal — for testing highlighters, SQL parsers, and query editors.
A realistic SQL script with CREATE TABLE constraints and foreign keys, INSERT seed data, a CREATE VIEW, and a grouped aggregate query with a join — for testing SQL parsers, formatters, and highlighters.
The classic hello-world in Swift — a single print — for testing highlighters, the Swift compiler, and parsers.
A realistic Swift snippet with an enum, a protocol, a struct with a computed property, optionals and optional binding, and higher-order functions — for testing highlighters, the Swift compiler, SwiftLint, and parsers.
The classic hello-world in TypeScript (shipped as .mts to avoid the MPEG-TS .ts collision) — a typed function for testing TypeScript-aware highlighters and the tsc compiler.
A realistic TypeScript snippet with an enum, a discriminated union, generics, exhaustive switch handling, and a typed reduce — for testing the type checker, highlighters, and the TS ESLint parser.
We use Google Analytics. It sets no analytics cookies until you allow the Analytics category below. See our cookie policy.