I'm not much experienced in programming, but I know a little Python3, and now I'm taking my first baby steps to learn Pharo. I'm still not familiar with object-oriented programming, or the class browser, but I already went though ProfStef tutorial and I'm toying with small programs on Playground, to get familiar with the syntax.
One of the first things I was curious about, was how the two languages compare in terms of speed, as I read somewhere that Pharo has a JIT compiler built in. So I wrote a little whimsical script in both languages, that generates 8 million numbers, filters 1/3 of them, calculates 1/sqrt(x) for each, sum the results, and repeats the process one hundred times, changing the intervals slightly every time, summing the results again in the end, and timed the whole process. Not a proper benchmark, just a exercise to get a order of magnitude estimate, but I tried to keep both versions as similar as possible.
Python 3 version:
import time, math
mega = lambda n: sum([1/math.sqrt(1 + i + n) for i in range(8000000) if (i + 1) // 3 == 0])
start = time.time()
print(sum([mega(n + 1) for n in range(100)]))
stop = time.time() - start
print(stop)
Results with Python 3.8.5 (default, Jul 28 2020, 12:59:40):
34.7701230607214
52.75216603279114
Pharo 8 version:
| mega range start stop |.
range := [:n | (((1 to: 8000000) select: [:j | (j quo: 3) = 0]) collect: [:i | 1 / (n + i) sqrt]) sum].
start := DateAndTime now.
Transcript show: (((1 to: 100) collect: [:n | range value: n]) sum); cr.
stop := (DateAndTime now - start) asSeconds.
Transcript show: stop; cr.
Results on Pharo-8.0.0+build.1141.sha.1b7a8d8203fce2a57794451f555bba4222614081 (64 Bit):
34.7701230607214
45
As I expected, the Pharo version ran faster, but not by a large margin, 45 seconds against a bit over 52 seconds for Python. It took about 13% less time. So I guess their speed are about the same order of magnitude. Is this the typical situation?