Skip to content

brendanjbaker/Languages

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

398 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Summary

This repository contains examples of 100+ programming languages.

Besides just showing example programs, the programs are runnable in a reproducible manner via Dockerfiles. Additionally, the programs are unit tested to ensure they indeed produce the expected output(s).

Contents

Technical background

Podman is used to build and execute a multi-layer image.

Layer Name Description
1 base Debian 13 (Trixie), Systemd, Snap, common apt packages.
2 system Things shared between all languages (entry point, tests...).
3 language Things shared within a language (language-specific setup...)
4 program The specific program for the language.

This provides the following (for example):

  • Changing a unit test (system layer) does not require re-installing apt packages (base layer).
  • Changing a language setup script (language layer) does not require rebuilding the base or system layers.
  • Changing a program does not require rebuilding any other layer (base, system, or language).

Help

$ ./languages.sh --help
languages.sh 0.0.0.0

Usage:
  languages.sh [options] <command>

Options:
  --configure         Install needed dependencies, etc.
  --debug             Debug everything.
  --debug-container   Debug container building, etc.
  --debug-program     Debug program execution.
  --debug-setup       Debug language setup script.
  --help              Show this help message.
  --interactive       Begin an interaction session.
  --parallel          Runs multiple programs concurrently.
  --prime             Pre-generates image(s) without running them.
  --reverse           Runs programs in reverse order.
  --test              Run unit tests.
  --version           Show version information.

Commands:
  clean                      Remove stored images and containers.
  list                       List languages and their programs.
  run                        Run all languages and programs.
  run <LANGUAGE>             Run all programs for a language.
  run <LANGUAGE> <PROGRAM>   Run a specific language's program.

Usage examples

  • List available languages and programs:
    • ./languages.sh list
  • Run everything:
    • ./languages.sh run
  • Run all C# programs:
    • ./languages.sh run csharp
  • Run the C# hello program:
    • ./languages.sh run csharp hello
  • Debug the C# hello program:
    • ./languages.sh --debug run csharp hello
  • Enter interactive mode for C#, with the hello program loaded:
    • ./languages.sh --interactive csharp hello
  • Run tests for Rust (all programs):
    • ./languages.sh --test run rust
  • Help/usage:
    • ./languages.sh --help
  • Version:
    • ./languages.sh --version

Programs

hello

This program should print Hello, world!, with a trailing newline, and exit with status 0.

sum

This program should print the sum of 0-100 (inclusive), which is 5050, with a trailing newline, and exit with status 0.

microwave

This program converts a string, as may be typed into a simple microwave, into MM:SS format, with a trailing newline.

The input must be passed as a single positional argument to the program. Any other usage is an error.

A usage error should exit with status 1. An invalid argument should exit with status 2.

Correct behavior is based on the Whirlpool WMH31017HZ-2 (my kitchen microwave). This is a common kitchen microwave that is customarily installed above a range/stove. I have observed that other microwaves have varying behavior for strange inputs, such as 161 or 9999. I chose this microwave as my source of truth merely because I have easy access to it.

Do not run a microwave without something in it to absorb the magnetron's radiation, or your microwave may damage itself. I used a large bowl of water to test behavior for inputs such as 9999.

Valid input examples

000000:00 6001:00 96010:00 995999:59
00000:00 6101:01 96110:01 996099:60
0000:00 9001:30 99910:39 996199:61
000:00 9901:39 100010:00 999999:99
100:01 10001:00 100110:01
5900:59 10101:01
15901:59
16002:00
16102:01
19902:39
20002:00
20102:01
95909:59

Invalid input examples

  • Empty string
  • x
  • xxxx
  • -1
  • 12345

freestyle

These programs are intended to demonstrate unique or interesting language features.

Test requirements are loose:

  • There must be standard output (stdout).
  • There must not be error output (stderr).
  • Exit status must be 0.

Checklist

Language hello sum microwave freestyle
Ada
Algol ✅️
APL ✅️ ✅️
Arturo
Assembly (GNU)
Assembly (Microsoft)
Assembly (Netwide)
Awk
B
B4X
Ballerina
Bash
BASIC¹
Batch
BCPL
Beanshell
Beef
Brainf#ck
C
C#
C++
C2
C3
Caml
Carbon
Chapel
ChucK
Clojure
CLU
COBOL
Cobra
CoffeeScript
ColdFusion
Cowgol
Crystal
Csound
CSS¹ ⚠️ ⚠️
Cwerg
D
Dart
Daslang
dBase
Delphi
E
Eiffel
Elixir
Elm
Emacs Lisp
Erlang
Extempore
F#
Factor
Fifth
Forth
Fortran
FoxPro
Futhark ⚠️
G-Portugol
Gambas
GAMS
GAP
GDScript
Gleam ✅️ ✅️
Glim
Go ✅️
Groovy ✅️
Gurgle
Hack
Hare
Haskell
Haxe
Hopper
HTML¹ ⚠️ ⚠️ ⚠️
HyperTalk
Icon
Inform
Ink
Io
Irdis
Isabelle¹
J
J#
Jai
Java
JavaScript
Joule
Joy¹
JS++
JScript
Jtw
Julia
Koka
Kotlin
LabVIEW
Ladder Logic
Less¹
Lily (A)
Lily (B)
Lisp
Lobster
Logo
Lua
Maple
MATLAB
Maxima
Modelica
Modula
Modula-2
Modula-3
Mojo
NATURAL
Nemerle
Never
Newspeak
Nial
Nim
Nit
Nix
NXT-G
Oak
Oberon
Object Pascal
Objective-C
Oblique
OCaml
Odin
Opa
OpenCL
Par
Pascal
Perl
Phix
PHL
PHP
Pike
PL/I
PL/M¹
PL/SQL
Planner
Pony
POP-11
PostScript
PowerShell
Project Verona
Prolog
Pure
Python
Q
R
Racket
Raku
Rebol
Red
Rexx
Ring
Roc
RPG (IV)
RPL
Ruby
Rust
SAS
Sass¹
Sather
Scala
Scheme
Scratch
Sed
Seed7
Self
Simula
Smalltalk
Solidity
Sonic Pi
SPARK
Spin (Parallax)
SQL¹
Squeak
Squirrel
Standard ML¹
SuperCollider
Stata
Storm
Structured Text
Swift
Tampio¹
Tcl
Tern
Toi
Transact-SQL
Typescript
Unicon
V
Vala
Vale
VBScript
Verilog
VHDL
Visual Basic .NET
Visual Basic (6)
Wenyan (文言)
Whiley
Wolfram
Wren
X10
Xojo
Xtend
Zig
Count... 133 130 11 4

Legend

Symbol Meaning
Completed
⚠️ Unimplementable
Failing
Unimplemented
¹ "Cheating" required.

Cheating

Some programs require "cheating" to express output and/or pass tests.

See the cheating page for additional information.

About

Demonstrations of 100+ programming languages.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published