r/ProgrammingLanguages • u/elemenity • Mar 04 '26
Comparing Scripting Language Speed
https://www.emulationonline.com/posts/comparing-scripting-language-speed/
10
Upvotes
r/ProgrammingLanguages • u/elemenity • Mar 04 '26
View all comments
Show parent comment
1
u/[deleted] Mar 05 '26 edited Mar 05 '26
Actually, my timing turns out to be better than C++!
All the OP's BF implementations include an optimisation to do with pre-determining the jump addresses for the "[" and "]" commands, and storing them into a table.
That means that when encountered, no looping is necessary. My versions don't have that, so are less efficient.
If I modify the C++ to use my method, then it takes 0.73 seconds for 100M iterations, while my systems language can do it in 0.62 seconds.
So my figure is closer to 0.85 relative to C++ using an equivalent BF implementaton.
However, my language also uses a special feature designed for fast dispatch loops, where the compiler generates multi-point dispatching. The same could be done in C or C++ using label pointers and 'computed goto' extensions, but it would need extensive rewriting; the language won't do it for you.
If I turn off the feature by changing the first line to the second:
then my timing becomes 0.9 seconds, or 1.23 relative to g++/-O3. But then my compiler doesn't do any of the same optimisations.