Page 3 of 6
Re: PB and VB.NET speed comparison
Posted: Mon May 07, 2012 3:05 pm
by Thorium
Olby wrote:
That's funny how bunch of folk gather together and say nobody is going nowhere, them dudes going to live forever and work on PB forever.. sounds like religion to me. That's why usually steer away from religious people

But I guess PB is all about trust and belief.
Not at all.
It's just that we think if Fred stopps the project he will release the source, as he did with the Amiga version. So the community will keep it alive with updates.
Re: PB and VB.NET speed comparison
Posted: Mon May 07, 2012 4:40 pm
by Fred
Exactly
Re: PB and VB.NET speed comparison
Posted: Mon May 07, 2012 5:33 pm
by USCode
moogle wrote:I think VB wins in this test because it does quite a lot more optimizations than PB does under the hood.
For example I remember that codes like this
Code: Select all
For x = 0 To 10000000
z = Sin(23.5687)
z = Cos(23.5687)
z = Tan(23.5687)
z = ATan(23.5687)
Next
VB detects that they are repeats so it will optimize this to run only one time as the values returned never change.
The first loop with Random will run like normal on VB as it's different every time.
C does this pretty quick too with it's optimizations.
PB doesn't have that (yet, I hope

)
One of the beauties of PB is its fast compilation speed. I believe I've read one of the reasons for this fast compilation speed is PB has a single-pass compiler.
Question: Would an optimization of this type even be possible for a single-pass compiler?
Re: PB and VB.NET speed comparison
Posted: Mon May 07, 2012 6:02 pm
by Danilo
USCode wrote:moogle wrote:I think VB wins in this test because it does quite a lot more optimizations than PB does under the hood.
For example I remember that codes like this
Code: Select all
For x = 0 To 10000000
z = Sin(23.5687)
z = Cos(23.5687)
z = Tan(23.5687)
z = ATan(23.5687)
Next
VB detects that they are repeats so it will optimize this to run only one time as the values returned never change.
The first loop with Random will run like normal on VB as it's different every time.
C does this pretty quick too with it's optimizations.
PB doesn't have that (yet, I hope

)
One of the beauties of PB is its fast compilation speed. I believe I've read one of the reasons for this fast compilation speed is PB has a single-pass compiler.
Question: Would an optimization of this type even be possible for a single-pass compiler?
Sure it could. 'Sin(23.5687)' and 'Cos(23.5687)' are constant expressions like '5 * 5' that do not change.
Other compilers would detect if z is used after the loop. If not, they would remove the
useless loop body.
What remains is an empty loop:
which can be optimized to
if x is used thereafter. Not all advanced optimizations are possible with a single pass compiler,
but simple
Constant folding can be done by PureBasic too.
I think PB already does it with '5 * 5', and Fred could add it for some mathematical functions too, if the
argument is a constant expression. Even detecting and replacing empty and useless loops should be possible.
Re: PB and VB.NET speed comparison
Posted: Mon May 07, 2012 6:16 pm
by USCode
Danilo wrote:USCode wrote:...One of the beauties of PB is its fast compilation speed. I believe I've read one of the reasons for this fast compilation speed is PB has a single-pass compiler.
Question: Would an optimization of this type even be possible for a single-pass compiler?
Sure it could. 'Sin(23.5687)' and 'Cos(23.5687)' are constant expressions like '5 * 5' that do not change.
Other compilers would detect if z is used after the loop. If not, they would remove the
useless loop body.
What remains is an empty loop:
which can be optimized to
if x is used thereafter. Not all advanced optimizations are possible with a single pass compiler,
but simple
Constant folding can be done by PureBasic too.
I think PB already does it with '5 * 5', and Fred could add it for some mathematical functions too, if the
argument is a constant expression.
Maybe then someone "in the know" could put in a detailed request in the "Feature Requests and Wishlists" forum ... ???

Re: PB and VB.NET speed comparison
Posted: Mon May 07, 2012 6:35 pm
by Danilo
USCode wrote:Maybe then someone "in the know" could put in a detailed request in the "Feature Requests and Wishlists" forum ... ???

You can do it. Just ask for '
constant folding' for mathematical functions.
Code: Select all
z.f = 5*5 ; already optimized to 25
z = Sin(23.5687)
z = Cos(23.5687)
z = Tan(23.5687)
z = ATan(23.5687)
z = Pow(3,3)
z = Radian(45)
y.s = Chr(9) ; already optimized to string
y.s = Hex(123)
It would eliminate the calculations of the mathematical functions:
Code: Select all
For x = 0 To 10000000
z = 25
z = -0.9999771844117471
z = 0.0067550467026268896
z = -148.03408894610274
z = 1.5283926061978867
z = 27.0
Next
But it would not eliminate the loop like C++ and .NET compilers.
Re: PB and VB.NET speed comparison
Posted: Mon May 07, 2012 7:22 pm
by USCode
Re: PB and VB.NET speed comparison
Posted: Mon May 07, 2012 8:14 pm
by Thorium
Thats a small optimization you can also perform by hand if you know the compiler does not do it. So in a real life situation it will not make a big difference as you would put such values you need countless times in constans anyway.
Re: PB and VB.NET speed comparison
Posted: Mon May 07, 2012 9:44 pm
by Olby
Thorium wrote:Thats a small optimization you can also perform by hand if you know the compiler does not do it. So in a real life situation it will not make a big difference as you would put such values you need countless times in constans anyway.
Whenever there is an option to optimize the code I rather rely on compiler rather than try to do it all by myself. Not that am lazy, you'll understand if you have worked with 60'000 code split into multiple files. Point is if it's possible then why not.
Re: PB and VB.NET speed comparison
Posted: Mon May 07, 2012 9:53 pm
by USCode
Olby wrote:... worked with 60'000 code split into multiple files. ...
Just curious - How long does that much code take PB to compile? Is that one monolithic executable or split into DLLs?
Re: PB and VB.NET speed comparison
Posted: Mon May 07, 2012 10:49 pm
by Olby
40 include files, multiple libraries (FreeImage, Adomate, GridControls, libMySql etc.) takes less than 10 seconds to produce executable. Originally we planned to use separate dlls for plugins, but due to problems with memory sharing had to hard-code plugins into binary (I have switches to enable/disable certain plugins).
Re: PB and VB.NET speed comparison
Posted: Fri May 18, 2012 1:31 pm
by langinagel
Sorry guys,
maybe I missed a point. When there is code that does nothing else but being constant over a long loop, why should the innocent compiler do the optimisation?
This is just code that should never been written.
If you accept someone on your project to write such garbage into the code and leave it in one of 60000 files....
then imagine what is in the other files.
This project is rotten and no compiler optimisation will help it.
For my background: I program with PB as a hobby, LOC 300 -2000. It's kind of fun and distraction...
But as a Functional safety guy I rely to the V-Model and can never accept such garbage in the code, no matter how many files will be compiled. This would be a safety violation.
Another point of view: I write my PB code under linux and the same code runs without change under Windows. Can VB.NET do that?
Greetings (actually from Japan)
Thorsten
Re: PB and VB.NET speed comparison
Posted: Fri May 18, 2012 2:27 pm
by Tenaja
langinagel wrote:
If you accept someone on your project to write such garbage into the code and leave it in one of 60000 files....
then imagine what is in the other files.
Because:
A) It happens, and
B) The best compilers optimize it out
Sometimes the "garbage code" sneaks in over years of edits and/or is not as obvious. Clearly that means somebody did not properly refactor, or was under such pressure to "just get it done" that they were not given the luxury to refactor. Then the next guy assumes it is "good code," and does not verify it, and it stays.
The bottom line is that people make mistakes (for a large variety of reasons), and the best compilers do a lot better job of compensating for that. Show me any huge project anybody has done, and it is guaranteed someone could pick out at least one piece of "garbage code" and use that as a basis for saying the author should never be involved in the team.
Re: PB and VB.NET speed comparison
Posted: Fri May 18, 2012 10:09 pm
by Danilo
Code: Select all
Procedure function(f.f)
Debug f
EndProcedure
;
; unreadable
;
function( 2578.31005859375 )
function( 5156.6201171875 )
function( 7734.93017578125 )
function( 6875.49365234375 )
;
; more work
;
#degree_45 = 2578.31005859375
#degree_90 = 5156.6201171875
#degree_135 = 7734.93017578125
#degree_120 = 6875.49365234375
function( #degree_45 )
function( #degree_90 )
function( #degree_135 )
function( #degree_120 )
;
; readable, compiler optimizes constant expressions
;
function( Degree( 45) )
function( Degree( 90) )
function( Degree(135) )
function( Degree(120) )
Re: PB and VB.NET speed comparison
Posted: Sat May 19, 2012 11:10 am
by TI-994A
Olby wrote:That's funny how bunch of folk gather together and say nobody is going nowhere, them dudes going to live forever and work on PB forever.. sounds like religion to me. That's why usually steer away from religious people But I guess PB is all about trust and belief.
Hi Olby. Product comparisons are always great, but they're never conclusive. The simple fact is there'll always be one tool better suited for the task at hand, and since you clearly need CLR/CLI, it may be easier for you to use VB.Net. However, better suited does not mean better tool.
COM/OOP and JIT compilation may have its strengths, but at what cost? VB.Net is a high level RAD tool that produces MSIL, which is fully dependent on the dot net framework to translate and run its apps. This is a massive set of libraries that has to be installed before even a simple "Hello World!" app could run. The latest version of the framework needs upto 2GB of drive space! Not many users are willing to jump through hoops and make changes to their systems simply to run an app; they'll abort as soon as they see the
Microsoft .NET Framework x.x is required... message.
Despite having all this power and optimisation at its disposal, it can only boast a two-second advantage while running on its native Windows platform, which is the only platform it supports intrinsically. Currently, VB.Net's only hope for cross-platform support lies with MONO, which is a slow and bloated third-party tool, that produces slow and bloated apps - no more two-second advantage. And since Microsoft does not sanction the use of MONO, which is now open source under the MonoProject, future development and support is questionable, making it unviable for commercial use.
And just because a product is backed by a corporate giant does not necessarily guarantee its future. In less than fifteen years, Microsoft had totally abandoned the original VisualBasic line without a second thought, to make way for a more commercially viable product, leaving long-time loyal developers stranded. Even MONO was abandoned, twice, first by Novell. and then by Xamarin. Who knows when they'll pull the plug on dot net.
PureBasic has been around for twelve years now, and in that time it has evolved into a very efficient cross-platform development tool. It produces small, fast, standalone native executables, and can tackle virtually any programming task. The geniuses at Fantaisie Software listen to us, which is a privilege that VB.Net users will never enjoy. Today I choose PureBasic because it meets my programming needs, and simply because I like it. Bob Zale has continuously developed and supported his product for twenty-five years now; we'll just have to see what tomorrow holds for PureBasic.