Originally published in the article A Python Substitute? I Tried Out the Best Programming Language You’ve Never Heard Of.
In this experiment I compared speed of execution of a program to print the n-th Fibonacci number.
The goal was to test the speed of Nim against Python and C, with Go being added later.
1. Make sure you have the "languages" installed before you try to run these programs.
- Download Python
- Download Go
- Get Nim
- Download GCC (C Compiler)
2. Compile the files that need to be compiled.
Nim:
nim c fibonacci.nim
Go:
go build fibonacci.go -o fib
C:
gcc fibonacci.c
3. Run and time the programs
To time the programs I used the time
command in Bash. The first run of each program after system startup should be discarded, and we're interested in the "real" time.
Nim:
time ./fibonacci
Go:
time ./fib
C:
time ./a.out
Python:
time python3 fibonacci.py