Hmm, also I’m getting very different results from you?
╰─➤ echo -n "\nElixir: "; elixir -e 'IO.puts(Tester.test())'; echo -n "\nGo: "; ./test_go; echo -n "\nOCaml: "; ./test_ml; echo
Elixir: 6335.006
Go: 12091.954
OCaml: 28248.52685
╰─➤ cat test.ex
defmodule Tester do
@interval 20
def test() do
start = System.system_time()
test(start + (@interval * 1000000000), 0)
end
defp test(en, n) do
if System.system_time() >= en do
n / (@interval * 1000)
else
test(en, n+1)
end
end
end
╰─➤ cat test.go
package main
import (
"time"
"fmt"
)
func main() {
interval := int32(20)
start := int32(time.Now().Unix())
n := 0
for {
if start + interval < int32(time.Now().Unix()) {
break
}
n += 1
}
fmt.Println(float32(n) / float32(interval * 1000))
}
╰─➤ cat test.ml
let rec looper en n =
if Unix.time () >= en
then n
else looper en (n + 1)
let _ =
let count = looper (Unix.time () +. 20.0) 0 in
print_float ((float_of_int count) /. (20.0 *. 1000.0))
The go version does not time as accurately either (only second resolution, which could skew it’s results a bit against it I think, but not enough to matter much here). But really, why is go looking so slow compared to another immutable functional language like OCaml? Is there some way to compile it in a ‘release’ mode or something? o.O
(/me would choose OCaml over Go for non-multithreaded work any day, and would choose MC-OCaml over Go for multi-threaded work any day, Go is a poor language, especially in its verbosity)


















