Not to go on a rant but I am really quite gobsmacked by the slow performance of Xojo.
As many of you know, I’ve been working on a Python-like programming language for a couple of years, written in Xojo. It started off as a tree-walking interpreter called Roo and currently it’s been renamed to Possum and uses a stack-based bytecode. I have finally got Possum to the stage that it can call functions and handle local and global variables.
Excitedly, I thought I would now test Possum’s speed against Roo with a simple (albeit heinously inefficient) fibonacci test:
function fib(n):
if n < 2 then return n
return fib(n - 1) + fib(n - 2)
print(fib(28))
For both implementations this prints the correct answer (9227465). What depressed me was that Roo took about 60 seconds and Possum about 50 seconds.
Whilst both of these implementations are really slow, I was surprised to see how little improvement Possum had made over Roo. Possum runs as close to the metal as I can get it.
Curious, I did a test to compare a barebones Xojo console application against Swift and Python to see how fast they are. Here’s the Xojo application code:
Function Fib(n As Integer) As Integer
If n < 2 Then Return n
Return Fib(n - 1) + Fib(n - 2)
End Function
In App.Run
:
Print(Fib(35).ToString)
This takes 6 seconds as a compiled console application on a 2017 MacBook Pro.
Compare this to Swift (0.5 seconds) and Python (5 seconds).
How the f**k is Xojo slower than Python 3??
For completeness, here’s the Swift code:
import Foundation
func fib(_ n: Int) -> Int {
if n < 2 {
return n
} else {
return fib(n - 1) + fib(n - 2)
}
}
print(fib(35))
and here’s the Python script:
from __future__ import print_function
def fib(n):
if n < 2: return n
return fib(n - 1) + fib(n - 2)
print(fib(35))