たらい回し関数
「たらい回し関数」として知られる 竹内関数 を色々な言語で動かして、完了するまでの時間を測ってみました。
色々な言語で計算速度を比較してみた の記事を読んだことがあり、似たようなことをやってみたいと思ってました。
更新
- 2024/09/11: 今後は その2 を更新していきます。
- 2024/08/26:
- 2024/08/22: Pinecone を追加しました。
- 2024/08/16: LiveScript を追加しました。
- 2024/08/13: Gravity を追加しました。
過去の更新
- 2024/08/12: Draco を追加しました。
- 2024/08/11: Dictu を追加しました。
- 2024/08/10: Clio を追加しました。
- 2024/08/08: ArkScript を追加しました。
- 2024/08/04:
- 2024/07/31: Flix を追加しました。
- 2024/07/27:
- 2024/07/24:
- Poly/ML を追加しました。
- Lisp Flavored Erlang を追加しました。
- 2024/07/22:
- 2024/07/21:
- 2024/07/20:
- 2024/07/19: Crystal を追加しました。1.13.1 に更新しました。
- 2024/07/18:
- 2024/07/17:
- 2024/07/16: Elixir を 1.17.2 に更新しました。
- 2024/07/15:
- 2024/07/14:
- Algol を再測定しました。
- Ada (gnat) を 13.2.0 に更新しました。
- Java を使用する言語を再測定しました。Concurnas を除き、Java 22.0.1 を使用しました。
- Ballerina を 2201.9.2 (Swan Lake Update 9) に更新しました。
- Clojure を再測定しました。
- Concurnas を再測定しました。
- Groovy を再測定しました。
- Haxe を 4.3.3 に更新しました。
- Java を再測定しました。
- Kotlin を再測定しました。
- Scala を再測定しました。
- 2024/07/13: 言語の名称で並べ替えました。
- 2024/07/11: D (gdc) を 13.2.0 に、D (ldc) を 1.36.0 に更新しました。
- 2024/07/10: V を 0.4.6 66ea826 に更新しました。
- 2024/07/09: Pascal を 3.2.2+dfsg-32 に更新しました。
- 2024/07/08: C# (dotnet)、F# (dotnet) を 8.0.302 に更新しました。
- 2024/07/07: Groovy を 4.0.22 に更新しました。
- 2024/07/06: Javascript node.js を 22.4.0 に、deno を 1.44.4 に、bun を 1.1.18 に更新しました。
- Fortran を 13.2.0 に更新しました。
- 2024/07/05: OS を Ubuntu Server 24.04 LTS (64-bit) にしました。
- Go を 1.22.5 に更新しました。
- C を gcc 13.2.0, clang 18.1.3 に更新しました。
- C++ を g++ 13.2.0, clang++ 18.1.3 に更新しました。
- Julia を 1.10.4 に更新しました。
- 2024/07/01: Javascript (bun) を追加しました。
- 2024/06/29: Concurnas を追加しました。
- 2024/06/16: Dart を 3.4.4 にバージョンアップしました。
- 2024/06/15: Go を 1.22.4 に、Rust を 1.79.0 にバージョンアップしました。
- 2024/06/14: Zig を 0.13.0 にバージョンアップしました。
- 2024/06/14: Erlang を除き、全ての言語の経過時間測定を
\time
での計測に切り替えました。測定時に言語のバージョンアップを行っています。- 過去の表を削除しました。
- 2024/05/22: Ante と Gleam を追加しました。
- 2024/05/21:
\time
での測定に切り替え、グラフにまとめました。 - 2024/05/14: Ballerina を追加しました。
- 2024/05/13: Sidef を追加しました。
- 2024/05/10: Swift を追加しました。
- 2024/05/09: 長すぎるので、まとめ方を変えました。
- 2024/05/08: Austral を追加しました。
- 2024/05/07:
LeanLean4 を追加しました。追記しました。 - 2024/05/06: Seed7 を追加しました。
- 2024/05/05: Vala と Idris2 を追加しました。
- 2024/05/04: Pony を追加しました。
- 2024/05/03: Prolog を追加しました。
- 2024/05/02: Odin, Inko を追加しました。
- 2024/04/30: Mercury を追加しました。
- 2024/04/29: V (clang) を追加しました。
- 2024/04/28: Clojure のコンパイルオプションを追加しました。
- 2024/04/26: C (clang), C++ (clang), D (ldc) を追加しました。Zig を
0.12.0
に更新しました。 - 2024/04/25: Onyx を追加しました。
- 2024/04/24: D, Lobster を追加しました。
- 2024/04/23: Groovy を追加しました。
- 2024/04/22: Felix を追加しました。
- 2024/04/21: Racket を追加しました。
- 2024/04/20: Pike, Clojure, Gauche を追加しました。
- 2024/04/19: Javascript, Raku を追加しました。
- 2024/04/18: Reason を追加しました。
- 2024/04/17: Nim を追加しました。
- 2024/04/14: Ruby と Mojo, Python, Perl, Php を追加しました。
- 2024/04/12: Ada, V を追加しました。
- 2024/04/12: Haxe を追加しました。コンパイルオプションを変えました。
- 2024/04/11: Dart と Lua を追加しました。
- 2024/04/10: F# と Pascal, Koka を追加しました。
環境
- ハードウェア: Raspberry Pi 5
- メモリ: 8 GB
- ストレージ: M.2 SSD 512 GB
- OS: Ubuntu Server 24.04 LTS (64-bit)
結果
グラフ
全体
このグラフだけ横軸を対数にしています。
処理時間 0 ~ 30 秒
処理時間 3 ~ 8 秒
表
結果
言語 | ビルド | 時間 |
---|---|---|
Ada |
gnat make -o tarai2 tarai2.adb |
11.87 |
Ada |
gnat make -O1 -o tarai2 tarai2.adb |
7.93 |
Ada |
gnat make -O2 -o tarai2 tarai2.adb |
6.16 |
Ada |
gnat make -O3 -o tarai2 tarai2.adb |
4.13 |
Algol |
a68g tarai2.alg |
684.82 |
Ante |
ante -b tarai2.an |
36.47 |
Ante |
ante -b -O1 tarai2.an |
28.23 |
Ante |
ante -b -O2 tarai2.an |
28.31 |
Ante |
ante -b -O3 tarai2.an |
28.26 |
ArkScript |
arkscript tarai2.ark |
1253.70 |
Austral |
austral compile tarai2.aum --entrypoint=Tarai:main --output=a.out |
23.53 |
Ballerina |
bal build tarai2.bal |
17.16 |
C |
gcc tarai2.c -lm |
8.74 |
C |
gcc -Ofast tarai2.c -lm |
3.50 |
C |
clang-18 tarai2.c -lm |
11.40 |
C |
clang-18 -Ofast tarai2.c -lm |
5.88 |
C# |
dotnet build |
20.33 |
C# |
dotnet publish |
4.07 |
C++ |
g++ tarai2.cpp |
8.75 |
C++ |
g++ -Ofast tarai2.cpp |
3.51 |
C++ |
clang++-18 tarai2.cpp |
11.40 |
C++ |
clang++-18 -Ofast tarai2.cpp |
5.87 |
Clio |
node .clio/index.js |
16.58 |
Clio |
bun .clio/index.js |
20.08 |
Clojure |
lein uberjar |
18.64 |
Concurnas |
concc tarai2.conc |
32.22 |
Crystal |
crystal run tarai2.cr |
13.92 |
Crystal |
crystal build tarai2.cr |
7.81 |
Crystal |
crystal build -O1 tarai2.cr |
6.04 |
Crystal |
crystal build -O2 tarai2.cr |
6.46 |
Crystal |
crystal build -O3 tarai2.cr |
5.27 |
D |
gdc tarai2.d |
8.76 |
D |
gdc -Ofast tarai2.d |
3.47 |
D |
ldc2 tarai2.d |
9.24 |
D |
ldc2 --O3 tarai2.d |
5.74 |
Dart |
dart run tarai2.dart |
15.32 |
Dart |
dart compile aot-snapshot tarai2.dart |
9.24 |
Dart |
dart compile exe tarai2.dart |
9.23 |
Dart |
dart compile jit-snapshot tarai2.dart |
15.47 |
Dictu |
dictu tarai2.du |
165.56 |
Draco |
dotnet build |
21.41 |
Draco |
dotnet publish |
18.14 |
Effekt |
effekt.sh -b tarai2.effekt |
3132.74 |
Elixir |
mix escript.build |
13.69 |
Erlang |
rebar3 escriptize |
9.74 |
F# |
dotnet build |
12.86 |
F# |
dotnet publish |
7.01 |
Felix |
flx -O3 tarai2.flx |
3.34 |
Flix |
flix build; flix build-jar |
127.73 |
Fortran |
gfortran -o a.out tarai2.f90 |
12.96 |
Fortran |
gfortran -o a.out -Ofast tarai2.f90 |
3.99 |
Gauche |
gosh tarai2.scm |
120.25 |
Gleam |
gleam build |
12.32 |
Go |
go build |
6.33 |
Gravity |
gravity tarai2.gravity |
219.68 |
Groovy |
groovy tarai2.groovy |
35.59 |
Groovy |
groovy --compile-static tarai2.groovy |
8.46 |
Haskell |
cabal build |
9.48 |
Haskell |
cabal v1-build |
9.47 |
Haskell |
cabal v2-build |
9.47 |
Haxe |
haxe --main Tarai2 --jvm Tarai2.jar |
5.84 |
Haxe |
haxe -D analyzer-optimize --main Tarai2 --jvm Tarai2.jar |
4.85 |
Hy |
hy tarai2.hy |
188.38 |
Idris2 |
idris2 tarai2.idr -o a.out |
76.96 |
Inko |
inko build tarai2.inko |
44.63 |
Inko |
inko build --opt balanced tarai2.inko |
44.61 |
Inko |
inko build --opt aggressive tarai2.inko |
9.84 |
Java |
java Tarai2.java |
6.46 |
Java |
javac Tarai2.java |
5.78 |
Javascript |
node tarai2.js |
19.76 |
Javascript |
deno run tarai2.js |
21.35 |
Javascript |
bun tarai2.js |
20.02 |
Julia |
julia tarai2.ji |
9.22 |
Julia |
julia -O1 tarai2.ji |
12.76 |
Julia |
julia -O2 tarai2.ji |
9.14 |
Julia |
julia -O3 tarai2.ji |
9.18 |
Julia |
julia -O2 --min-optleve=1 tarai2.ji |
9.27 |
Julia |
julia -O2 --min-optleve=2 tarai2.ji |
9.19 |
Julia |
julia -O2 --min-optleve=3 tarai2.ji |
9.29 |
Koka |
koka -c -j4 -O3 -v0 -r tarai2.kk |
10.86 |
Kotlin |
kotlinc tarai2.kt -include-runtime -d tarai2.jar |
5.80 |
LEAN4 |
lake build |
12.86 |
Lisp |
clisp tarai2.lsp |
1493.17 |
Lisp |
clisp -c tarai2.lsp |
217.70 |
Lisp Flavored Erlang |
rebar3 lfe escriptize |
9.44 |
LiveScript |
lsc tarai2.ls |
20.57 |
Lobster |
lobster --pak tarai2.lobster |
190.05 |
Lua |
lua tarai2.lua |
90.40 |
Lua |
luajit tarai2.lua |
21.61 |
Mercury |
mmc -o a.out tarai2.m |
4.84 |
Mercury |
mmc -O6 -o a.out tarai2.m |
4.83 |
Mojo |
mojo build -o a.out tarai2.mojo |
5.78 |
Nelua |
nelua tarai2.nelua |
9.22 |
Nelua |
nelua --release tarai2.nelua |
5.21 |
Nelua |
nelua --maximum-performance tarai2.nelua |
3.78 |
Nim |
nim c -d:release --opt:size --hints:off -o:a.out tarai2.nim |
9.84 |
Nim |
nim cpp -d:release --opt:size --hints:off -o:a.out tarai2.nim |
7.71 |
Nim |
nim c -d:release --opt:speed --hints:off -o:a.out tarai2.nim |
8.86 |
Nim |
nim cpp -d:release --opt:speed --hints:off -o:a.out tarai2.nim |
6.00 |
Nit |
nitc -o a.out tarai2.nit |
7.71 |
Nit |
nitc --release -o a.out tarai2.nit |
7.71 |
Nit |
nitc --no-check-all -o a.out tarai2.nit |
7.55 |
OCaml |
dune build |
6.60 |
Odin |
odin build tarai2.odin -file |
10.94 |
Odin |
odin build tarai2.odin -o:speed -file |
5.45 |
Odin |
odin build tarai2.odin -o:speed -no-bounds-check -file |
5.45 |
Odin |
odin build tarai2.odin -o:speed -thread-count:4 -file |
5.45 |
Odin |
odin build tarai2.odin -o:speed -no-bounds-check -thread-count:4 -file |
5.45 |
Onyx |
onyx run tarai2.onyx |
12.66 |
Onyx |
onyx build tarai2.onyx |
12.52 |
Pascal |
fpc tarai2.pas |
12.95 |
Pascal |
fpc -O4 tarai2.pas |
9.41 |
Peregrine |
peregrine.elf compile tarai2.pe -o a.out |
12.46 |
Peregrine |
peregrine.elf compile tarai2.pe -static -o a.out |
12.43 |
Peregrine |
peregrine.elf compile tarai2.pe -release -o a.out |
5.98 |
Peregrine |
peregrine.elf compile tarai2.pe -release -static -o a.out |
6.02 |
Perl |
perl tarai2.pl |
1205.21 |
Php |
php tarai2.php |
98.05 |
Pike |
pike tarai2.pike |
259.16 |
Pinecone |
pinecone tarai2.pn |
3236.99 |
Poly/ML |
polyc tarai2.ml |
7.48 |
Pony |
ponyc |
6.00 |
Prolog |
swipl -O -g main -o a.out -c tarai2.swi |
383.11 |
Python |
python tarai2.py |
195.78 |
Python |
pypy3 tarai2.py |
132.17 |
R |
Rscript tarai2.R |
6884.97 |
Racket |
racket tarai2.rkt |
10.55 |
Racket |
raco exe tarai2.rkt |
10.55 |
Racket |
raco make tarai2.rkt |
10.54 |
Raku |
raku tarai2.p6 |
1100.15 |
Reason |
dune exec tarai2 |
6.66 |
Reason |
dune build |
6.60 |
Ring |
ring2exe tarai2.ring -static |
3447.47 |
Ruby |
ruby --yjit tarai2.rb |
28.79 |
Rune |
target/release/rune run scripts/tarai2.rn |
483.17 |
Rust |
cargo build --release |
5.74 |
Scala |
scala src/main/scala/Tarai2.scala |
9.27 |
Scala |
sbt assembly |
4.84 |
Seed7 |
s7c tarai2.sd7 |
11.86 |
Seed7 |
s7c -O3 tarai2.sd7 |
6.09 |
Seed7 |
s7c -O3 -oc3 tarai2.sd7 |
5.95 |
Sidef |
sidef -O2 tarai2.sf |
30761.01 |
Swift |
swiftc -o a.out tarai2.swift |
17.32 |
Swift |
swiftc -O -o a.out tarai2.swift |
5.94 |
Swift |
swiftc -Ounchecked -o a.out tarai2.swift |
6.23 |
V |
v run tarai2.v |
22.48 |
V |
v -prod -cc gcc -skip-unused -manualfree -prealloc -gc none -no-bounds-checking -o a.out tarai2.v |
3.46 |
V |
v -prod -cc clang-18 -skip-unused -manualfree -prealloc -gc none -no-bounds-checking -o a.out tarai2.v |
5.88 |
Vala |
valac -o a.out tarai2.vala |
11.63 |
Zig |
zig build-exe tarai2.zig |
11.76 |
Zig |
zig build-exe -OReleaseFast tarai2.zig |
5.73 |
Zig |
zig build-exe -OReleaseSafe tarai2.zig |
5.16 |
Zig |
zig build-exe -OReleaseSmall tarai2.zig |
6.08 |
言語のバージョン
言語 | バージョン |
---|---|
Ada |
GNAT 13.2.0 |
Alogl |
Algol 68 Genie 3.1.2 |
Ante |
ante 0.1.1 |
ArkScript |
4.0.0-71920056 |
Austral |
0.2.0 |
Ballerina |
Ballerina 2201.9.2 (Swan Lake Update 9) Language specification 2024R1 Update Tool 1.4.2
|
Ballerina |
java 22.0.1 2024-04-16 Java(TM) SE Runtime Environment (build 22.0.1+8-16) Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)
|
C |
gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0 |
C |
Ubuntu clang version 18.1.3 (1ubuntu1) |
C# |
8.0.303 |
C++ |
g++ (Ubuntu 13.2.0-23ubuntu4) 13.2.0 |
C++ |
Ubuntu clang version 18.1.3 (1ubuntu1) |
Clio |
0.12.0 |
Clojure |
Leiningen 2.11.2 on Java 22.0.1 Java HotSpot(TM) 64-Bit Server VM |
Concurnas |
Welcome to Concurnas 1.14.020 (OpenJDK 64-Bit Server VM, Java 11.0.23). |
Crystal |
Crystal 1.13.1 [0cef61e51] (2024-07-12) |
D |
gdc (Ubuntu 13.2.0-23ubuntu4) 13.2.0 |
D |
LDC - the LLVM D compiler (1.36.0): |
Dart |
Dart SDK version: 3.4.4 (stable) (Wed Jun 12 15:54:31 2024 +0000) on "linux_arm64" |
Dictu |
Dictu Version: 0.29.0 |
Draco |
8.0.303 |
Effekt |
v0.2.2 |
Elixir |
Elixir 1.17.2 (compiled with Erlang/OTP 27) |
Elixir |
Mix 1.17.2 (compiled with Erlang/OTP 27) |
Erlang |
rebar 3.23.0+build.5413.ref4ca95a1e on Erlang/OTP 27 Erts 15.0.1 |
F# |
8.0.303 |
Felix |
version 2019.01.06 |
Flix |
The Flix Programming Language 0.48.0 |
Fortran |
GNU Fortran (Ubuntu 13.2.0-23ubuntu4) 13.2.0 |
Gauche |
Gauche scheme shell, version 0.9.15 [utf-8,pthreads], aarch64-unknown-linux-gnu |
Gleam |
gleam 1.3.2 |
Go |
go version go1.22.5 linux/arm64 |
Gravity |
Gravity version 0.8.5 (Aug 13 2024) |
Groovy |
Groovy Version: 4.0.22 JVM: 22.0.1 Vendor: Oracle Corporation OS: Linux |
Haskell |
The Glorious Glasgow Haskell Compilation System, version 9.10.1 |
Haxe |
4.3.3 |
Haxe |
java 22.0.1 2024-04-16 Java(TM) SE Runtime Environment (build 22.0.1+8-16) Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)
|
Hy |
hy 0.29.0 |
Idris2 |
Idris 2, version 0.7.0 |
Inko |
inko 0.15.0 |
Java |
java 22.0.1 2024-04-16 Java(TM) SE Runtime Environment (build 22.0.1+8-16) Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)
|
Javascript |
node --version v22.5.1
|
Javascript |
deno 1.45.4 (release, aarch64-unknown-linux-gnu) v8 12.7.224.13 typescript 5.5.2
|
Javascript |
bun --version 1.1.20
|
Julia |
julia version 1.10.4 |
Koka |
Koka 3.1.2, 23:10:17 Jun 7 2024 (ghc release version) |
kotlin |
Kotlin version 2.0.0-release-341 (JRE 22.0.1+8-16) |
LEAN4 |
Lean (version 4.8.0, aarch64-unknown-linux-gnu, commit df668f00e6c0, Release) |
LEAN4 |
Lake version 5.0.0-df668f0 (Lean version 4.8.0) |
Lisp |
GNU CLISP 2.49.93+ (2018-02-18) (built on bos01-arm64-038.buildd [127.0.1.1]) |
Lisp Flavored Erlang |
LFE v2.1.4 |
LiveScript |
LiveScript version 1.6.0 |
Lobster |
Lobster programming language compiler/runtime (version 2024-07-17T15:17:09-07:00|ea01a900) |
Lua |
Lua 5.4.6 Copyright (C) 1994-2023 Lua.org, PUC-Rio |
Lua |
LuaJIT 2.1.1703358377 -- Copyright (C) 2005-2023 Mike Pall. https://luajit.org/ |
Mercury |
Mercury Compiler, version 22.01.8, on aarch64-unknown-linux-gnu |
Mojo |
mojo 24.4.0 (2cb57382) |
Nelua |
Nelua 0.2.0-dev Build number: 1617
|
Nim |
Nim Compiler Version 2.0.8 [Linux: arm64] |
Nit |
v0.8-3697-ge8e9cca96 |
OCaml |
The OCaml toplevel, version 5.2.0 |
Odin |
odin version dev-2024-07:0bb4cc6ce |
Onyx |
Onyx toolchain version v0.1.12 |
Pascal |
Free Pascal Compiler version 3.2.2+dfsg-32 [2024/01/05] for aarch64 |
Peregrine |
Peregrine Compiler (C) The Peregrine Organisation, MPL-2.0 |
Perl |
This is perl 5, version 40, subversion 0 (v5.40.0) built for aarch64-linux |
Php |
PHP 8.3.9 (cli) (built: Jul 21 2024 05:51:48) (NTS) |
Pike |
Pike v8.0 release 1738 Copyright © 1994-2022 Linköping University |
Pinecone |
Pinecone version 0.5.1 |
Poly/ML |
Poly/ML 5.9.1 Release RTS version: Arm64-5.9.1 (Git version v5.9.1-64-ga71e81c1) |
Pony |
0.58.5-da2b0322 [release] |
Prolog |
SWI-Prolog version 9.0.4 for aarch64-linux |
Python |
Python 3.12.4 |
Python |
Python 3.9.18 (7.3.15+dfsg-1build3, Mar 31 2024, 07:19:21) [PyPy 7.3.15 with GCC 13.2.0]
|
R |
R version 4.4.1 (2024-06-14) -- "Race for Your Life" |
Racket |
Welcome to Racket v8.13 [cs]. |
Raku |
Welcome to Rakudo™ v2022.12. |
Reason |
Reason 3.11.0 @ |
Ring |
Ring version 1.21 |
Ruby |
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [aarch64-linux] |
Rune |
The Rune Language Interpreter git-812da733 |
Rust |
rustc 1.80.0 (051478957 2024-07-21) |
Scala |
Scala code runner version 3.4.2 -- Copyright 2002-2024, LAMP/EPFL |
Scala |
sbt script version: 1.10.0 |
Scala |
java 22.0.1 2024-04-16 Java(TM) SE Runtime Environment (build 22.0.1+8-16) Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)
|
Seed7 |
SEED7 COMPILER Version 3.2.50 Copyright (c) 1990-2023 Thomas Mertes |
Sidef |
Sidef 24.05 |
Swift |
Swift version 5.10.1 (swift-5.10.1-RELEASE) Target: aarch64-unknown-linux-gnu
|
V |
V 0.4.7 52fe7c0 |
Vala |
Vala 0.56.16 |
Zig |
0.13.0 |
実測
Ada
Sun Jul 14 14:34:05 JST 2024
tarai2.adb
with Ada.Text_IO; use Ada.Text_IO;
procedure Tarai2 is
function tarai(x, y, z: Integer) return Integer is
begin
if x <= y then
return y;
end if;
return tarai(tarai(x-1, y, z), tarai(y-1, z, x), tarai(z-1, x, y));
end tarai;
begin
Put_Line(Integer'Image(tarai(15, 5, 0)));
end Tarai2;
$ gnat --version
GNAT 13.2.0
Copyright (C) 1996-2023, Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ gnatclean switches tarai2; gnat make -o tarai2 tarai2.adb; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
"./tarai2.ali" has been deleted
"./tarai2.o" has been deleted
"tarai2" has been deleted
aarch64-linux-gnu-gcc-13 -c tarai2.adb
aarch64-linux-gnu-gnatbind-13 -x tarai2.ali
aarch64-linux-gnu-gnatlink-13 tarai2.ali -o tarai2
15
real:11.87[sec]_user:11.86[sec]_sys:0.00[sec]_Memory:3584[KB]
$ gnatclean switches tarai2; gnat make -O1 -o tarai2 tarai2.adb; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
"./tarai2.ali" has been deleted
"./tarai2.o" has been deleted
"tarai2" has been deleted
aarch64-linux-gnu-gcc-13 -c -O1 tarai2.adb
aarch64-linux-gnu-gnatbind-13 -x tarai2.ali
aarch64-linux-gnu-gnatlink-13 tarai2.ali -O1 -o tarai2
15
real:7.93[sec]_user:7.92[sec]_sys:0.00[sec]_Memory:3584[KB]
$ gnatclean switches tarai2; gnat make -O2 -o tarai2 tarai2.adb; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
"./tarai2.ali" has been deleted
"./tarai2.o" has been deleted
"tarai2" has been deleted
aarch64-linux-gnu-gcc-13 -c -O2 tarai2.adb
aarch64-linux-gnu-gnatbind-13 -x tarai2.ali
aarch64-linux-gnu-gnatlink-13 tarai2.ali -O2 -o tarai2
15
real:6.16[sec]_user:6.15[sec]_sys:0.00[sec]_Memory:3584[KB]
$ gnatclean switches tarai2; gnat make -O3 -o tarai2 tarai2.adb; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
"./tarai2.ali" has been deleted
"./tarai2.o" has been deleted
"tarai2" has been deleted
aarch64-linux-gnu-gcc-13 -c -O3 tarai2.adb
aarch64-linux-gnu-gnatbind-13 -x tarai2.ali
aarch64-linux-gnu-gnatlink-13 tarai2.ali -O3 -o tarai2
15
real:4.13[sec]_user:4.13[sec]_sys:0.00[sec]_Memory:3584[KB]
Algol
Sun Jul 14 16:48:55 JST 2024
$ a68g --pretty-print tarai2.alg
tarai2.alg.f
PROC tarai = (INT i, j, k) INT:
IF i <= j
THEN j
ELSE tarai (tarai (i - 1, j, k), tarai (j - 1, k, i), tarai (k - 1, i, j))
FI;
print ((tarai (15, 5, 0), new line))
$ a68g -v
Algol 68 Genie 3.1.2
Copyright 2001-2023 Marcel van der Veer <algol68g@xs4all.nl>.
This is free software covered by the GNU General Public License.
There is ABSOLUTELY NO WARRANTY for Algol 68 Genie;
not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
Please report bugs to Marcel van der Veer <algol68g@xs4all.nl>.
With compilation support
C compiler is gcc
With parallel-clause support
With TCP/IP support
GNU libc version glibc 2.39
GNU libpthread version NPTL 2.39
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] a68g tarai2.alg
+15
real:684.82[sec]_user:684.61[sec]_sys:0.02[sec]_Memory:20224[KB]
Ante
Sat Jul 20 13:32:22 JST 2024
$
tarai2.an
tarai x y z =
if x <= y then y
else tarai ( tarai (x - 1) y z ) ( tarai (y - 1) z x ) ( tarai (z - 1) x y )
print (tarai 15 5 0)
$ ante --version
ante 0.1.1
$ rm -rf tarai2; ante -b tarai2.an; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
15
real:36.47[sec]_user:36.46[sec]_sys:0.00[sec]_Memory:1024[KB]
$ rm -rf tarai2; ante -b -O1 tarai2.an; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
15
real:28.23[sec]_user:28.22[sec]_sys:0.00[sec]_Memory:1024[KB]
$ rm -rf tarai2; ante -b -O2 tarai2.an; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
15
real:28.31[sec]_user:28.31[sec]_sys:0.00[sec]_Memory:1024[KB]
$ rm -rf tarai2; ante -b -O3 tarai2.an; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
15
real:28.26[sec]_user:28.25[sec]_sys:0.00[sec]_Memory:1024[KB]
ArkScript
Thu Aug 8 10:09:15 JST 2024
$ arkscript --format tarai2.ark
tarai2.ark
(let tarai (fun (x y z)
(if (<= x y)
y
(tarai (tarai (- x 1) y z) (tarai (- y 1) z x) (tarai (- z 1) x y)))))
(print (tarai 15 5 0))
$ arkscript --version
4.0.0-71920056
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] arkscript tarai2.ark
15
real:1253.70[sec]_user:1253.33[sec]_sys:0.01[sec]_Memory:5120[KB]
Austral
Sat Jul 20 13:39:56 JST 2024
$
tarai2.aum
module body Tarai is
function tarai(x: Int32, y: Int32, z: Int32): Int32 is
if x <= y then
return y;
else
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y));
end if;
end;
function main(): ExitCode is
printLn(tarai(15, 5, 0));
return ExitSuccess();
end;
end module body.
$ austral --version
0.2.0
$ rm -rf a.out; austral compile tarai2.aum --entrypoint=Tarai:main --output=a.out; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:23.53[sec]_user:23.52[sec]_sys:0.00[sec]_Memory:1280[KB]
Ballerina
Sun Jul 14 09:19:52 JST 2024
$ bal format tarai2.bal
no changes.
tarai2.bal
import ballerina/io;
public function tarai(int x, int y, int z) returns int {
if x <= y {
return y;
}
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y));
}
public function main() {
io:println(tarai(15, 5, 0));
}
$ sdk use java 22.0.1-oracle
Using java version 22.0.1-oracle in this shell.
$ bal -v
Ballerina 2201.9.2 (Swan Lake Update 9)
Language specification 2024R1
Update Tool 1.4.2
$ java --version
java 22.0.1 2024-04-16
Java(TM) SE Runtime Environment (build 22.0.1+8-16)
Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)
$ rm -rf tarai2.jar; bal build tarai2.bal; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] java -jar tarai2.jar
Compiling source
tarai2.bal
Generating executable
tarai2.jar
15
real:17.16[sec]_user:17.37[sec]_sys:0.11[sec]_Memory:65456[KB]
$ sdk use java 17.0.11-oracle
Using java version 17.0.11-oracle in this shell.
$ bal -v
Ballerina 2201.9.2 (Swan Lake Update 9)
Language specification 2024R1
Update Tool 1.4.2
$ java --version
java 17.0.11 2024-04-16 LTS
Java(TM) SE Runtime Environment (build 17.0.11+7-LTS-207)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.11+7-LTS-207, mixed mode, sharing)
$ rm -rf tarai2.jar; bal build tarai2.bal; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] java -jar tarai2.jar
Compiling source
tarai2.bal
Generating executable
tarai2.jar
15
real:15.33[sec]_user:15.54[sec]_sys:0.09[sec]_Memory:63164[KB]
C
Fri Jul 5 14:22:37 JST 2024
$ clang-format-18 -i tarai2.c
tarai2.c
#include <stdio.h>
int tarai(int x, int y, int z) {
if (x <= y) {
return y;
}
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y));
}
int main(void) {
printf("%d\n", tarai(15, 5, 0));
return 0;
}
$ gcc --version
gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ rm -rf a.out; gcc tarai2.c -lm; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:8.74[sec]_user:8.73[sec]_sys:0.00[sec]_Memory:1280[KB]
$ rm -rf a.out; gcc -Ofast tarai2.c -lm; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:3.50[sec]_user:3.50[sec]_sys:0.00[sec]_Memory:1280[KB]
$ clang-18 --version
Ubuntu clang version 18.1.3 (1ubuntu1)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ rm -rf a.out; clang-18 tarai2.c -lm; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:11.40[sec]_user:11.39[sec]_sys:0.00[sec]_Memory:1408[KB]
$ rm -rf a.out; clang-18 -Ofast tarai2.c -lm; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:5.88[sec]_user:5.87[sec]_sys:0.00[sec]_Memory:1408[KB]
C#
Sat Jul 27 15:52:31 JST 2024
$ dotnet format style
Program.cs
using System;
namespace ConsoleApp {
class Program {
static int tarai(int x, int y, int z) {
if (x <= y) {
return y;
} else {
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y));
}
}
static void Main() {
Console.WriteLine(tarai(15, 5, 0));
}
}
}
$ dotnet --version
8.0.303
$ dotnet clean; dotnet build; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] dotnet run
Build started 07/27/2024 15:52:39.
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.74
Determining projects to restore...
All projects are up-to-date for restore.
tarai2 -> $HOME/workspace/cs/tarai2/bin/Debug/net8.0/tarai2.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:02.04
15
real:20.33[sec]_user:22.41[sec]_sys:0.56[sec]_Memory:181080[KB]
$ dotnet clean; dotnet publish; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] bin/Release/net8.0/tarai2
Build started 07/27/2024 15:53:03.
1>Project "$HOME/workspace/cs/tarai2/tarai2.csproj" on node 1 (Clean target(s)).
1>CoreClean:
Deleting file "$HOME/workspace/cs/tarai2/bin/Debug/net8.0/tarai2".
Deleting file "$HOME/workspace/cs/tarai2/bin/Debug/net8.0/tarai2.deps.json".
Deleting file "$HOME/workspace/cs/tarai2/bin/Debug/net8.0/tarai2.runtimeconfig.json".
Deleting file "$HOME/workspace/cs/tarai2/bin/Debug/net8.0/tarai2.dll".
Deleting file "$HOME/workspace/cs/tarai2/bin/Debug/net8.0/tarai2.pdb".
Deleting file "$HOME/workspace/cs/tarai2/obj/Debug/net8.0/tarai2.GeneratedMSBuildEditorConfig.editorconfig".
Deleting file "$HOME/workspace/cs/tarai2/obj/Debug/net8.0/tarai2.AssemblyInfoInputs.cache".
Deleting file "$HOME/workspace/cs/tarai2/obj/Debug/net8.0/tarai2.AssemblyInfo.cs".
Deleting file "$HOME/workspace/cs/tarai2/obj/Debug/net8.0/tarai2.csproj.CoreCompileInputs.cache".
Deleting file "$HOME/workspace/cs/tarai2/obj/Debug/net8.0/tarai2.dll".
Deleting file "$HOME/workspace/cs/tarai2/obj/Debug/net8.0/refint/tarai2.dll".
Deleting file "$HOME/workspace/cs/tarai2/obj/Debug/net8.0/tarai2.pdb".
Deleting file "$HOME/workspace/cs/tarai2/obj/Debug/net8.0/tarai2.genruntimeconfig.cache".
Deleting file "$HOME/workspace/cs/tarai2/obj/Debug/net8.0/ref/tarai2.dll".
1>Done Building Project "$HOME/workspace/cs/tarai2/tarai2.csproj" (Clean target(s)).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.73
Determining projects to restore...
All projects are up-to-date for restore.
tarai2 -> $HOME/workspace/cs/tarai2/bin/Release/net8.0/tarai2.dll
tarai2 -> $HOME/workspace/cs/tarai2/bin/Release/net8.0/publish/
15
real:4.07[sec]_user:4.04[sec]_sys:0.01[sec]_Memory:27528[KB]
C++
Fri Jul 5 15:00:32 JST 2024
$ clang-format-18 -i tarai2.cpp
tarai2.cpp
#include <iostream>
int tarai(int x, int y, int z) {
if (x <= y) {
return y;
}
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y));
}
int main() {
std::cout << tarai(15, 5, 0) << std::endl;
return 0;
}
$ g++ --version
g++ (Ubuntu 13.2.0-23ubuntu4) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ rm -rf a.out; g++ tarai2.cpp; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:8.75[sec]_user:8.75[sec]_sys:0.00[sec]_Memory:3072[KB]
$ rm -rf a.out; g++ -Ofast tarai2.cpp; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:3.51[sec]_user:3.50[sec]_sys:0.00[sec]_Memory:3072[KB]
$ clang++-18 --version
Ubuntu clang version 18.1.3 (1ubuntu1)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ rm -rf a.out; clang++-18 tarai2.cpp; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:11.40[sec]_user:11.40[sec]_sys:0.00[sec]_Memory:3072[KB]
$ rm -rf a.out; clang++-18 -Ofast tarai2.cpp; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:5.87[sec]_user:5.86[sec]_sys:0.00[sec]_Memory:3072[KB]
Clio
Sat Aug 10 17:47:41 JST 2024
$
src/main.clio
fn tarai x y z:
if x <= y: y
else: tarai (tarai x - 1 y z) (tarai y - 1 z x) (tarai z - 1 x y)
export fn main argv:
tarai 15 5 0 -> console.log
$ clio --version
0.12.0
$ node --version
v22.5.1
$ rm -rf build; clio build; cd build
Info: Compiling from "clio.toml"
Info: Creating build for target "js"
✔ Compiling from source...
✔ Copying over the resource files...
✔ Adding Clio start script...
✔ Installing npm dependencies (this may take a while)...
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] node .clio/index.js
15
real:16.58[sec]_user:17.63[sec]_sys:0.25[sec]_Memory:160508[KB]
$ bun --version
1.1.20
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] bun .clio/index.js
[bun] Warning: async_hooks.createHook is not implemented in Bun. Hooks can still be created but will never be called.
15
real:20.08[sec]_user:20.74[sec]_sys:0.23[sec]_Memory:173260[KB]
Clojure
Sun Jul 14 09:31:56 JST 2024
$ cljfmt src/tarai2/core.clj
src/tarai2/core.clj
(ns tarai2.core
(:gen-class))
(defn tarai [x y z]
(do
(if (<= x y)
y
(tarai
(tarai (- x 1) y z)
(tarai (- y 1) z x)
(tarai (- z 1) x y)))))
(defn -main
[& args]
(prn (tarai 15 5 0)))
$ sdk use java 22.0.1-oracle
Using java version 22.0.1-oracle in this shell.
$ lein --version
Leiningen 2.11.2 on Java 22.0.1 Java HotSpot(TM) 64-Bit Server VM
$ java --version
java 22.0.1 2024-04-16
Java(TM) SE Runtime Environment (build 22.0.1+8-16)
Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)
$ lein clean; lein uberjar; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] java -jar ./target/uberjar/tarai2-0.1.0-SNAPSHOT-standalone.jar
Compiling tarai2.core
Created $HOME/workspace/clojure/tarai2/target/uberjar/tarai2-0.1.0-SNAPSHOT.jar
Created $HOME/workspace/clojure/tarai2/target/uberjar/tarai2-0.1.0-SNAPSHOT-standalone.jar
15
real:18.64[sec]_user:19.40[sec]_sys:0.16[sec]_Memory:83488[KB]
$ sdk use java 17.0.11-oracle
Using java version 17.0.11-oracle in this shell.
$ clojure --help | head
./tarai2_clojure.sh: line 38: clojure: command not found
$ lein --version
Leiningen 2.11.2 on Java 17.0.11 Java HotSpot(TM) 64-Bit Server VM
$ java --version
java 17.0.11 2024-04-16 LTS
Java(TM) SE Runtime Environment (build 17.0.11+7-LTS-207)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.11+7-LTS-207, mixed mode, sharing)
$ lein clean; lein uberjar; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] java -jar ./target/uberjar/tarai2-0.1.0-SNAPSHOT-standalone.jar
Compiling tarai2.core
Created $HOME/workspace/clojure/tarai2/target/uberjar/tarai2-0.1.0-SNAPSHOT.jar
Created $HOME/workspace/clojure/tarai2/target/uberjar/tarai2-0.1.0-SNAPSHOT-standalone.jar
15
real:17.77[sec]_user:18.78[sec]_sys:0.17[sec]_Memory:84020[KB]
Concurnas
Sun Jul 14 09:36:12 JST 2024
tarai2.conc
def tarai(x int, y int, z int) int {
if (x > y) {
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
}
return y
}
System.out.println(tarai(15, 5, 0))!
$ sdk use java 11.0.23-amzn
Using java version 11.0.23-amzn in this shell.
$ java --version
openjdk 11.0.23 2024-04-16 LTS
OpenJDK Runtime Environment Corretto-11.0.23.9.1 (build 11.0.23+9-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.23.9.1 (build 11.0.23+9-LTS, mixed mode)
$ concc tarai2.conc; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] conc tarai2
Finished compilation of: $HOME/workspace/concurnas/tarai2/tarai2.conc -> $HOME/workspace/concurnas/tarai2/tarai2$tarai2$$Lambda0.class [tarai2$tarai2$$Lambda0], $HOME/workspace/concurnas/tarai2/tarai2.class [tarai2]
15
real:32.22[sec]_user:41.76[sec]_sys:0.85[sec]_Memory:201320[KB]
Crystal
Fri Jul 19 22:57:26 JST 2024
$ crystal tool format src/tarai2.cr
Using compiled compiler at $HOME/.crystal/.build/crystal
src/tarai2.cr
module Tarai2
def tarai(x : Int32, y : Int32, z : Int32)
if x <= y
return y
end
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
end
end
include Tarai2
puts tarai(15, 5, 0)
$ crystal --version
Using compiled compiler at $HOME/.crystal/.build/crystal
Crystal 1.13.1 [0cef61e51] (2024-07-12)
The compiler was not built in release mode.
LLVM: 18.1.3
Default target: aarch64-unknown-linux-gnu
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] crystal run src/tarai2.cr
Using compiled compiler at $HOME/.crystal/.build/crystal
15
real:13.92[sec]_user:15.54[sec]_sys:1.10[sec]_Memory:278528[KB]
$ rm -rf tarai2; crystal build src/tarai2.cr; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
Using compiled compiler at $HOME/.crystal/.build/crystal
15
real:7.81[sec]_user:7.81[sec]_sys:0.00[sec]_Memory:2944[KB]
$ rm -rf tarai2; crystal build -O1 src/tarai2.cr; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
Using compiled compiler at $HOME/.crystal/.build/crystal
15
real:6.04[sec]_user:6.04[sec]_sys:0.00[sec]_Memory:2688[KB]
$ rm -rf tarai2; crystal build -O2 src/tarai2.cr; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
Using compiled compiler at $HOME/.crystal/.build/crystal
15
real:6.46[sec]_user:6.45[sec]_sys:0.00[sec]_Memory:2688[KB]
$ rm -rf tarai2; crystal build -O3 src/tarai2.cr; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
Using compiled compiler at $HOME/.crystal/.build/crystal
15
real:5.27[sec]_user:5.27[sec]_sys:0.00[sec]_Memory:2816[KB]
D
Thu Jul 11 00:33:57 JST 2024
$ dfmt -i tarai2.d
tarai2.d
import std.stdio;
int tarai(int x, int y, int z)
{
if (x <= y)
return y;
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y));
}
void main()
{
writeln(tarai(15, 5, 0));
}
$ gdc --version
gdc (Ubuntu 13.2.0-23ubuntu4) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ rm -rf tarai2; gdc -o tarai2 tarai2.d; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
15
real:8.76[sec]_user:8.75[sec]_sys:0.00[sec]_Memory:6144[KB]
$ rm -rf tarai2; gdc -Ofast -o tarai2 tarai2.d; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
15
real:3.47[sec]_user:3.47[sec]_sys:0.00[sec]_Memory:6144[KB]
$ ldc2 --version | head
LDC - the LLVM D compiler (1.36.0):
based on DMD v2.106.1 and LLVM 17.0.6
built with LDC - the LLVM D compiler (1.36.0)
Default target: aarch64-unknown-linux-gnu
Host CPU: cortex-a76
http://dlang.org - http://wiki.dlang.org/LDC
Registered Targets:
aarch64 - AArch64 (little endian)
$ rm -rf tarai2; ldc2 tarai2.d; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
15
real:9.24[sec]_user:9.23[sec]_sys:0.00[sec]_Memory:5376[KB]
$ rm -rf tarai2; ldc2 --O3 tarai2.d; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
15
real:5.74[sec]_user:5.73[sec]_sys:0.00[sec]_Memory:5376[KB]
Dart
Sat Jul 20 13:17:24 JST 2024
$ dart format tarai2.dart
Formatted 1 file (0 changed) in 0.21 seconds.
tarai2.dart
int tarai(int x, int y, int z) {
if (x <= y) {
return y;
}
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y));
}
main() {
print(tarai(15, 5, 0));
}
$ dart --version
Dart SDK version: 3.4.4 (stable) (Wed Jun 12 15:54:31 2024 +0000) on "linux_arm64"
$ dart --disable-analytics
Analytics reporting disabled. In order to enable it, run: dart --enable-analytics
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] dart run tarai2.dart
15
real:15.32[sec]_user:15.52[sec]_sys:0.25[sec]_Memory:153168[KB]
$ dart compile aot-snapshot tarai2.dart; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] dartaotruntime tarai2.aot
Generated: $HOME/workspace/dart/tarai2/tarai2.aot
15
real:9.24[sec]_user:9.23[sec]_sys:0.00[sec]_Memory:5632[KB]
$ dart compile exe tarai2.dart; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2.exe
Generated: $HOME/workspace/dart/tarai2/tarai2.exe
15
real:9.23[sec]_user:9.22[sec]_sys:0.00[sec]_Memory:5760[KB]
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] dart compile jit-snapshot tarai2.dart
Compiling tarai2.dart to jit-snapshot file tarai2.jit.
15
real:15.47[sec]_user:15.76[sec]_sys:0.33[sec]_Memory:160884[KB]
Dictu
Sun Aug 11 13:13:30 JST 2024
$
tarai2.du
def tarai(x, y, z) {
if (x <= y)
return y;
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y));
}
print(tarai(15, 5, 0));
$ dictu --version
Dictu Version: 0.29.0
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] dictu tarai2.du
15
real:165.56[sec]_user:165.51[sec]_sys:0.00[sec]_Memory:8576[KB]
Draco
Mon Aug 12 12:11:10 JST 2024
$
main.draco
import System.Console;
func main() {
WriteLine(tarai(15, 5, 0));
}
func tarai(x: int32, y: int32, z: int32): int32 =
if (x <= y) y
else tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y));
$ dotnet --version
8.0.303
$ dotnet clean; dotnet build; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] dotnet run
Build started 08/12/2024 12:11:11.
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.77
Determining projects to restore...
All projects are up-to-date for restore.
tarai2 -> $HOME/workspace/draco/tarai2/bin/Debug/net8.0/tarai2.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:02.90
15
real:21.41[sec]_user:22.88[sec]_sys:0.54[sec]_Memory:177756[KB]
$ dotnet clean; dotnet publish; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] bin/Release/net8.0/tarai2
Build started 08/12/2024 12:11:36.
1>Project "$HOME/workspace/draco/tarai2/tarai2.dracoproj" on node 1 (Clean target(s)).
1>CoreClean:
Deleting file "$HOME/workspace/draco/tarai2/bin/Debug/net8.0/tarai2".
Deleting file "$HOME/workspace/draco/tarai2/bin/Debug/net8.0/tarai2.deps.json".
Deleting file "$HOME/workspace/draco/tarai2/bin/Debug/net8.0/tarai2.runtimeconfig.json".
Deleting file "$HOME/workspace/draco/tarai2/bin/Debug/net8.0/tarai2.dll".
Deleting file "$HOME/workspace/draco/tarai2/bin/Debug/net8.0/tarai2.pdb".
Deleting file "$HOME/workspace/draco/tarai2/obj/Debug/net8.0/tarai2.dracoproj.CoreCompileInputs.cache".
Deleting file "$HOME/workspace/draco/tarai2/obj/Debug/net8.0/tarai2.dll".
Deleting file "$HOME/workspace/draco/tarai2/obj/Debug/net8.0/tarai2.pdb".
Deleting file "$HOME/workspace/draco/tarai2/obj/Debug/net8.0/tarai2.genruntimeconfig.cache".
1>Done Building Project "$HOME/workspace/draco/tarai2/tarai2.dracoproj" (Clean target(s)).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.75
Determining projects to restore...
All projects are up-to-date for restore.
tarai2 -> $HOME/workspace/draco/tarai2/bin/Release/net8.0/tarai2.dll
tarai2 -> $HOME/workspace/draco/tarai2/bin/Release/net8.0/publish/
15
real:18.14[sec]_user:18.10[sec]_sys:0.02[sec]_Memory:27392[KB]
Effekt
tarai2.effekt
def tarai(x: Int, y: Int, z: Int): Int =
if (x <= y) { y } else {
tarai(tarai(x-1, y, z), tarai(y-1, z, x), tarai(z-1, x, y));
}
def main() = {
println(tarai(15, 5, 0));
}
$ rm -rf out; effekt.sh -b tarai2.effekt; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./out/tarai2
15
real:3132.74[sec]_user:3129.94[sec]_sys:5.82[sec]_Memory:116320[KB]
Elixir
Tue Jul 16 23:39:27 JST 2024
$ mix format lib/tarai2.ex
lib/tarai2.ex
defmodule Tarai2 do
def tarai(x, y, z) do
if x <= y do
y
else
tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
end
end
def main(_) do
IO.puts(Tarai2.tarai(15, 5, 0))
end
end
$ elixir --version
Erlang/OTP 27 [erts-15.0.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit]
Elixir 1.17.2 (compiled with Erlang/OTP 27)
$ mix --version
Erlang/OTP 27 [erts-15.0.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit]
Mix 1.17.2 (compiled with Erlang/OTP 27)
$ rm -rf tarai2; mix clean; mix escript.build; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
Compiling 1 file (.ex)
Generated tarai2 app
Generated escript tarai2 with MIX_ENV=dev
15
real:13.69[sec]_user:13.56[sec]_sys:0.29[sec]_Memory:70552[KB]
Erlang
Wed Jul 17 00:40:10 JST 2024
$ efmt -w src/tarai2.erl
[2024-07-16T15:40:10Z INFO efmt] All files were formatted correctly!
src/tarai2.erl
-module(tarai2).
-export([main/1]).
main(_) ->
io:format("~p~n", [tarai(15, 5, 0)]),
erlang:halt(0).
tarai(X, Y, _) when X =< Y -> Y;
tarai(X, Y, Z) -> tarai(tarai(X - 1, Y, Z), tarai(Y - 1, Z, X), tarai(Z - 1, X, Y)).
$ rebar3 --version
rebar 3.23.0+build.5413.ref4ca95a1e on Erlang/OTP 27 Erts 15.0.1
$ rebar3 escriptize; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./_build/default/bin/tarai2
===> Verifying dependencies...
===> Analyzing applications...
===> Compiling tarai2
===> Building escript for tarai2...
15
real:9.74[sec]_user:9.60[sec]_sys:0.26[sec]_Memory:55540[KB]
F#
Sat Jul 27 15:57:15 JST 2024
$ dotnet fantomas Program.fs
Program.fs was unchanged.
Program.fs
let rec tarai x y z =
if x <= y then
y
else
tarai (tarai (x - 1) y z) (tarai (y - 1) z x) (tarai (z - 1) x y)
printfn "%d" (tarai 15 5 0)
$ dotnet --version
8.0.303
$ dotnet clean; dotnet build; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] dotnet run
Build started 07/27/2024 15:57:17.
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.73
Determining projects to restore...
Restored $HOME/workspace/fs/tarai2/tarai2.fsproj (in 1.1 sec).
tarai2 -> $HOME/workspace/fs/tarai2/bin/Debug/net8.0/tarai2.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:04.70
15
real:12.86[sec]_user:13.74[sec]_sys:0.39[sec]_Memory:173820[KB]
$ dotnet clean; dotnet publish; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] bin/Release/net8.0/tarai2
Build started 07/27/2024 15:57:36.
1>Project "$HOME/workspace/fs/tarai2/tarai2.fsproj" on node 1 (Clean target(s)).
1>CoreClean:
Deleting file "$HOME/workspace/fs/tarai2/bin/Debug/net8.0/tarai2".
Deleting file "$HOME/workspace/fs/tarai2/bin/Debug/net8.0/tarai2.deps.json".
Deleting file "$HOME/workspace/fs/tarai2/bin/Debug/net8.0/tarai2.runtimeconfig.json".
Deleting file "$HOME/workspace/fs/tarai2/bin/Debug/net8.0/tarai2.dll".
Deleting file "$HOME/workspace/fs/tarai2/bin/Debug/net8.0/tarai2.pdb".
Deleting file "$HOME/workspace/fs/tarai2/bin/Debug/net8.0/FSharp.Core.dll".
Deleting file "$HOME/workspace/fs/tarai2/bin/Debug/net8.0/cs/FSharp.Core.resources.dll".
Deleting file "$HOME/workspace/fs/tarai2/bin/Debug/net8.0/de/FSharp.Core.resources.dll".
Deleting file "$HOME/workspace/fs/tarai2/bin/Debug/net8.0/es/FSharp.Core.resources.dll".
Deleting file "$HOME/workspace/fs/tarai2/bin/Debug/net8.0/fr/FSharp.Core.resources.dll".
Deleting file "$HOME/workspace/fs/tarai2/bin/Debug/net8.0/it/FSharp.Core.resources.dll".
Deleting file "$HOME/workspace/fs/tarai2/bin/Debug/net8.0/ja/FSharp.Core.resources.dll".
Deleting file "$HOME/workspace/fs/tarai2/bin/Debug/net8.0/ko/FSharp.Core.resources.dll".
Deleting file "$HOME/workspace/fs/tarai2/bin/Debug/net8.0/pl/FSharp.Core.resources.dll".
Deleting file "$HOME/workspace/fs/tarai2/bin/Debug/net8.0/pt-BR/FSharp.Core.resources.dll".
Deleting file "$HOME/workspace/fs/tarai2/bin/Debug/net8.0/ru/FSharp.Core.resources.dll".
Deleting file "$HOME/workspace/fs/tarai2/bin/Debug/net8.0/tr/FSharp.Core.resources.dll".
Deleting file "$HOME/workspace/fs/tarai2/bin/Debug/net8.0/zh-Hans/FSharp.Core.resources.dll".
Deleting file "$HOME/workspace/fs/tarai2/bin/Debug/net8.0/zh-Hant/FSharp.Core.resources.dll".
Deleting file "$HOME/workspace/fs/tarai2/obj/Debug/net8.0/tarai2.fsproj.AssemblyReference.cache".
Deleting file "$HOME/workspace/fs/tarai2/obj/Debug/net8.0/tarai2.AssemblyInfoInputs.cache".
Deleting file "$HOME/workspace/fs/tarai2/obj/Debug/net8.0/tarai2.AssemblyInfo.fs".
Deleting file "$HOME/workspace/fs/tarai2/obj/Debug/net8.0/tarai2.fsproj.CoreCompileInputs.cache".
Deleting file "$HOME/workspace/fs/tarai2/obj/Debug/net8.0/tarai2.fsproj.Up2Date".
Deleting file "$HOME/workspace/fs/tarai2/obj/Debug/net8.0/tarai2.dll".
Deleting file "$HOME/workspace/fs/tarai2/obj/Debug/net8.0/refint/tarai2.dll".
Deleting file "$HOME/workspace/fs/tarai2/obj/Debug/net8.0/tarai2.pdb".
Deleting file "$HOME/workspace/fs/tarai2/obj/Debug/net8.0/tarai2.genruntimeconfig.cache".
Deleting file "$HOME/workspace/fs/tarai2/obj/Debug/net8.0/ref/tarai2.dll".
1>Done Building Project "$HOME/workspace/fs/tarai2/tarai2.fsproj" (Clean target(s)).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.75
Determining projects to restore...
All projects are up-to-date for restore.
tarai2 -> $HOME/workspace/fs/tarai2/bin/Release/net8.0/tarai2.dll
tarai2 -> $HOME/workspace/fs/tarai2/bin/Release/net8.0/publish/
15
real:7.01[sec]_user:6.97[sec]_sys:0.02[sec]_Memory:32528[KB]
Felix
tarai2.flx
fun tarai(x:int, y:int, z:int) = {
if (x <= y) do
return y;
done
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y));
};
println $ tarai(15, 5, 0);
$ flx --version
version 2019.01.06
$ flx --clean; flx -O3 tarai2.flx; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] flx -O3 tarai2.flx
Delete cache $HOME/.felix/cache/text
Delete cache $HOME/.felix/cache/binary
Cache may be out of date due to grammar upgrade!
Grammar time stamp =1713770014.000
Automaton.syntax time stamp =BIG BANG
Delete cache $HOME/.felix/cache/text
Delete cache $HOME/.felix/cache/binary
Can't load automaton '$HOME/.felix/cache/binary/usr/local/lib/felix/felix-2019.01.06/share/lib/grammar/grammar.files/syntax.automaton'from disk: building!
Opening syntax extensions $HOME/felix/src/packages/grammar.fdoc: line 4731, cols 1 to 19
Parsed open of syntax extensions felix
Setting automaton
Automaton set
Trying to store automaton $HOME/.felix/cache/binary/usr/local/lib/felix/felix-2019.01.06/share/lib/grammar/grammar.files/syntax.automaton
Saved automaton to disk.
Binding library std
binding library std done
Exports = 0
** BEGIN ** Calculating Function type for function tarai index 78537
15
15
real:3.34[sec]_user:3.32[sec]_sys:0.00[sec]_Memory:23552[KB]
Flix
Wed Jul 31 20:16:58 JST 2024
$
src/Main.flix
def main(): Unit \ IO =
println(tarai(15, 5, 0))
def tarai(x: Int32, y: Int32, z: Int32): Int32 =
if (x <= y) y
else tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
$ sdk use java 22.0.1-oracle
Using java version 22.0.1-oracle in this shell.
$ flix --version
The Flix Programming Language 0.48.0
$ java --version
java 22.0.1 2024-04-16
Java(TM) SE Runtime Environment (build 22.0.1+8-16)
Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)
$ flix build; flix build-jar; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] java -jar artifact/tarai2.jar src/Main.flix
Found `flix.toml`. Checking dependencies...
ANTLR Tool version 4.11.1 used for code generation does not match the current runtime version 4.13.1
ANTLR Runtime version 4.11.1 used for parser compilation does not match the current runtime version 4.13.1
ANTLR Tool version 4.11.1 used for code generation does not match the current runtime version 4.13.1
ANTLR Runtime version 4.11.1 used for parser compilation does not match the current runtime version 4.13.1
Resolving Flix dependencies...
Downloading Flix dependencies...
Resolving Maven dependencies...
Running Maven dependency resolver.
Downloading external jar dependencies...
Dependency resolution completed.
Found `flix.toml`. Checking dependencies...
ANTLR Tool version 4.11.1 used for code generation does not match the current runtime version 4.13.1
ANTLR Runtime version 4.11.1 used for parser compilation does not match the current runtime version 4.13.1
ANTLR Tool version 4.11.1 used for code generation does not match the current runtime version 4.13.1
ANTLR Runtime version 4.11.1 used for parser compilation does not match the current runtime version 4.13.1
Resolving Flix dependencies...
Downloading Flix dependencies...
Resolving Maven dependencies...
Running Maven dependency resolver.
Downloading external jar dependencies...
Dependency resolution completed.
15
real:127.73[sec]_user:128.31[sec]_sys:0.68[sec]_Memory:173264[KB]
Fortran
Sat Jul 6 20:08:32 JST 2024
$ fortran-linter tarai2.f90
$ fprettify tarai2.f90
tarai2.f90
recursive function tarai(x, y, z) result(ret)
integer, intent(in) :: x, y, z
integer :: ret
if (x <= y) then
ret = y
else
ret = tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
end if
end function tarai
program main
use, intrinsic :: iso_fortran_env
integer :: tarai
print *, tarai(15, 5, 0)
end program main
$ gfortran --version
GNU Fortran (Ubuntu 13.2.0-23ubuntu4) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ rm -rf a.out; gfortran -o a.out tarai2.f90; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:12.96[sec]_user:12.95[sec]_sys:0.00[sec]_Memory:1792[KB]
$ rm -rf a.out; gfortran -o a.out -Ofast tarai2.f90; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:3.99[sec]_user:3.98[sec]_sys:0.00[sec]_Memory:1792[KB]
Gauche
Mon Jul 15 12:45:38 JST 2024
$ cljfmt tarai2.scm
tarai2.scm
(define (tarai x y z)
(if (<= x y)
y
(tarai
(tarai (- x 1) y z)
(tarai (- y 1) z x)
(tarai (- z 1) x y))))
(define (main args)
(print (tarai 15 5 0)))
$ gosh -V
Gauche scheme shell, version 0.9.15 [utf-8,pthreads], aarch64-unknown-linux-gnu
(version "0.9.15")
(command "gosh")
(scheme.id gauche)
(languages scheme r5rs r7rs)
(encodings utf-8)
(website "https://practical-scheme.net/gauche")
(build.platform "aarch64-unknown-linux-gnu")
(build.configure)
(scheme.path "/usr/local/share/gauche-0.98/site/lib" "/usr/local/share/gauche-0.98/0.9.15/lib")
(threads pthreads)
(gauche.net.tls mbedtls)
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] gosh tarai2.scm
15
Command exited with non-zero status 70
real:120.25[sec]_user:120.21[sec]_sys:0.00[sec]_Memory:15104[KB]
Gleam
Mon Jul 15 14:30:31 JST 2024
$ gleam format src/tarai2.gleam
src/tarai2.gleam
import gleam/io
pub fn main() {
io.debug(tarai(15, 5, 0))
}
pub fn tarai(x: Int, y: Int, z: Int) -> Int {
case x <= y {
True -> y
_ -> tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
}
}
$ gleam --version
gleam 1.3.2
$ gleam clean; gleam build; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] gleam run
Downloading packages
Downloaded 2 packages in 0.01s
Compiling gleam_stdlib
Compiling gleeunit
Compiling tarai2
Compiled in 2.02s
Compiled in 0.01s
Running tarai2.main
=ERROR REPORT==== 15-Jul-2024::14:30:33.506839 ===
file:path_eval(["$HOME","$HOME/.config/erlang"],".erlang"): illegal operation on a directory
15
real:12.32[sec]_user:12.29[sec]_sys:0.14[sec]_Memory:62452[KB]
Go
Fri Jul 5 13:47:31 JST 2024
$ go fmt
main.go
main.go
package main
import "fmt"
func tarai(x, y, z int) int {
if x <= y {
return y
}
return tarai(tarai(x-1, y, z), tarai(y-1, z, x), tarai(z-1, x, y))
}
func main() {
fmt.Println(tarai(15, 5, 0))
}
$ go version
go version go1.22.5 linux/arm64
$ rm -rf tarai2; go build; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
15
real:6.33[sec]_user:6.33[sec]_sys:0.00[sec]_Memory:1664[KB]
Gravity
Tue Aug 13 15:28:10 JST 2024
$
tarai2.gravity
func tarai(x, y, z) {
if (x <= y) return y;
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y));
}
func main() {
System.print(tarai(15, 5, 0));
}
$ gravity --version
Gravity version 0.8.5 (Aug 13 2024)
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] gravity tarai2.gravity
15
RESULT: NULL (in 219683.5542 ms)
real:219.68[sec]_user:219.62[sec]_sys:0.00[sec]_Memory:2048[KB]
Groovy
Sun Jul 14 09:41:17 JST 2024
$ npm-groovy-lint --fix tarai2.groovy
npm-groovy-lint results in 1 linted files:
┌─────────┬───────────┬─────────────┬─────────────┬─────────────────┐
│ (index) │ Severity │ Total found │ Total fixed │ Total remaining │
├─────────┼───────────┼─────────────┼─────────────┼─────────────────┤
│ 0 │ 'Error' │ 0 │ 0 │ 0 │
│ 1 │ 'Warning' │ 0 │ 0 │ 0 │
│ 2 │ 'Info' │ 0 │ 0 │ 0 │
└─────────┴───────────┴─────────────┴─────────────┴─────────────────┘
tarai2.groovy
int tarai(int x, int y, int z) {
if (x <= y) {
y
}
else {
tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
}
}
public static void main(args) {
println tarai(15, 5, 0)
}
$ sdk use java 22.0.1-oracle
Using java version 22.0.1-oracle in this shell.
$ groovy --version
Groovy Version: 4.0.22 JVM: 22.0.1 Vendor: Oracle Corporation OS: Linux
$ java --version
java 22.0.1 2024-04-16
Java(TM) SE Runtime Environment (build 22.0.1+8-16)
Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] groovy tarai2.groovy
15
real:35.59[sec]_user:39.41[sec]_sys:0.76[sec]_Memory:454056[KB]
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] groovy --compile-static tarai2.groovy
15
real:8.46[sec]_user:12.55[sec]_sys:0.41[sec]_Memory:154196[KB]
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] groovy --type-checked tarai2.groovy
15
real:36.95[sec]_user:42.17[sec]_sys:0.81[sec]_Memory:338200[KB]
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] groovy --compile-static --type-checked tarai2.groovy
15
real:8.73[sec]_user:13.31[sec]_sys:0.44[sec]_Memory:165872[KB]
$ sdk use java 17.0.11-oracle
Using java version 17.0.11-oracle in this shell.
$ groovy --version
Groovy Version: 4.0.22 JVM: 17.0.11 Vendor: Oracle Corporation OS: Linux
$ java --version
java 17.0.11 2024-04-16 LTS
Java(TM) SE Runtime Environment (build 17.0.11+7-LTS-207)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.11+7-LTS-207, mixed mode, sharing)
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] groovy tarai2.groovy
15
real:57.51[sec]_user:63.31[sec]_sys:0.84[sec]_Memory:245224[KB]
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] groovy --compile-static tarai2.groovy
15
real:8.16[sec]_user:14.10[sec]_sys:0.54[sec]_Memory:198964[KB]
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] groovy --type-checked tarai2.groovy
15
real:70.25[sec]_user:78.34[sec]_sys:0.99[sec]_Memory:274872[KB]
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] groovy --compile-static --type-checked tarai2.groovy
15
real:8.44[sec]_user:15.02[sec]_sys:0.63[sec]_Memory:208104[KB]
Haskell
Sat Jul 20 08:35:04 JST 2024
$ fourmolu -i app/Main.hs
app/Main.hs
{-# LANGUAGE TemplateHaskell #-}
module Main where
tarai :: Int -> Int -> Int -> Int
tarai x y z
{-
\| x <= y = y
-}
| x `seq` y `seq` z `seq` x <= y = y
| otherwise = tarai (tarai (x - 1) y z) (tarai (y - 1) z x) (tarai (z - 1) x y)
main :: IO ()
main = print $ tarai 15 5 0
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.10.1
$ cabal clean; cabal build; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] $HOME/workspace/haskell/tarai2/dist-newstyle/build/aarch64-linux/ghc-9.10.1/tarai2-0.1.0.0/x/tarai2/build/tarai2/tarai2
Resolving dependencies...
Build profile: -w ghc-9.10.1 -O1
In order, the following will be built (use -v for more details):
- tarai2-0.1.0.0 (exe:tarai2) (first run)
Configuring executable 'tarai2' for tarai2-0.1.0.0...
Preprocessing executable 'tarai2' for tarai2-0.1.0.0...
Building executable 'tarai2' for tarai2-0.1.0.0...
[1 of 1] Compiling Main ( app/Main.hs, $HOME/workspace/haskell/tarai2/dist-newstyle/build/aarch64-linux/ghc-9.10.1/tarai2-0.1.0.0/x/tarai2/build/tarai2/tarai2-tmp/Main.o )
[2 of 2] Linking $HOME/workspace/haskell/tarai2/dist-newstyle/build/aarch64-linux/ghc-9.10.1/tarai2-0.1.0.0/x/tarai2/build/tarai2/tarai2
15
real:9.48[sec]_user:9.47[sec]_sys:0.00[sec]_Memory:6272[KB]
$ cabal v1-clean; cabal v1-build; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] dist/build/tarai2/tarai2
cleaning...
Resolving dependencies...
Configuring tarai2-0.1.0.0...
Preprocessing executable 'tarai2' for tarai2-0.1.0.0...
Building executable 'tarai2' for tarai2-0.1.0.0...
[1 of 1] Compiling Main ( app/Main.hs, dist/build/tarai2/tarai2-tmp/Main.o )
[2 of 2] Linking dist/build/tarai2/tarai2
15
real:9.47[sec]_user:9.47[sec]_sys:0.00[sec]_Memory:6272[KB]
$ cabal v2-clean; cabal v2-build; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] $HOME/workspace/haskell/tarai2/dist-newstyle/build/aarch64-linux/ghc-9.10.1/tarai2-0.1.0.0/x/tarai2/build/tarai2/tarai2
Resolving dependencies...
Build profile: -w ghc-9.10.1 -O1
In order, the following will be built (use -v for more details):
- tarai2-0.1.0.0 (exe:tarai2) (first run)
Configuring executable 'tarai2' for tarai2-0.1.0.0...
Preprocessing executable 'tarai2' for tarai2-0.1.0.0...
Building executable 'tarai2' for tarai2-0.1.0.0...
[1 of 1] Compiling Main ( app/Main.hs, $HOME/workspace/haskell/tarai2/dist-newstyle/build/aarch64-linux/ghc-9.10.1/tarai2-0.1.0.0/x/tarai2/build/tarai2/tarai2-tmp/Main.o )
[2 of 2] Linking $HOME/workspace/haskell/tarai2/dist-newstyle/build/aarch64-linux/ghc-9.10.1/tarai2-0.1.0.0/x/tarai2/build/tarai2/tarai2
15
real:9.47[sec]_user:9.47[sec]_sys:0.00[sec]_Memory:6272[KB]
Haxe
Sun Jul 14 09:50:15 JST 2024
$ haxelib run formatter -s Tarai2.hx
Formatted 1 files in 0.03 s.
-------------------------
Input lines: 12
Output lines: 12
-------------------------
Tarai2.hx
class Tarai2 {
static function tarai(x:Int, y:Int, z:Int):Int {
if (x <= y)
return y;
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y));
}
static public function main():Void {
trace(tarai(15, 5, 0));
}
}
$ sdk use java 22.0.1-oracle
Using java version 22.0.1-oracle in this shell.
$ haxe --version
4.3.3
$ java --version
java 22.0.1 2024-04-16
Java(TM) SE Runtime Environment (build 22.0.1+8-16)
Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)
$ rm -r Tarai2.jar; haxe --main Tarai2 --jvm Tarai2.jar; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] java -jar Tarai2.jar
Tarai2.hx:9: 15
real:5.84[sec]_user:5.82[sec]_sys:0.02[sec]_Memory:36912[KB]
$ rm -r Tarai2.jar; haxe -D analyzer-optimize --main Tarai2 --jvm Tarai2.jar; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] java -jar Tarai2.jar
Tarai2.hx:9: 15
real:4.85[sec]_user:4.82[sec]_sys:0.03[sec]_Memory:36784[KB]
$ sdk use java 17.0.11-oracle
Using java version 17.0.11-oracle in this shell.
$ haxe --version
4.3.3
$ java --version
java 17.0.11 2024-04-16 LTS
Java(TM) SE Runtime Environment (build 17.0.11+7-LTS-207)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.11+7-LTS-207, mixed mode, sharing)
$ rm -r Tarai2.jar; haxe --main Tarai2 --jvm Tarai2.jar; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] java -jar Tarai2.jar
Tarai2.hx:9: 15
real:4.61[sec]_user:4.58[sec]_sys:0.02[sec]_Memory:35388[KB]
$ rm -r Tarai2.jar; haxe -D analyzer-optimize --main Tarai2 --jvm Tarai2.jar; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] java -jar Tarai2.jar
Tarai2.hx:9: 15
real:4.07[sec]_user:4.04[sec]_sys:0.03[sec]_Memory:35516[KB]
Hy
Sat Jul 27 14:30:23 JST 2024
$ cljfmt tarai2.hy
tarai2.hy
(defn tarai [x y z]
(if (<= x y)
y
(tarai
(tarai (- x 1) y z)
(tarai (- y 1) z x)
(tarai (- z 1) x y))))
(print (tarai 15 5 0))
$ hy --version
hy 0.29.0
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] hy tarai2.hy
15
real:188.38[sec]_user:187.47[sec]_sys:0.74[sec]_Memory:22716[KB]
Idris2
Sat Jul 20 16:00:59 JST 2024
$
tarai2.idr
module Main
tarai : Int -> Int -> Int -> Int
tarai x y z = if x <= y then y else tarai (tarai (x-1) y z) (tarai (y-1) z x) (tarai (z-1) x y)
main : IO ()
main = do
putStrLn $ show $ tarai 15 5 0
$ idris2 --version
Idris 2, version 0.7.0
$ rm -rf build; idris2 tarai2.idr -o a.out; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./build/exec/a.out
15
real:76.96[sec]_user:76.88[sec]_sys:0.05[sec]_Memory:49024[KB]
Inko
Thu Jul 18 20:07:27 JST 2024
$ inko fmt tarai2.inko
tarai2.inko
import std.stdio (STDOUT)
fn tarai(x: Int, y: Int, z: Int) -> Int {
if x <= y {
y
} else {
tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
}
}
class async Main {
fn async main {
STDOUT.new.print(tarai(15, 5, 0).to_string)
}
}
$ inko --version
inko 0.15.0
$ rm -rf build; inko build tarai2.inko; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] build/tarai2
15
real:44.63[sec]_user:44.38[sec]_sys:0.30[sec]_Memory:2560[KB]
$ rm -rf build; inko build --opt balanced tarai2.inko; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] build/tarai2
15
real:44.61[sec]_user:44.43[sec]_sys:0.23[sec]_Memory:2560[KB]
$ rm -rf build; inko build --opt aggressive tarai2.inko; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] build/aggressive/tarai2
15
real:9.84[sec]_user:9.60[sec]_sys:0.28[sec]_Memory:2432[KB]
Java
Sun Jul 14 09:57:40 JST 2024
$ clang-format-18 -i Tarai2.java
Tarai2.java
public class Tarai2 {
static int tarai(int x, int y, int z) {
if (x <= y)
return y;
else
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y));
}
public static void main(String[] args) {
System.out.println(tarai(15, 5, 0));
}
}
$ sdk use java 22.0.1-oracle
Using java version 22.0.1-oracle in this shell.
$ java --version
java 22.0.1 2024-04-16
Java(TM) SE Runtime Environment (build 22.0.1+8-16)
Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] java Tarai2.java
15
real:6.46[sec]_user:7.06[sec]_sys:0.12[sec]_Memory:85816[KB]
$ javac Tarai2.java; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] java Tarai2
15
real:5.78[sec]_user:5.75[sec]_sys:0.03[sec]_Memory:35632[KB]
$ sdk use java 17.0.11-oracle
Using java version 17.0.11-oracle in this shell.
$ java --version
java 17.0.11 2024-04-16 LTS
Java(TM) SE Runtime Environment (build 17.0.11+7-LTS-207)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.11+7-LTS-207, mixed mode, sharing)
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] java Tarai2.java
15
real:5.23[sec]_user:5.83[sec]_sys:0.11[sec]_Memory:81948[KB]
$ javac Tarai2.java; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] java Tarai2
15
real:4.60[sec]_user:4.57[sec]_sys:0.03[sec]_Memory:34688[KB]
Javascript
Sat Jul 27 15:03:46 JST 2024
$ npx prettier tarai2.js --write
tarai2.js 71ms (unchanged)
tarai2.js
function tarai(x, y, z) {
if (x <= y) {
return y;
}
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y));
}
console.log(tarai(15, 5, 0));
$ node --version
v22.5.1
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] node tarai2.js
15
real:19.76[sec]_user:19.74[sec]_sys:0.01[sec]_Memory:50688[KB]
$ deno --version
deno 1.45.4 (release, aarch64-unknown-linux-gnu)
v8 12.7.224.13
typescript 5.5.2
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] deno run tarai2.js
15
real:21.35[sec]_user:21.32[sec]_sys:0.02[sec]_Memory:53336[KB]
$ bun --version
1.1.20
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] bun tarai2.js
15
real:20.02[sec]_user:20.00[sec]_sys:0.01[sec]_Memory:41992[KB]
Julia
$ julia
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 1.10.4 (2024-06-04)
_/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |
julia> using JuliaFormatter
julia> format("tarai2.jl")
true
julia>
Fri Jul 5 15:26:01 JST 2024
tarai2.jl
function tarai(x, y, z)
if x <= y
y
else
tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
end
end
println(tarai(15, 5, 0))
$ julia --version
julia version 1.10.4
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] julia tarai2.jl
15
real:9.22[sec]_user:9.14[sec]_sys:0.14[sec]_Memory:238240[KB]
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] julia -O1 tarai2.jl
15
real:12.76[sec]_user:12.70[sec]_sys:0.12[sec]_Memory:236756[KB]
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] julia -O2 tarai2.jl
15
real:9.14[sec]_user:9.08[sec]_sys:0.13[sec]_Memory:238216[KB]
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] julia -O3 tarai2.jl
15
real:9.18[sec]_user:9.11[sec]_sys:0.13[sec]_Memory:238252[KB]
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] julia -O2 --min-optleve=1 tarai2.jl
15
real:9.27[sec]_user:9.21[sec]_sys:0.13[sec]_Memory:238208[KB]
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] julia -O2 --min-optleve=2 tarai2.jl
15
real:9.19[sec]_user:9.12[sec]_sys:0.14[sec]_Memory:238220[KB]
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] julia -O2 --min-optleve=3 tarai2.jl
15
real:9.29[sec]_user:9.22[sec]_sys:0.14[sec]_Memory:238256[KB]
Koka
tarai2.kk
fun tarai(x: int, y: int, z: int)
if x <= y return y
tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
fun main()
println(tarai(15, 5, 0))
$ koka --version
Koka 3.1.2, 23:10:17 Jun 7 2024 (ghc release version)
version: 3.1.2
bin : /usr/local/bin
lib : /usr/local/lib/koka/v3.1.2
share : /usr/local/share/koka/v3.1.2
output : .koka/v3.1.2/gcc-debug-536eb9
cc : /usr/bin/gcc
Copyright 2019-2024, Microsoft Research, Daan Leijen, and others.
This program is free software; see the source for copying conditions.
This program is distributed in the hope that it will be useful,
but without any warranty; without even the implied warranty
of merchantability or fitness for a particular purpose.
$ koka -c -j4 -O3 -v0 -r tarai2.kk; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] .koka/v3.1.2/gcc-drelease-7e22e4/tarai2__main
compile : kklib from: /usr/local/share/koka/v3.1.2/kklib
In file included from /usr/local/share/koka/v3.1.2/kklib/src/../mimalloc/src/static.c:35,
from /usr/local/share/koka/v3.1.2/kklib/src/all.c:23:
/usr/local/share/koka/v3.1.2/kklib/src/../mimalloc/src/segment.c: In function ‘mi_segment_span_free_coalesce’:
/usr/local/share/koka/v3.1.2/kklib/src/../mimalloc/src/segment.c:664:30: warning: ‘__atomic_load_8’ writing 8 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
664 | const bool is_abandoned = (segment->thread_id == 0); // mi_segment_is_abandoned(segment);
| ^~~~~~~
15
real:10.86[sec]_user:10.85[sec]_sys:0.00[sec]_Memory:1536[KB]
Kotlin
Sun Jul 14 10:02:05 JST 2024
$ ktlint -F Tarai2.kt
Tarai2.kt
fun tarai(
x: Int,
y: Int,
z: Int,
): Int {
if (x <= y) {
return y
}
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
}
fun main() {
println(tarai(15, 5, 0))
}
$ sdk use java 22.0.1-oracle
Using java version 22.0.1-oracle in this shell.
$ kotlin -version
Kotlin version 2.0.0-release-341 (JRE 22.0.1+8-16)
$ java --version
java 22.0.1 2024-04-16
Java(TM) SE Runtime Environment (build 22.0.1+8-16)
Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)
$ rm -rf Tarai2.jar; kotlinc Tarai2.kt -include-runtime -d Tarai2.jar; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] java -jar Tarai2.jar
15
real:5.80[sec]_user:5.78[sec]_sys:0.03[sec]_Memory:37936[KB]
$ sdk use java 17.0.11-oracle
Using java version 17.0.11-oracle in this shell.
$ kotlin -version
Kotlin version 2.0.0-release-341 (JRE 17.0.11+7-LTS-207)
$ java --version
java 17.0.11 2024-04-16 LTS
Java(TM) SE Runtime Environment (build 17.0.11+7-LTS-207)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.11+7-LTS-207, mixed mode, sharing)
$ rm -rf Tarai2.jar; kotlinc Tarai2.kt -include-runtime -d Tarai2.jar; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] java -jar Tarai2.jar
15
real:4.61[sec]_user:4.59[sec]_sys:0.03[sec]_Memory:36540[KB]
LEAN4
Main.lean
import «Tarai2»
def main : IO Unit := do
let stdout ← IO.getStdout
stdout.putStrLn s!"{tarai 15 5 0}"
Tarai2.lean
partial def tarai (x: Int) (y: Int) (z: Int) : Int :=
if x <= y then
y
else
tarai (tarai (x-1) y z) (tarai (y-1) z x) (tarai (z-1) x y)
$ lean --version
Lean (version 4.8.0, aarch64-unknown-linux-gnu, commit df668f00e6c0, Release)
$ lake --version
Lake version 5.0.0-df668f0 (Lean version 4.8.0)
$ lake clean; lake build; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./.lake/build/bin/tarai2
Build completed successfully.
15
real:12.86[sec]_user:12.85[sec]_sys:0.00[sec]_Memory:8704[KB]
Lisp
Mon Jul 22 20:31:53 JST 2024
$
tarai2.lsp
(defun tarai (x y z)
(if (<= x y)
y
(tarai
(tarai (- x 1) y z)
(tarai (- y 1) z x)
(tarai (- z 1) x y))))
(print (tarai 15 5 0))
$ clisp --version
GNU CLISP 2.49.93+ (2018-02-18) (built on bos01-arm64-038.buildd [127.0.1.1])
Software: GNU C 13.2.0
gcc -g -O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/build/clisp-NOdkZY/clisp-2.49.20210628.gitde01f0f=. -fstack-protector --param=ssp-buffer-size=4 -fstack-clash-protection -Wformat -Werror=format-security -mbranch-protection=standard -fdebug-prefix-map=/build/clisp-NOdkZY/clisp-2.49.20210628.gitde01f0f=/usr/src/clisp-1:2.49.20210628.gitde01f0f-3.1build3 -no-integrated-cpp -W -Wswitch -Wcomment -Wpointer-arith -Wreturn-type -Wmissing-declarations -Wimplicit -Wno-sign-compare -Wno-format-nonliteral -Wno-shift-negative-value -O2 -fwrapv -fPIC -fno-strict-aliasing -DNO_ASM -DENABLE_UNICODE -DDYNAMIC_FFI -DDYNAMIC_MODULES -Wl,-Bsymbolic-functions -Wl,-z,relro libgnu.a -lreadline -lncurses -lffcall -lsigsegv -lunistring
SAFETY=0 HEAPCODES ONE_FREE_BIT_HEAPCODES WIDE_HARD SPVW_BLOCKS SPVW_MIXED TRIVIALMAP_MEMORY
libsigsegv 2.14
libreadline 8.2
libffcall 2.4
Features:
(READLINE REGEXP WILDCARD SYSCALLS I18N LOOP COMPILER CLOS MOP CLISP ANSI-CL COMMON-LISP LISP=CL INTERPRETER LOGICAL-PATHNAMES
SOCKETS GENERIC-STREAMS SCREEN FFI GETTEXT UNICODE BASE-CHAR=CHARACTER WORD-SIZE=64 UNIX)
C Modules: (clisp i18n syscalls regexp readline)
Installation directory: /usr/lib/clisp-2.49.93+/
User language: ENGLISH
Machine: AARCH64 (AARCH64) raspberrypi5 [127.0.1.1]
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] clisp tarai2.lsp
15
real:1493.17[sec]_user:1492.78[sec]_sys:0.00[sec]_Memory:9088[KB]
$ rm -rf tarai2.fas; clisp -c tarai2.lsp; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] clisp tarai2.fas
i i i i i i i ooooo o ooooooo ooooo ooooo
I I I I I I I 8 8 8 8 8 o 8 8
I \ `+' / I 8 8 8 8 8 8
\ `-+-' / 8 8 8 ooooo 8oooo
`-__|__-' 8 8 8 8 8
| 8 o 8 8 o 8 8
------+------ ooooo 8oooooo ooo8ooo ooooo 8
Welcome to GNU CLISP 2.49.93+ (2018-02-18) <http://clisp.org/>
Copyright (c) Bruno Haible, Michael Stoll 1992-1993
Copyright (c) Bruno Haible, Marcus Daniels 1994-1997
Copyright (c) Bruno Haible, Pierpaolo Bernardi, Sam Steingold 1998
Copyright (c) Bruno Haible, Sam Steingold 1999-2000
Copyright (c) Sam Steingold, Bruno Haible 2001-2018
Type :h and hit Enter for context help.
;; Compiling file $HOME/workspace/lisp/tarai2/tarai2.lsp ...
;; Wrote file $HOME/workspace/lisp/tarai2/tarai2.fas
0 errors, 0 warnings
Bye.
15
real:217.70[sec]_user:217.64[sec]_sys:0.00[sec]_Memory:8960[KB]
Lisp Flavored Erlang
Wed Jul 24 21:02:32 JST 2024
$
src/tarai2.lfe
(defmodule tarai2
(export (main 1)))
(defun main (_)
(lfe_io:format "~p~n" `(,(tarai 15 5 0)))
(erlang:halt 0))
(defun tarai (x y z)
(if (=< x y)
y
(tarai
(tarai (- x 1) y z)
(tarai (- y 1) z x)
(tarai (- z 1) x y))))
$ rebar3 lfe escriptize; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./_build/default/bin/tarai2
===> Analyzing applications...
===> Compiling zipper
===> Compiling katana_code
===> Compiling ../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl failed
../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl:510:39: syntax error before: 'else'
../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl:655:34: syntax error before: 'else'
../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl:492:30: function quickscan_form/1 undefined
../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl:624:10: function scan_form/2 undefined
../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl:527:1: Warning: function kill_form/1 is unused
../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl:531:1: Warning: function quickscan_macros/1 is unused
../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl:534:1: Warning: function quickscan_macros/2 is unused
../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl:562:1: Warning: function quickscan_macros_1/3 is unused
../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl:570:1: Warning: function quick_macro_atom/1 is unused
../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl:573:1: Warning: function quick_macro_string/1 is unused
../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl:579:1: Warning: function skip_macro_args/1 is unused
../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl:584:1: Warning: function skip_macro_args/3 is unused
../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl:684:1: Warning: function build_info_string/2 is unused
../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl:689:1: Warning: function scan_macros/2 is unused
../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl:692:1: Warning: function scan_macros/3 is unused
../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl:731:1: Warning: function macro/5 is unused
../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl:734:1: Warning: function macro_call/6 is unused
../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl:749:1: Warning: function macro_atom/2 is unused
../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl:757:1: Warning: function parentheses/1 is unused
../../.cache/rebar3/plugins/katana_code/src/ktn_dodger.erl:763:1: Warning: function scan_macros_1/4 is unused
===> Errors loading plugin {rebar3_lint,"0.2.0"}. Run rebar3 with DEBUG=1 set to see errors.
===> Verifying dependencies...
===> Getting log of git repo failed in $HOME/workspace/lfe/tarai2. Falling back to version 0.0.0
===> Analyzing applications...
===> Compiling tarai2
===> Getting log of git repo failed in $HOME/workspace/lfe/tarai2. Falling back to version 0.0.0
===> Getting log of git repo failed in $HOME/workspace/lfe/tarai2. Falling back to version 0.0.0
===> Building escript for tarai2...
15
real:9.44[sec]_user:9.32[sec]_sys:0.26[sec]_Memory:54848[KB]
LiveScript
Fri Aug 16 12:47:47 JST 2024
$
tarai2.ls
tarai = (x, y, z) ->
if x <= y
return y
else
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
console.log tarai(15, 5, 0)
$ lsc --version
LiveScript version 1.6.0
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] lsc tarai2.ls
15
real:20.57[sec]_user:20.55[sec]_sys:0.03[sec]_Memory:57872[KB]
Lobster
Sat Jul 20 15:22:28 JST 2024
$
tarai2.lobster
def tarai(x: int, y: int, z: int) -> int:
if x <= y:
return y
return tarai( tarai(x-1, y, z), tarai(y-1, z, x), tarai(z-1, x, y))
print(tarai(15, 5, 0))
$ rm -rf default.lpak
$ lobster | head
Lobster programming language compiler/runtime (version 2024-07-17T15:17:09-07:00|ea01a900)
no arguments given - cannot load default.lpak
Usage:
lobster [ OPTIONS ] [ FILE ] [ -- ARGS ]
Compile & run FILE, or omit FILE to load default.lpak
--pak Compile to pakfile, don't run.
--cpp Compile to C++ code, don't run (see implementation.md!).
--import RELDIR Additional dir (relative to FILE) to load imports from
--main MAIN if present, run this main program file after compiling FILE.
--parsedump Also dump parse tree.
$ lobster --pak tarai2.lobster; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] lobster --runtime-no-asserts tarai2.lobster
15
real:190.07[sec]_user:190.00[sec]_sys:0.01[sec]_Memory:8644[KB]
$ lobster --pak tarai2.lobster; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] lobster
15
real:190.05[sec]_user:190.00[sec]_sys:0.00[sec]_Memory:8628[KB]
Lua
Mon Jul 22 23:19:52 JST 2024
$ stylua tarai2.lua
tarai2.lua
local function tarai(x, y, z)
if x <= y then
return y
else
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
end
end
print(tarai(15, 5, 0))
$ lua -v
Lua 5.4.6 Copyright (C) 1994-2023 Lua.org, PUC-Rio
$ luajit -v
LuaJIT 2.1.1703358377 -- Copyright (C) 2005-2023 Mike Pall. https://luajit.org/
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] lua tarai2.lua
15
real:90.40[sec]_user:90.37[sec]_sys:0.00[sec]_Memory:2048[KB]
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] luajit tarai2.lua
15
real:21.61[sec]_user:21.61[sec]_sys:0.00[sec]_Memory:1920[KB]
Mercury
tarai2.m
% tarai2.m
:- module tarai2.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module int.
:- func tarai(int, int, int) = int.
tarai(X, Y, Z) = R :-
(
if X =< Y
then R = Y
else R = tarai(tarai(X - 1, Y, Z), tarai(Y - 1, Z, X), tarai(Z - 1, X, Y))
).
main(!IO) :-
io.print(tarai(15, 5, 0), !IO),
io.nl(!IO).
:- end_module tarai2.
$ mmc --version
Mercury Compiler, version 22.01.8, on aarch64-unknown-linux-gnu
Copyright (C) 1993-2012 The University of Melbourne
Copyright (C) 2013-2023 The Mercury team
$ rm -rf a.out; mmc -o a.out tarai2.m; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:4.84[sec]_user:4.82[sec]_sys:0.00[sec]_Memory:5120[KB]
$ rm -rf a.out; mmc -O6 -o a.out tarai2.m; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:4.83[sec]_user:4.83[sec]_sys:0.00[sec]_Memory:5632[KB]
Mojo
Sat Jul 20 13:04:23 JST 2024
$ mojo format tarai2.🔥
All done! ✨ 🍰 ✨
1 file left unchanged.
tarai2.🔥
fn tarai(x: Int, y: Int, z: Int) -> Int:
if x <= y:
return y
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
def main():
print(tarai(15, 5, 0))
$ mojo --version
mojo 24.4.0 (2cb57382)
$ rm -rf ; mojo build -o a.out tarai2.🔥; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:5.78[sec]_user:5.77[sec]_sys:0.00[sec]_Memory:7552[KB]
Nelua
Sun Aug 4 01:38:41 JST 2024
$
tarai2.nelua
require 'math'
do
local function tarai(x: integer, y: integer, z: integer): integer
if x <= y then
return y
end
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
end
print(tarai(15, 5, 0))
end
$ nelua --version
Nelua 0.2.0-dev
Build number: 1617
Git date: 2024-06-16 11:32:57 -0300
Git hash: 4b2c75f8fe5c1d11a966b2fe8974a256868749a6
Semantic version: 0.2.0-dev.1617+4b2c75f8
Copyright (C) 2019-2024 Eduardo Bart (https://nelua.io/)
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] nelua tarai2.nelua
15
real:9.22[sec]_user:9.16[sec]_sys:0.05[sec]_Memory:27264[KB]
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] nelua --release tarai2.nelua
15
real:5.21[sec]_user:5.14[sec]_sys:0.06[sec]_Memory:29184[KB]
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] nelua --maximum-performance tarai2.nelua
15
real:3.78[sec]_user:3.68[sec]_sys:0.09[sec]_Memory:36756[KB]
Nim
Wed Jul 17 20:14:21 JST 2024
$ nimpretty tarai2.nim
tarai2.nim
proc tarai(x: int, y: int, z: int): int =
if x <= y:
return y
return tarai(tarai(x-1, y, z), tarai(y-1, z, x), tarai(z-1, x, y))
echo tarai(15, 5, 0)
$ nim --version
Nim Compiler Version 2.0.8 [Linux: arm64]
Compiled at 2024-07-17
Copyright (c) 2006-2023 by Andreas Rumpf
active boot switches: -d:release
$ rm -rf a.out; nim c -d:release --opt:size --hints:off -o:a.out tarai2.nim; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:9.84[sec]_user:9.84[sec]_sys:0.00[sec]_Memory:1024[KB]
$ rm -rf a.out; nim cpp -d:release --opt:size --hints:off -o:a.out tarai2.nim; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:7.71[sec]_user:7.71[sec]_sys:0.00[sec]_Memory:3072[KB]
$ rm -rf a.out; nim c -d:release --opt:speed --hints:off -o:a.out tarai2.nim; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:8.86[sec]_user:8.86[sec]_sys:0.00[sec]_Memory:1152[KB]
$ rm -rf a.out; nim cpp -d:release --opt:speed --hints:off -o:a.out tarai2.nim; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:6.00[sec]_user:5.99[sec]_sys:0.00[sec]_Memory:3072[KB]
Nit
Sun Aug 4 13:47:08 JST 2024
$
tarai2.nit
fun tarai(x: Int, y: Int, z: Int): Int
do
if x <= y then
return y
else
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
end
end
print tarai(15, 5, 0)
$ nit --version
v0.8-3697-ge8e9cca96
$ rm -rf a.out; nitc -o a.out tarai2.nit; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:7.71[sec]_user:7.71[sec]_sys:0.00[sec]_Memory:2560[KB]
$ rm -rf a.out; nitc --release -o a.out tarai2.nit; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:7.73[sec]_user:7.73[sec]_sys:0.00[sec]_Memory:2560[KB]
$ rm -rf a.out; nitc --no-check-all -o a.out tarai2.nit; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:7.55[sec]_user:7.54[sec]_sys:0.00[sec]_Memory:2560[KB]
OCaml
Sat Jul 20 12:52:39 JST 2024
$ dune fmt
bin/main.ml
let rec tarai x y z =
if x <= y then y
else tarai (tarai (x - 1) y z) (tarai (y - 1) z x) (tarai (z - 1) x y)
let () = Printf.printf "%d\n" (tarai 15 5 0)
$ dune --version
3.16.0
$ ocaml --version
The OCaml toplevel, version 5.2.0
$ dune build; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] dune exec tarai2
15
real:6.66[sec]_user:6.62[sec]_sys:0.02[sec]_Memory:27648[KB]
$ dune build; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./_build/default/bin/main.exe
15
real:6.60[sec]_user:6.59[sec]_sys:0.00[sec]_Memory:2432[KB]
Odin
Sat Jul 20 14:03:50 JST 2024
$
tarai2.odin
package main
import "core:fmt"
tarai :: proc(x: i64, y: i64, z: i64) -> i64 {
if x <= y {
return y
}
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
}
main :: proc() {
fmt.println(tarai(15, 5, 0))
}
$ odin version
odin version dev-2024-07:0bb4cc6ce
$ rm -rf tarai2; odin build tarai2.odin -file; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
15
real:10.94[sec]_user:10.93[sec]_sys:0.00[sec]_Memory:1280[KB]
$ rm -rf tarai2; odin build tarai2.odin -o:speed -file; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
15
real:5.45[sec]_user:5.45[sec]_sys:0.00[sec]_Memory:1152[KB]
$ rm -rf tarai2; odin build tarai2.odin -o:speed -no-bounds-check -file; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
15
real:5.45[sec]_user:5.44[sec]_sys:0.00[sec]_Memory:1152[KB]
$ rm -rf tarai2; odin build tarai2.odin -o:speed -thread-count:4 -file; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
15
real:5.45[sec]_user:5.44[sec]_sys:0.00[sec]_Memory:1152[KB]
$ rm -rf tarai2; odin build tarai2.odin -o:speed -no-bounds-check -thread-count:4 -file; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
15
real:5.45[sec]_user:5.44[sec]_sys:0.00[sec]_Memory:1152[KB]
Onyx
Sat Jul 20 13:59:12 JST 2024
$
tarai2.onyx
use core {*}
tarai :: (x: i64, y: i64, z: i64) -> i64 {
if (x <= y) {
return y
}
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
}
main :: () {
println(tarai(15, 5, 0))
}
$ onyx version
Onyx toolchain version v0.1.12
Runtime: wasmer
Built: Wed Jul 17 21:56:14 2024
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] onyx run tarai2.onyx
15
real:12.66[sec]_user:12.60[sec]_sys:0.09[sec]_Memory:77440[KB]
$ rm -rf out.wasm; onyx build tarai2.onyx; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] onyx run out.wasm
15
real:12.52[sec]_user:12.52[sec]_sys:0.05[sec]_Memory:50304[KB]
Pascal
Tue Jul 9 00:11:36 JST 2024
$ ptop tarai2.pas tarai2.pas
tarai2.pas
Program tarai(output);
Uses sysutils;
Function tarai(x, y, z: integer) : integer;
Begin
If x <= y Then
tarai := y
Else
tarai := tarai(tarai(x-1, y, z), tarai(y-1, z, x), tarai(z-1, x, y))
End;
Begin
writeln(tarai(15, 5, 0));
End.
$ fpc -version
[0.005] Free Pascal Compiler version 3.2.2+dfsg-32 [2024/01/05] for aarch64
[0.005] Copyright (c) 1993-2021 by Florian Klaempfl and others
[0.005] error: No source file name in command line
[0.005] error: Compilation aborted
Error: /usr/bin/ppca64 returned an error exitcode
$ rm -r tarai2; fpc tarai2.pas; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
rm: cannot remove 'tarai2': No such file or directory
Free Pascal Compiler version 3.2.2+dfsg-32 [2024/01/05] for aarch64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Linux for AArch64
Compiling tarai2.pas
Assembling tarai
Linking tarai2
16 lines compiled, 0.2 sec
15
real:12.95[sec]_user:12.95[sec]_sys:0.00[sec]_Memory:384[KB]
$ rm -r tarai2; fpc -O4 tarai2.pas; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
Free Pascal Compiler version 3.2.2+dfsg-32 [2024/01/05] for aarch64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Linux for AArch64
Compiling tarai2.pas
Assembling tarai
Linking tarai2
16 lines compiled, 0.2 sec
15
real:9.41[sec]_user:9.40[sec]_sys:0.00[sec]_Memory:384[KB]
Peregrine
Sun Aug 4 16:01:57 JST 2024
$
tarai2.pe
def tarai(x: int, y: int, z: int) -> int :
if x <= y:
return y
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
def main() :
printf("%d\n", tarai(15, 5, 0))
$ peregrine.elf | head
Peregrine Compiler (C) The Peregrine Organisation, MPL-2.0
Usage: peregrine [command] [options] [file] -o [output file]
Peregrine Commands:
compile - compiles a given file
help - prints out help
Peregrine Options:
-release - create release builds
-debug - create debug builds
$ rm -rf a.out; peregrine.elf compile tarai2.pe -o a.out; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:12.46[sec]_user:12.45[sec]_sys:0.00[sec]_Memory:3200[KB]
$ rm -rf a.out; peregrine.elf compile tarai2.pe -static -o a.out; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:12.43[sec]_user:12.43[sec]_sys:0.00[sec]_Memory:512[KB]
$ rm -rf a.out; peregrine.elf compile tarai2.pe -release -o a.out; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:5.98[sec]_user:5.98[sec]_sys:0.00[sec]_Memory:3200[KB]
$ rm -rf a.out; peregrine.elf compile tarai2.pe -release -static -o a.out; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:6.02[sec]_user:6.02[sec]_sys:0.00[sec]_Memory:512[KB]
Perl
Sat Jul 20 19:57:58 JST 2024
$ perltidy -pbp tarai2.pl | sponge tarai2.pl
tarai2.pl
sub tarai {
local ( $x, $y, $z ) = @_;
return $y if $x <= $y;
tarai(
tarai( $x - 1, $y, $z ),
tarai( $y - 1, $z, $x ),
tarai( $z - 1, $x, $y )
);
}
print tarai( 15, 5, 0 ), "\n";
$ perl --version
This is perl 5, version 40, subversion 0 (v5.40.0) built for aarch64-linux
Copyright 1987-2024, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at https://www.perl.org/, the Perl Home Page.
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] perl tarai2.pl
15
real:1205.21[sec]_user:1204.89[sec]_sys:0.00[sec]_Memory:4480[KB]
Php
Sun Jul 21 08:01:48 JST 2024
$ npx prettier tarai2.php --write
tarai2.php 30ms
tarai2.php
<?php
function tarai($x, $y, $z)
{
if ($x <= $y) {
return $y;
}
return tarai(
tarai($x - 1, $y, $z),
tarai($y - 1, $z, $x),
tarai($z - 1, $x, $y)
);
}
echo tarai(15, 5, 0), "\n";
?>
$ php --version
PHP 8.3.9 (cli) (built: Jul 21 2024 05:51:48) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.9, Copyright (c) Zend Technologies
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] php tarai2.php
15
real:98.05[sec]_user:98.02[sec]_sys:0.00[sec]_Memory:12964[KB]
Pike
tarai2.pike
int tarai(int x, int y, int z)
{
if (x <= y)
return y;
return tarai(tarai(x-1, y, z), tarai(y-1, z, x), tarai(z-1, x, y));
}
int main()
{
write("%d\n", tarai(15, 5, 0));
return 0;
}
$ pike --version
Pike v8.0 release 1738 Copyright © 1994-2022 Linköping University
Pike comes with ABSOLUTELY NO WARRANTY; This is free software and you are
welcome to redistribute it under certain conditions; read the files
COPYING and COPYRIGHT in the Pike distribution for more details.
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] pike tarai2.pike
15
real:259.16[sec]_user:259.09[sec]_sys:0.01[sec]_Memory:6656[KB]
Poly/ML
Wed Jul 24 17:57:00 JST 2024
$
tarai2.ml
fun tarai(x, y, z) =
if x <= y then y
else tarai(tarai((x - 1), y, z), tarai((y - 1), z, x), tarai((z - 1), x, y));
fun main() = print(Int.toString(tarai(15, 5, 0)) ^ "\n");
$ poly -v
Poly/ML 5.9.1 Release RTS version: Arm64-5.9.1 (Git version v5.9.1-64-ga71e81c1)
$ rm -rf a.out; polyc tarai2.ml; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:7.48[sec]_user:7.47[sec]_sys:0.00[sec]_Memory:4608[KB]
Pinecone
Thu Aug 22 19:04:11 JST 2024
$
tarai2.pn
print: tarai: 15, 5, 0
tarai :: {x: Int, y: Int, z: Int} -> {Int}: (
in.x <= in.y ?
out: in.y
|
out: tarai: (tarai: in.x - 1, in.y, in.z), (tarai: in.y - 1, in.z, in.x), (tarai: in.z - 1, in.x, in.y)
out
)
$ pinecone -v
Pinecone version 0.5.1
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] pinecone tarai2.pn
15
real:3236.99[sec]_user:3235.95[sec]_sys:0.04[sec]_Memory:4096[KB]
Pony
Sat Jul 20 13:45:38 JST 2024
$
main.pony
actor Main
fun tarai(x: I32, y: I32, z: I32): I32 =>
if x <= y then
return y
else
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
end
new create(env: Env) =>
env.out.print(tarai(15, 5, 0).string())
$ ponyc --version
0.58.5-da2b0322 [release]
Compiled with: LLVM 15.0.7 -- Clang-18.1.3-aarch64
Defaults: pic=true
$ rm -rf tarai2; ponyc; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
Building builtin -> /usr/local/lib/pony/0.58.5-da2b0322/packages/builtin
Building . -> $HOME/workspace/pony/tarai2
Generating
Reachability
Selector painting
Data prototypes
Data types
Function prototypes
Functions
Descriptors
Verifying
Writing ./tarai2.o
Linking ./tarai2
15
real:6.00[sec]_user:5.98[sec]_sys:0.00[sec]_Memory:2048[KB]
Prolog
tarai2.swi
tarai(X, Y, _, Y) :-
X =< Y, !.
tarai(X, Y, Z, R) :-
X1 is X-1,
Y1 is Y-1,
Z1 is Z-1,
tarai(X1, Y, Z, R1),
tarai(Y1, Z, X, R2),
tarai(Z1, X, Y, R3),
tarai(R1, R2, R3, R).
main :-
tarai(15, 5, 0, R),
!.
$ swipl --version
SWI-Prolog version 9.0.4 for aarch64-linux
$ rm -rf a.out; swipl -O -g main -o a.out -c tarai2.swi; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
Warning: $HOME/workspace/prolog/tarai2/tarai2.swi:12:
Warning: Singleton variables: [R]
% Disabled autoloading (loaded 34 files)
% Disabled autoloading (loaded 0 files)
real:383.11[sec]_user:382.39[sec]_sys:0.24[sec]_Memory:14336[KB]
Python
Sun Jul 21 09:54:43 JST 2024
$ pyenv local 3.12.4; black tarai2.py
All done! ✨ 🍰 ✨
1 file left unchanged.
tarai2.py
def tarai(x: int, y: int, z: int) -> int:
if x <= y:
return y
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
print(tarai(15, 5, 0))
$ pyenv local 3.12.4
$ python --version
Python 3.12.4
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] python tarai2.py
15
real:195.78[sec]_user:195.62[sec]_sys:0.10[sec]_Memory:8960[KB]
$ pypy3 --version
Python 3.9.18 (7.3.15+dfsg-1build3, Mar 31 2024, 07:19:21)
[PyPy 7.3.15 with GCC 13.2.0]
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] pypy3 tarai2.py
15
real:132.17[sec]_user:131.91[sec]_sys:0.10[sec]_Memory:58660[KB]
R
$ R
R version 4.4.1 (2024-06-14) -- "Race for Your Life"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: aarch64-unknown-linux-gnu
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> styler::style_file("tarai2.R")
Styling 1 files:
tarai2.R ✔
────────────────────────────────────────
Status Count Legend
✔ 1 File unchanged.
ℹ 0 File changed.
✖ 0 Styling threw an error.
────────────────────────────────────────
>
Thu Jul 18 13:46:36 JST 2024
$
tarai2.R
tarai <- function(x, y, z) {
force(x)
force(y)
force(z)
if (x <= y) {
return(y)
} else {
return(tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y)))
}
}
print(tarai(15, 5, 0))
$ R --version
R version 4.4.1 (2024-06-14) -- "Race for Your Life"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: aarch64-unknown-linux-gnu
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
https://www.gnu.org/licenses/.
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] Rscript tarai2.R
[1] 15
real:6884.97[sec]_user:6877.15[sec]_sys:0.25[sec]_Memory:67448[KB]
Racket
Sat Jul 20 13:09:17 JST 2024
$ raco fmt -i tarai2.rkt
tarai2.rkt
#lang racket
(define (tarai x y z)
(if (<= x y) y (tarai (tarai (- x 1) y z) (tarai (- y 1) z x) (tarai (- z 1) x y))))
(printf "~a\n" (tarai 15 5 0))
$ racket --version
Welcome to Racket v8.13 [cs].
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] racket tarai2.rkt
15
real:10.55[sec]_user:10.27[sec]_sys:0.25[sec]_Memory:103360[KB]
$ rm -rf tarai2; raco exe tarai2.rkt; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
15
real:10.55[sec]_user:10.34[sec]_sys:0.20[sec]_Memory:142428[KB]
$ rm -rf compiled; raco make tarai2.rkt; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] racket ./compiled/tarai2_rkt.zo
15
real:10.54[sec]_user:10.26[sec]_sys:0.26[sec]_Memory:103264[KB]
Raku
tarai2.p6
sub tarai($x, $y, $z) {
if $x <= $y {
return $y;
}
return tarai( tarai($x-1, $y, $z), tarai($y-1, $z, $x), tarai($z-1, $x, $y));
}
say tarai(15, 5, 0);
$ raku --version
Welcome to Rakudo™ v2022.12.
Implementing the Raku® Programming Language v6.d.
Built on MoarVM version 2022.12.
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] raku tarai2.p6
15
real:1100.15[sec]_user:1100.20[sec]_sys:0.03[sec]_Memory:118256[KB]
Reason
Sat Jul 20 13:54:08 JST 2024
$ refmt --in-place bin/main.re
bin/main.re
let rec tarai = (x: int, y: int, z: int) =>
if (x <= y) {
y;
} else {
tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y));
};
let () = {
Printf.printf("%d\n", tarai(15, 5, 0));
};
$ dune --version
3.16.0
$ refmt --version
Reason 3.11.0 @
$ dune build; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] dune exec tarai2
15
real:6.66[sec]_user:6.63[sec]_sys:0.02[sec]_Memory:27648[KB]
$ dune build; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./_build/default/bin/main.exe
15
real:6.60[sec]_user:6.60[sec]_sys:0.00[sec]_Memory:2432[KB]
Ring
Mon Aug 26 08:55:55 JST 2024
$
tarai2.ring
print("#{tarai(15, 5, 0)}\n")
func tarai(x, y, z) {
if x <= y
return y
else
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
ok
}
$ ring | head
===========================================================================
Ring version 1.21
2013-2024, Mahmoud Fayed <msfclipper@yahoo.com>
Usage : ring filename.ring [Options]
===========================================================================
-tokens : Print a list of tokens in the source code file
-rules : Print grammar rules applied on the tokens
-ic : Print the intermediate byte code (before execution)
-icfinal : Print the final byte code (after execution)
-cgi : Print http response header before error messages
$ rm -rf tarai2; ring2exe tarai2.ring -static; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
Ring2EXE: Process File : tarai2.ring
Ring2EXE: Start building the application...
Ring2EXE: Generate C source code file...
Ring2EXE: Generation Time : 0.00 seconds...
Ring2EXE: Generate batch|script file...
Ring2EXE: Generate batch|script file for static building...
Ring2EXE: Build the Executable File...
Ring2EXE: End of building script...
Ring2EXE: Executable file is ready!
Ring2EXE: End of building process...
Ring2EXE: Clear Temp. Files...
15
real:3447.47[sec]_user:3446.52[sec]_sys:0.01[sec]_Memory:13568[KB]
Ruby
tarai2.rb
def tarai(x, y, z)
if x <= y then
return y
end
return tarai(tarai(x-1, y, z), tarai(y-1, z, x), tarai(z-1, x, y))
end
puts( tarai(15, 5, 0) )
$ rbenv local system
$ ruby --version
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [aarch64-linux-gnu]
$ rbenv local 3.3.0
$ ruby --version
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [aarch64-linux]
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ruby --yjit tarai2.rb
15
real:28.79[sec]_user:28.65[sec]_sys:0.06[sec]_Memory:12800[KB]
Rune
Mon Aug 26 19:33:07 JST 2024
$ target/release/rune fmt scripts/tarai2.rn
scripts/tarai2.rn
fn tarai(x, y, z) {
if x <= y {
y
} else {
tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
}
}
dbg!(tarai(15, 5, 0));
$ target/release/rune help | head
The Rune Language Interpreter git-812da733
Usage: rune [OPTIONS] [COMMAND]
Commands:
check Run checks but do not execute
doc Build documentation
ace Build ace autocompletion
test Run all tests but do not execute
bench Run the given program as a benchmark
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] target/release/rune run scripts/tarai2.rn
15
real:483.17[sec]_user:483.03[sec]_sys:0.00[sec]_Memory:15908[KB]
Rust
Sat Jul 27 14:43:35 JST 2024
$ cargo fmt
src/main.rs
fn tarai(x: isize, y: isize, z: isize) -> isize {
if x <= y {
return y;
}
tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
}
fn main() {
println!("{}", tarai(15, 5, 0));
}
$ rustc --version
rustc 1.80.0 (051478957 2024-07-21)
$ cargo clean; cargo build --release; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./target/release/tarai2
Removed 11 files, 863.3KiB total
Compiling tarai2 v0.1.0 ($HOME/workspace/rust/tarai2)
Finished `release` profile [optimized] target(s) in 0.30s
15
real:5.74[sec]_user:5.74[sec]_sys:0.00[sec]_Memory:1536[KB]
Scala
Sun Jul 14 10:10:00 JST 2024
$ sbt scalafmtAll
[info] welcome to sbt 1.10.0 (Oracle Corporation Java 23-ea)
[info] loading settings for project tarai2-build from plugins.sbt ...
[info] loading project definition from $HOME/workspace/scala/tarai2/project
[info] loading settings for project tarai2 from build.sbt ...
[info] set current project to tarai2 (in build file:$HOME/workspace/scala/tarai2/)
[info] scalafmt: Formatting 1 Scala sources ($HOME/workspace/scala/tarai2)...
[success] Total time: 3 s, completed Jul 14, 2024, 10:10:11 AM
./src/main/scala/Tarai2.scala
object Tarai2 {
def tarai(x: Int, y: Int, z: Int): Int = {
if (x <= y) y
else tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
}
def main(args: Array[String]): Unit = {
println(tarai(15, 5, 0))
}
}
$ sdk use java 22.0.1-oracle
Using java version 22.0.1-oracle in this shell.
$ scala --version
Scala code runner version 3.4.2 -- Copyright 2002-2024, LAMP/EPFL
$ sbt --version
sbt script version: 1.10.0
$ java --version
java 22.0.1 2024-04-16
Java(TM) SE Runtime Environment (build 22.0.1+8-16)
Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] scala ./src/main/scala/Tarai2.scala
15
real:9.27[sec]_user:16.58[sec]_sys:0.59[sec]_Memory:214500[KB]
$ sbt clean; sbt assembly; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] java -jar ./target/scala-3.4.2/tarai2-assembly-0.1.0-SNAPSHOT.jar
[info] welcome to sbt 1.10.0 (Oracle Corporation Java 22.0.1)
[info] loading settings for project tarai2-build from plugins.sbt ...
[info] loading project definition from $HOME/workspace/scala/tarai2/project
[info] loading settings for project tarai2 from build.sbt ...
[info] set current project to tarai2 (in build file:$HOME/workspace/scala/tarai2/)
[success] Total time: 0 s, completed Jul 14, 2024, 10:10:39 AM
[info] welcome to sbt 1.10.0 (Oracle Corporation Java 22.0.1)
[info] loading settings for project tarai2-build from plugins.sbt ...
[info] loading project definition from $HOME/workspace/scala/tarai2/project
[info] loading settings for project tarai2 from build.sbt ...
[info] set current project to tarai2 (in build file:$HOME/workspace/scala/tarai2/)
[info] compiling 1 Scala source to $HOME/workspace/scala/tarai2/target/scala-3.4.2/classes ...
[info] 2 file(s) merged using strategy 'Rename' (Run the task at debug level to see the details)
[info] 2 file(s) merged using strategy 'Discard' (Run the task at debug level to see the details)
[info] Built: $HOME/workspace/scala/tarai2/target/scala-3.4.2/tarai2-assembly-0.1.0-SNAPSHOT.jar
[info] Jar hash: 024717ae4d802c0588408df91586ffa29e8abda8
[success] Total time: 9 s, completed Jul 14, 2024, 10:10:57 AM
15
real:4.84[sec]_user:4.88[sec]_sys:0.04[sec]_Memory:50096[KB]
$ sdk use java 17.0.11-oracle
Using java version 17.0.11-oracle in this shell.
$ scala --version
Scala code runner version 3.4.2 -- Copyright 2002-2024, LAMP/EPFL
$ sbt --version
sbt version in this project: 1.10.0
sbt script version: 1.10.0
$ java --version
java 17.0.11 2024-04-16 LTS
Java(TM) SE Runtime Environment (build 17.0.11+7-LTS-207)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.11+7-LTS-207, mixed mode, sharing)
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] scala ./src/main/scala/Tarai2.scala
15
real:8.90[sec]_user:16.36[sec]_sys:0.65[sec]_Memory:217304[KB]
$ sbt clean; sbt assembly; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] java -jar ./target/scala-3.4.2/tarai2-assembly-0.1.0-SNAPSHOT.jar
[info] welcome to sbt 1.10.0 (Oracle Corporation Java 17.0.11)
[info] loading settings for project tarai2-build from plugins.sbt ...
[info] loading project definition from $HOME/workspace/scala/tarai2/project
[info] loading settings for project tarai2 from build.sbt ...
[info] set current project to tarai2 (in build file:$HOME/workspace/scala/tarai2/)
[success] Total time: 0 s, completed Jul 14, 2024, 10:11:29 AM
[info] welcome to sbt 1.10.0 (Oracle Corporation Java 17.0.11)
[info] loading settings for project tarai2-build from plugins.sbt ...
[info] loading project definition from $HOME/workspace/scala/tarai2/project
[info] loading settings for project tarai2 from build.sbt ...
[info] set current project to tarai2 (in build file:$HOME/workspace/scala/tarai2/)
[info] compiling 1 Scala source to $HOME/workspace/scala/tarai2/target/scala-3.4.2/classes ...
[info] 2 file(s) merged using strategy 'Rename' (Run the task at debug level to see the details)
[info] 2 file(s) merged using strategy 'Discard' (Run the task at debug level to see the details)
[info] Built: $HOME/workspace/scala/tarai2/target/scala-3.4.2/tarai2-assembly-0.1.0-SNAPSHOT.jar
[info] Jar hash: 024717ae4d802c0588408df91586ffa29e8abda8
[success] Total time: 9 s, completed Jul 14, 2024, 10:11:46 AM
15
real:4.51[sec]_user:4.55[sec]_sys:0.05[sec]_Memory:48700[KB]
Seed7
tarai2.sd7
$ include "seed7_05.s7i";
const func integer: tarai(in integer: x, in integer: y, in integer: z) is func
result
var integer: r is y;
begin
if x <= y then
r := y;
else
r := tarai(tarai(x-1, y, z), tarai(y-1, z, x), tarai(z-1, x, y));
end if;
end func;
const proc: main is func
begin
writeln(tarai(15, 5, 0));
end func;
$ s7c -?
SEED7 COMPILER Version 3.2.50 Copyright (c) 1990-2023 Thomas Mertes
usage: s7c [options] source
Options:
-? Write Seed7 compiler usage.
-On Tell the C compiler to optimize with level n (n is between 1 and 3).
-O Equivalent to -O1
-S Specify the stack size of the executable (e.g.: -S 16777216).
-b Specify the directory of the Seed7 runtime libraries (e.g.: -b ../bin).
-c Specify configuration (C compiler, etc.) to be used (e.g.: -c emcc).
-e Generate code which sends a signal, if an uncaught exception occurs.
This option allows debuggers to handle uncaught Seed7 exceptions.
-flto Enable link time optimization.
-g Tell the C compiler to generate an executable with debug information.
This way the debugger will refer to Seed7 source files and line numbers.
To generate debug information which refers to the temporary C program
the option -g-debug_c can be used.
-l Add a directory to the include library search path (e.g.: -l ../lib).
-ocn Optimize generated C code with level n. E.g.: -oc3
The level n is a digit between 0 and 3:
0 Do no optimizations with constants.
1 Use literals and named constants to simplify expressions (default).
2 Evaluate constant parameter expressions to simplify expressions.
3 Like -oc2 and additionally evaluate all constant expressions.
-p Activate simple function profiling.
-sx Suppress checks specified with x. E.g.: -sr or -sro
The checks x are specified with letters from the following list:
d Suppress the generation of checks for integer division by zero.
i Suppress the generation of index checks (e.g. string, array).
o Suppress the generation of integer overflow checks.
r Suppress the generation of range checks.
-tx Set runtime trace level to x. Where x is a string consisting of:
d Trace dynamic calls
e Trace exceptions and handlers
f Trace functions
s Trace signals
-wn Specify warning level n. E.g.: -w2
The level n is a digit between 0 and 2:
0 Omit warnings.
1 Write normal warnings (default).
2 Write warnings for raised exceptions.
$ rm -rf tarai2; s7c tarai2.sd7; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
SEED7 COMPILER Version 3.2.50 Copyright (c) 1990-2023 Thomas Mertes
Source: tarai2.sd7
Compiling the program ...
Generating code ...
after walk_const_list
662 declarations processed
131 optimizations done
96 evaluations done
1 division checks inserted
34 range checks inserted
89 index checks inserted
95 overflow checks inserted
Calling the C compiler ...
gcc -w -ffunction-sections -fdata-sections -c tmp_tarai2.c 2>tmp_tarai2.cerrs >/dev/null
Calling the linker ...
gcc -Wl\,--strip-debug -Wl\,--gc-sections -o tarai2 tmp_tarai2.o $HOME/seed7-Seed7_release_2024-04-29/bin/s7_data.a $HOME/seed7-Seed7_release_2024-04-29/bin/seed7_05.a 2>tmp_tarai2.lerrs >/dev/null
15
real:11.86[sec]_user:11.86[sec]_sys:0.00[sec]_Memory:1024[KB]
$ rm -rf tarai2; s7c -O3 tarai2.sd7; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
SEED7 COMPILER Version 3.2.50 Copyright (c) 1990-2023 Thomas Mertes
Source: tarai2.sd7
Compiling the program ...
Generating code ...
after walk_const_list
662 declarations processed
131 optimizations done
96 evaluations done
1 division checks inserted
34 range checks inserted
89 index checks inserted
95 overflow checks inserted
Calling the C compiler ...
gcc -w -O3 -ffunction-sections -fdata-sections -c tmp_tarai2.c 2>tmp_tarai2.cerrs >/dev/null
Calling the linker ...
gcc -Wl\,--strip-debug -Wl\,--gc-sections -o tarai2 tmp_tarai2.o $HOME/seed7-Seed7_release_2024-04-29/bin/s7_data.a $HOME/seed7-Seed7_release_2024-04-29/bin/seed7_05.a 2>tmp_tarai2.lerrs >/dev/null
15
real:6.09[sec]_user:6.09[sec]_sys:0.00[sec]_Memory:1024[KB]
$ rm -rf tarai2; s7c -O3 -oc3 tarai2.sd7; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
SEED7 COMPILER Version 3.2.50 Copyright (c) 1990-2023 Thomas Mertes
Source: tarai2.sd7
Compiling the program ...
Generating code ...
after walk_const_list
662 declarations processed
246 optimizations done
47 functions inlined
284 evaluations done
1 division checks inserted
30 range checks inserted
3 range checks optimized away
99 index checks inserted
2 index checks optimized away
83 overflow checks inserted
8 overflow checks optimized away
Calling the C compiler ...
gcc -w -O3 -ffunction-sections -fdata-sections -c tmp_tarai2.c 2>tmp_tarai2.cerrs >/dev/null
Calling the linker ...
gcc -Wl\,--strip-debug -Wl\,--gc-sections -o tarai2 tmp_tarai2.o $HOME/seed7-Seed7_release_2024-04-29/bin/s7_data.a $HOME/seed7-Seed7_release_2024-04-29/bin/seed7_05.a 2>tmp_tarai2.lerrs >/dev/null
15
real:5.95[sec]_user:5.95[sec]_sys:0.00[sec]_Memory:1024[KB]
Sidef
tarai2.sf
func tarai(x, y, z) {
if (x <= y) {
return y
}
return tarai(tarai(x-1, y, z), tarai(y-1, z, x), tarai(z-1, x, y))
}
say tarai(15, 5, 0)
$ sidef --version
Sidef 24.05
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] sidef -O2 tarai2.sf
15
real:30761.01[sec]_user:30760.98[sec]_sys:0.00[sec]_Memory:49152[KB]
Swift
Thu Jul 18 22:21:09 JST 2024
$ swift-format -i Sources/main.swift
Sources/main.swift
func tarai(x: Int, y: Int, z: Int) -> Int {
if x <= y {
return y
} else {
return tarai(
x: tarai(x: x - 1, y: y, z: z), y: tarai(x: y - 1, y: z, z: x), z: tarai(x: z - 1, y: x, z: y)
)
}
}
print(tarai(x: 15, y: 5, z: 0))
$ swift --version
Swift version 5.10.1 (swift-5.10.1-RELEASE)
Target: aarch64-unknown-linux-gnu
$ rm -rf a.out; swiftc -o a.out Sources/main.swift; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:17.32[sec]_user:17.31[sec]_sys:0.00[sec]_Memory:8064[KB]
$ rm -rf a.out; swiftc -O -o a.out Sources/main.swift; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:5.94[sec]_user:5.94[sec]_sys:0.00[sec]_Memory:7808[KB]
$ rm -rf a.out; swiftc -Ounchecked -o a.out Sources/main.swift; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:6.23[sec]_user:6.23[sec]_sys:0.00[sec]_Memory:7808[KB]
$ swift build -c release --static-swift-stdlib; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] swift run --skip-build
Building for production...
[5/5] Linking tarai2
Build complete! (1.35s)
15
real:17.84[sec]_user:17.58[sec]_sys:0.24[sec]_Memory:96000[KB]
V
Sat Jul 27 16:07:43 JST 2024
$ v fmt -w tarai2.v
Already formatted file: $HOME/workspace/v/tarai2/tarai2.v
tarai2.v
fn tarai(x int, y int, z int) int {
if x <= y {
return y
}
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y))
}
fn main() {
println(tarai(15, 5, 0))
}
$ v --version
V 0.4.7 52fe7c0
$ \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] v run tarai2.v
15
real:22.48[sec]_user:22.46[sec]_sys:0.06[sec]_Memory:45864[KB]
$ rm -rf a.out; v -prod -cc gcc -skip-unused -manualfree -prealloc -gc none -no-bounds-checking -o a.out tarai2.v; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:3.46[sec]_user:3.46[sec]_sys:0.00[sec]_Memory:1024[KB]
$ rm -rf a.out; v -prod -cc clang-18 -skip-unused -manualfree -prealloc -gc none -no-bounds-checking -o a.out tarai2.v; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:5.88[sec]_user:5.87[sec]_sys:0.00[sec]_Memory:1024[KB]
Vala
Sat Jul 20 05:11:43 JST 2024
$ io.elementary.vala-lint --fix tarai2.vala
No mistakes found
tarai2.vala
int tarai (int x, int y, int z) {
if (x <= y) return y;
else return tarai (tarai (x - 1, y, z), tarai (y - 1, z, x), tarai (z - 1, x, y));
}
void main () {
print ("%d\n", tarai (15, 5, 0));
}
$ valac --version
Vala 0.56.16
$ rm -rf a.out; valac -o a.out tarai2.vala; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./a.out
15
real:11.63[sec]_user:11.63[sec]_sys:0.00[sec]_Memory:2432[KB]
Zig
Sat Jul 20 12:58:08 JST 2024
$ zig fmt tarai2.zig
tarai2.zig
const std = @import("std");
fn tarai(x: i32, y: i32, z: i32) i32 {
if (x <= y) {
return y;
}
return tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y));
}
pub fn main() !void {
const stdout = std.io.getStdOut().writer();
try stdout.print("{d}\n", .{
tarai(15, 5, 0),
});
}
$ zig version
0.13.0
$ rm -rf tarai2; zig build-exe tarai2.zig; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
15
real:11.76[sec]_user:11.76[sec]_sys:0.00[sec]_Memory:384[KB]
$ rm -rf tarai2; zig build-exe -OReleaseFast tarai2.zig; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
15
real:5.73[sec]_user:5.73[sec]_sys:0.00[sec]_Memory:256[KB]
$ rm -rf tarai2; zig build-exe -OReleaseSafe tarai2.zig; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
15
real:5.16[sec]_user:5.15[sec]_sys:0.00[sec]_Memory:256[KB]
$ rm -rf tarai2; zig build-exe -OReleaseSmall tarai2.zig; \time -o /dev/stdout -f real:%e[sec]_user:%U[sec]_sys:%S[sec]_Memory:%M[KB] ./tarai2
15
real:6.08[sec]_user:6.08[sec]_sys:0.00[sec]_Memory:256[KB]
あれこれ
- 色々間違い、思い違いがあると思います。ご指摘ください。
- 新しい Java に言語が対応していないことがあるので、Early Access の使用をやめ、Java 22.0.1 にしました。