No citation needed as long as you understand both languages' runtime stack.
Python is an interpreted language that runs on top of a virtual machine (usually CPython). Types are determined at run time.
.py -> .pyo* (bytecode) -> VM -> OS
On the other hand, Go (and other C languages) have a different runtime stack:
.go -> binary* -> OS
Between source and binary are a bunch of compiler steps[0], but * is where both binaries are executed. Statically compiled languages do not have to determine types at runtime and therefore are able to optimize code paths much better.
Still don't believe me? Here's a Fibonacci calculation micro benchmark[1] I ran:
╭─ting@noa /tmp/fib ‹python-2.7.3› ‹ruby-1.9.3›
╰─➤ time ./go
1346269
real 0.02s
user 0.01s
sys 0.00s
╭─ting@noa /tmp/fib ‹python-2.7.3› ‹ruby-1.9.3›
╰─➤ time python3 ./fib.py
1346269
real 0.61s
user 0.60s
sys 0.00s
Sidenote:
Java runs on a virtual machine (JVM) but it's performance comes very close to C languages due to static typing, JIT compilation, and heavy investment in the JVM from many companies.
[0]: For C, compilation goes through these steps:
hello.c
(preprocessor)
hello.tmp
(compiler)
hello.s
(assembler)
hello.o
(linker)
hello <-- binary to run
I tend to get pedantic about it given my background in compiler design.
I find sad that young generations mix languages with implementations and get wrong concepts that a certain language can only be implemented in a specific way.
> I find sad that young generations mix languages with implementations and get wrong concepts that a certain language can only be implemented in a specific way.
Yes, but the parent that you responded to wasn't really susceptible to this. It's quite natural to speak of the "performance properties of Language X" as if you were to say, "the performance properties of the most widely used implementation of Language X."
English doesn't lend itself well to precision. Therefore, people rely on the ability of others to use contextual clues to infer assumptions.
It's pretty clear in this case what point the parent was trying to convey.
And I'm not sure what youth has to do with any of this.
> And I'm not sure what youth has to do with any of this.
I am already old enough to have coded Z80 assembly back in the day and I see this mix of languages and implementations mostly around youth wannabe programmers.
And I have seen the "mix up" (if you can even call it that) among all programmers. Mostly for the reasons that I've already outlined. (i.e., there may not be a mix up if people are relying on their readers to infer assumptions through context.)
Dynamically-typed languages can be fast when run with a jit -- for example, Lua+luajit is close to Go in your microbenchmark. On my computer, for n=40, Go is 0m2.156s and luajit is 0m3.199s.
Thanks for the extra results. Obviously, a single micro-benchmark will only take you so far (and something like the Computer Language Shootout gets you farther -- it's a shame and mystifying (to me) that that site no longer has results for LuaJIT...).
But anyway, in my (limited) experimentations with LuaJIT, it's often been within a factor of 2x-3x of speed of C, which to me is pretty fast, and typical of many statically-typed, compiled languages.
I'm curious what times you get with an iterative version, or at least using a LUT. As-is, this mostly benchmarks the stack (admittedly that is an interesting datapoint.)
I don't know if anyone will ever read this thread again :), but just in case, the the current front-page post on Julia provides another nice example of a fast, dynamically-typed, JITed language (within 1-2x of C, from their own set of benchmarks).
Python is an interpreted language that runs on top of a virtual machine (usually CPython). Types are determined at run time.
On the other hand, Go (and other C languages) have a different runtime stack: Between source and binary are a bunch of compiler steps[0], but * is where both binaries are executed. Statically compiled languages do not have to determine types at runtime and therefore are able to optimize code paths much better.Still don't believe me? Here's a Fibonacci calculation micro benchmark[1] I ran:
Sidenote:Java runs on a virtual machine (JVM) but it's performance comes very close to C languages due to static typing, JIT compilation, and heavy investment in the JVM from many companies.
[0]: For C, compilation goes through these steps:
[1]: https://gist.github.com/wting/77c9742fa1169179235f