Besides of price, easy coding, etc. here are more differences between PowerBasic and PureBasic (i included gcc too for a basis comparation):
Compiled with PowerBasic 7.02 for Windows:
Code: Select all
#COMPILE EXE
FUNCTION PBMAIN () AS LONG
DIM starttime AS DWORD
DIM elapsedtime AS DWORD
DIM a(10) AS DWORD
DIM b AS DWORD
DIM i AS DWORD
b=2
FOR i=1 TO 500000000
a(1)=a(2)+a(3)
a(b)=a(1)-a(2)
a(2)=17+i
a(3)=100-a(2)
NEXT
MSGBOX "Hello, World!"
END FUNCTION
On my machine (Athlon 900MHz) it takes about 23 seconds, and its .exe size is 7168 bytes.
Equivalent PureBasic code:
Code: Select all
Dim a(10)
b=2
For i=1 To 500000000
a(1)=a(2)+a(3)
a(b)=a(1)-a(2)
a(2)=17+i
a(3)=100-a(2)
Next
Messagebox_(0,"Hello, World!","",#MB_ICONINFORMATION)
Compiled with PB3.72. .exe size: 4640 bytes. Elapsed time (with my PC in identical conditions than above): about 10 seconds.
Same code for minimalize gcc for windows (perhaps the best C, C++ compiler for windows):
Code: Select all
#include <windows.h>
int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PSTR szCmdLine,
int iCmdShow)
{
long starttime,elapsedtime, a[10], b=2, i;
//starttime=GetTickCount()
for (i=1;i<=500000000;i++)
{
a[1]=a[2]+a[3];
a[b]=a[1]-a[2];
a[2]=17+i;
a[3]=100-a[2];
}
//elapsedtime=GetTickCount()-starttime
MessageBox (NULL, "Hello", "Hello Demo", MB_OK);
return (0);
}
.exe size: 24406 bytes. Elapsed time: about 7.5 seconds
Another example (now with floating point values instead of mem read/write tasks):
For PowerBasic 7.02 for Windows:
Code: Select all
#COMPILE EXE
FUNCTION PBMAIN () AS LONG
DIM starttime AS DWORD
DIM elapsedtime AS DWORD
DIM I AS DWORD
DIM y AS SINGLE
DIM x AS SINGLE
y=5
FOR I=1 TO 500000000
x=x+y*1.000001
NEXT
MSGBOX "Hello, World!"
END FUNCTION
.exe size: 6144 bytes. Time: about 8 secs.
Same in PureBasic:
Code: Select all
y.f=5
x.f
For I=1 To 500000000
x=x+y*1.000001
Next
Messagebox_(0,"Hello","",#MB_ICONINFORMATION)
.exe size: 4128 bytes. Time: about 7.8 secs.
Minimalize gcc for Windows:
Code: Select all
#include <windows.h>
int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PSTR szCmdLine,
int iCmdShow)
{
long starttime,elapsedtime, I;
float y=5,x;
//starttime=GetTickCount()
for (I=1;I<=500000000;I++) x=x+y*1.000001;
//elapsedtime=GetTickCount()-starttime
MessageBox (NULL, "Hello", "Hello Demo", MB_OK);
return (0);
}
.exe size:24406 bytes (it is because windows.h including). Time: about 7.4 secs.
If compiled with g++.exe (GCC with C++ stuff compiler) elapsed time is same, but the .exe size is more than double.
Note: i didn't use WinAPI function GetTickCount because i don't know (nor want to know) with PowerBasic.
In the past, i made some little programs using Borland C++ Builder 4.0 and same programs with PureBasic 3.51, and you can believe: in general I tested more speed (in final executable code) with PB than Borland Builder C++.
Note2: If you implement these pieces of code on BlitzBasic2D you will find no way to compare it, because Blitz is veeeery poor in speed and size of executables in comparison with PowerBasic and PureBasic; so it is not worthwhile to compare it.
AL