In this project, we implement the FizzBuzz game with 50+ programming languages.
- 『プログラミング言語大全』(Encyclopedia of Programming Languages) by kujirahand.com
For each programming language, this project includes
-
How to install the compiler or the interpreter for the language (see Setup Development Environments).
-
How to use such tools (see Setup Development Environments).
-
How to comment out string in the language (see the first line of the source code).
-
How to implement the FizzBuzz game (see the source code). For a limited number of difficult languages (e.g. Assembly), we only implemented Hello World.
Unless otherwise, we use Arch Linux.
Hereafter, we define the function aur()
as follows.
function aur() {
if [[ $# == 0 || $1 == "-h" || $1 == "--help" ]]; then
echo "Usage: aur <AUR package name>"
return 0
fi
git clone "https://aur.archlinux.org/${1}.git"
}
And we execute the following command.
mkdir ~/Build
-
Read Setup Development Environments and setup the development environment for the language.
-
cd ./093_Some_Language
-
bash yrun.sh
This section is for contributors of this project.
-
mkdir 093_Some_Language
-
cd 093_Some_Language
-
cp ../yrun.sh .
-
echo 'some_language_interpreter --run "${source}.some_extension"' >> yrun.sh
(The variablesource
is by default defined asfizzbuzz
in../yrun_template.sh
, which is sourced fromyrun.sh
. You do not have to define it.) -
Put the source code
fizzbuzz.some_extension
here. -
bash yrun.sh > x && vimdiff x ../correct_output.txt
to check the result is correct. -
Confirm
fizzbuzz.some_extension
starts with a comment line (e.g.# This is a comment.
).
gcc <source>.c -o <source>.out
./<source>.out
Installation: sudo pacman -S gcc
go run <source>.go
Installation: sudo pacman -S go
nasm -felf64 <source>.asm
ld <source>.o -o <source>.out
./<source>.out
Installation: sudo pacman -S nasm
g++ <source>.cpp -o <source>.out
./<source>.out
Installation: sudo pacman -S gcc
gfortran <source>.f90 -o <source>.out
./<source>.out
Installation: sudo pacman -S gcc-fortran
dmd <source>.d -of=<source>.out
./<source>.out
Installation: sudo pacman -S dlang-dmd
rustc --allow unused_parens <source>.rs -o <source>.out
./<source>.out
Installation: sudo pacman -S rust
python3 <source>.py
Installation: sudo pacman -S python
ruby <source>.rb
Installation: sudo pacman -S ruby
crystal <source>.cr
Installation: sudo pacman -S crystal
php <source>.php
Installation: sudo pacman -S php
Additional Notes
You can embed PHP codes into HTML and serve it by parsing the PHP part server-side. For Apache, read Apache HTTP Server - ArchWiki and open ./011_PHP_02.php
.
lua <source>.lua
Installation: sudo pacman -S lua
Only a compiler for Windows is supplied. However, you can use the official online compiler: MoonScript Online Compiler
perl <script>.pl
Installation: sudo pacman -S perl
rakudo <source>.p6
Installation
cd ~/Build
aur moarvm
cd moarvm/
makepkg -sir
cd ~/Build
aur nqp
cd nqp/
makepkg -sir
cd ~/Build
aur rakudo
cd rakudo/
makepkg -sir
node <source>.js
Installation: sudo pacman -S nodejs
tsc <source>.ts
node <source>.js
Installation: sudo pacman -S typescript
coffee <source>.coffee
Installation: sudo pacman -S coffeescript
dart <source>.dart
Installation: sudo pacman -S dart
/usr/lib/emscripten/emcc <source>.cpp -s WASM=1 -o <source>.html
This command outputs <source>.html
, <source>.js
and <source>.wasm
. They shall be served via a HTTP server. See Compiling a New C/C++ Module to WebAssembly - MDN for the detail.
Installation: sudo pacman -S emscripten
/usr/lib/jvm/java-14-openjdk/bin/javac <source>.java
/usr/lib/jvm/java-14-openjdk/bin/java <source>
Installation: sudo pacman -S jdk-openjdk
vim -c 'source <source>.exscript'
Installation: sudo pacman -S gvim
kotlinc <source>.kt
kotlin _<source>
Installation: sudo pacman -S kotlin
scala <source>.scala
Installation: sudo pacman -S scala
export JAVA_HOME=/usr/lib/jvm/java-14-openjdk
groovy <source>.groovy
Installation: sudo pacman -S groovy
cd <source> #The source code `<source>.pde` shall exist here.
processing-java --sketch="${PWD}" --run
Installation: sudo pacman -S processing
swift <source>.swift
Installation
cd ~/Build
aur swift-bin
cd swift-bin/
makepkg -sir
gcc -std=gnu11 -lgnustep-base -lobjc <source>.m -o <source>.out
./<source>.out
Installation: sudo pacman -S gcc-objc gnustep-base
csc <source>.cs
chmod a+x <source>.exe
./<source>.exe
or
csc <source>.cs
mono <source>.exe
Installation: sudo pacman -S dotnet-sdk
dotnet fsi <source>.fsx
Installation: sudo pacman -S dotnet-sdk
vbc <source>.vb
chmod a+x <source>.exe
./<source>.exe
or
csc <source>.vb
mono <source>.exe
Installation
sudo pacman -S dotnet-sdk
cd ~/Build
aur mono-basic
cd mono-basic/
makepkg -sir
In this section, we assume you are using Windows and Excel 2016.
-
Open
Excel
. -
View
>Macros
>View Macros
-
Type a macro name you want.
-
Click
Create
. -
Write your code.
-
Type F5.
-
Click
Run
.
mkdir <project directory>
cd <project directory>
clasp create --type standalone --title <project title>
vi <source>.js
clasp push
script_id=$(sed 's/.*:"//; s/"}//' .clasp.json)
firefox "https://script.google.com/d/${script_id}/edit"
#Click `Run` or type `Ctrl+r` to run the script.
#Click `View` and `Logs` or type `Ctrl+Enter` to view the output.
Although you can run the script from the command-line via clasp run [<function name>]
, the preparations for the command to work are quite complex. See run.md - google/clasp for the detail.
Installation
npm install --global @google/clasp
#Visit https://script.google.com/home/usersettings and enable the Apps Script API.
clasp login
fpc -Mdelphi <source>.pas
./<source>
Installation: sudo pacman -S fpc
fpc <source>.pas
./<source>
Installation: sudo pacman -S fpc
a68g <source>.a68
Installation: sudo pacman -S algol68g
gnatmake <source>.adb
./<source>
Installation: sudo pacman -S gcc-ada
wolfram -script <source>.m
Installation: Consult the official instructions. You can display the activation key in https://user.wolfram.com/portal/myProducts.html.
awk -f <source>.awk
Installation: sudo pacman -S gawk
sed --file=<source>.sed
Installation: sudo pacman -S sed
/opt/microsoft/powershell/7/pwsh <source>.ps1
Installation
cd ~/Build
aur powershell
cd powershell/
makepkg -sir
#Open `cmd.exe` in Windows.
start <source>.bat
bash <source>.sh
Installation: sudo pacman -S bash
#Open `Terminal` in macOS.
osascript <source>.applescript
Installation: Pre-installed.
ghc -dynamic <source>.hs
./<source>
or
runhaskell <source>.hs
Installation: sudo pacman -S ghc
ocaml <source>.ml
Installation: sudo pacman -S ocaml
smlnj < <source>.sml
Installation: sudo pacman -S smlnj
erlc <source>.erl
erl -noshell -s <source> <function name> -s init stop
Installation: sudo pacman -S erlang
elixir <source>.exs
Installation: sudo pacman -S elixir
clisp <source>.lisp
Installation: sudo pacman -S clisp
clojure <source>.clj
Installation: sudo pacman -S clojure
scheme --batch-mode < <source>.scm
Installation: sudo pacman -S mit-scheme
echo | gprolog --consult-file "${source}.prolog" --query-goal <query command>
Installation: sudo pacman -S gprolog
gst <source>.st
Installation: sudo pacman -S smalltalk
fbc -lang deprecated <source>.bas
./<source>
Installation: sudo pacman -S freebasic
cobc -x <source>.cobol
./<source>
Installation: sudo pacman -S gnucobol
cnako3 <source>.nako3
Installation: npm install --global nadesiko3
hspcmp <source>.hsp
hsp3cl <source>.ax
Installation
#Hereafter we use Ubuntu because
#1. Only debian-based distributions are officially supported.
#2. With newer `gcc`, `make` fails since the C++ source codes are written badly.
# See |https://github.com/onitama/OpenHSP/issues/12| for the detail.
# Of course, Arch Linux uses the latest `gcc` by default, which is problematic in this case.
docker run -it ubuntu
set -o vi
apt update
apt install gcc git make vim
git clone "https://github.com/onitama/OpenHSP"
cd OpenHSP/
sed -i 's/sudo //g' setup.sh
./setup.sh
R --no-echo --file=<source>.r
Installation: sudo pacman -S r
julia <source>.jl
Installation: sudo pacman -S julia
octave <source>.m
Installation: sudo pacman -S octave
haxe --run <source>.hx
Installation: sudo pacman -S haxe
nim compile --run <source>.nim
or
nim compile <source>.nim
./<source>
Installation: sudo pacman -S nim
bfc <source>.brainf
mv 'a.out' <source>.out
./<source>.out
Installation
cd ~/Build
aur brainfuck
cd brainfuck
makepkg -sir
gnuplot <source>.gp
Installation: sudo pacman -S gnuplot
bc <source>.bc
Installation: sudo pacman -S bc