[Gambas-user] Runtime

Rob sourceforge-raindog2 at ...94...
Thu May 22 16:41:54 CEST 2008


On Thursday 22 May 2008 09:29, Leonardo Miliani wrote:
> Personally, if I should choose I preferred to choose speed against
> other features but I have to admit that the interpreter solution is
> very easy

I ported a customer's application from VB to Gambas several years ago 
(circa Gambas 1.0) and the Gambas version was noticeably more 
responsive on the same hardware despite the VB version being compiled 
into native code (or at least that's what the VB IDE calls it.)

It could have been that my optimization skills were better than the 
author of the original program, or it could have been Linux acting 
more responsively than Windows, but if there is a performance hit for 
using bytecode, it's really not that much.  "Native code compiler" 
when speaking of high-level languages is often just a euphemism 
for "our compiler copies the same routines that our interpreter uses 
into your executable," resulting in little if any difference in 
performance.

Further, writing a C program with a modern, mainstream compiler, even 
with all the optimization switches turned on, even if you were to use 
a compiler that doesn't rely on a widely available runtime as gcc 
does, doesn't give you anywhere near the speeds you get by writing 
assembly code from scratch.  Just as with Gambas, the C compiler and 
all the libraries give you a huge amount of convenience (and 
maintainability) at the expense of raw performance.  

And even if you were to write your application in an assembly 
language, as soon as you want to do any kind of I/O or show something 
on the screen, you're making calls to someone else's code, written in 
C and dependent upon a whole lot of other code written in C.  An mp3 
encoder written in Gambas using liblame (assuming that's possible 
with API calls) will be exactly as fast as an mp3 encoder written in 
C or even assembly language using liblame, because all the heavy 
lifting is done by a library.

It may be that if you're writing something in Gambas to generate 
fractals in real time, it'll be slower than it would be in C, but if 
you're the kind of person who writes real-time fractal generators, 
you're probably going to end up writing for an assembler anyway.

Rob




More information about the User mailing list