simple speed optimization request

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Re: simple speed optimization request

Post by remi_meier »

freak wrote:> Oddly, PB has them exactly opposite of every "modern" programming language...except maybe some interpreted junk.

You mean such junk as Java?
Although I wouldn't call Java modern, how can you call that
"junk"? :|
freak wrote:The zero initialization has been part of the language from the very beginning. And as we pointed out its costs are minimal. So it is not going to change.
How about adding an option for warnings if a variable has
been initialized properly? Then at least we wouldn't have
such errors as these in our codes:

Code: Select all

Procedure.s a()
  Protected s.s
  If 1 And 0 ; seriously complicated condition
    s = "hi there"
  EndIf
  
  ProcedureReturn PeekS(@s)
EndProcedure

Debug a()
And later add the not-to-zero-init part
Athlon64 3700+, 1024MB Ram, Radeon X1600
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: simple speed optimization request

Post by Tenaja »

freak wrote:> Oddly, PB has them exactly opposite of every "modern" programming language...except maybe some interpreted junk.

You mean such junk as Java?
Java is no longer interpreted... and its speed is not matched by anything except C, on a Linux benchmark. In fact, it has a very small penalty, according to this benchmark:
http://shootout.alioth.debian.org/u64q/ ... &lang2=gcc
Maybe somebody has the "free time" to see how PB stacks up.

Well, let's see, C, Java, C++, GO!, these are all "modern," in the sense that they are heavily used in "modern times" (or backed by a big organization like Google) and they are all "safe" in the opposite ways of PB.

freak wrote:The zero initialization has been part of the language from the very beginning. And as we pointed out its costs are minimal. So it is not going to change.
So you are of the "we have always done it this way so we cannot change" mindset? How disappointing for the future of PB. Especially with a simple update that can easily be 100% backward compatible. Does your attitude carry over to ALL speed optimizations?
void
Enthusiast
Enthusiast
Posts: 116
Joined: Sat Aug 27, 2011 9:50 pm
Location: Washington, USA

Re: simple speed optimization request

Post by void »

Tenaja wrote:Java is no longer interpreted... and its speed is not matched by anything except C, on a Linux benchmark. In fact, it has a very small penalty, according to this benchmark:
http://shootout.alioth.debian.org/u64q/ ... &lang2=gcc
Maybe somebody has the "free time" to see how PB stacks up.

Well, let's see, C, Java, C++, GO!, these are all "modern," in the sense that they are heavily used in "modern times" (or backed by a big organization like Google) and they are all "safe" in the opposite ways of PB.
The point freak was making is that java does the same thing PB does regarding variable initialization, and as you pointed out clearly isn't suffering for it since it's currently one of the fastest runtime environments around.
Tenaja wrote:So you are of the "we have always done it this way so we cannot change" mindset? How disappointing for the future of PB. Especially with a simple update that can easily be 100% backward compatible. Does your attitude carry over to ALL speed optimizations?
This isn't a simple update. It may possibly be 'simple' from a programming standpoint, but it is far from simple from a support standpoint. This feature will cause more people to shoot themselves in the foot than it will help, and there's already a mechanism to get what you want: assembly.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: simple speed optimization request

Post by freak »

Tenaja wrote:
freak wrote:> Oddly, PB has them exactly opposite of every "modern" programming language...except maybe some interpreted junk.

You mean such junk as Java?
Java is no longer interpreted... and its speed is not matched by anything except C, on a Linux benchmark. In fact, it has a very small penalty, according to this benchmark:
http://shootout.alioth.debian.org/u64q/ ... &lang2=gcc
Maybe somebody has the "free time" to see how PB stacks up.

Well, let's see, C, Java, C++, GO!, these are all "modern," in the sense that they are heavily used in "modern times" (or backed by a big organization like Google) and they are all "safe" in the opposite ways of PB.
I mentioned Java because it has automatic 0-initialization for class member variables (see the link). Btw, the 'junk' part was sarcasm.

Tenaja wrote:
freak wrote:The zero initialization has been part of the language from the very beginning. And as we pointed out its costs are minimal. So it is not going to change.
So you are of the "we have always done it this way so we cannot change" mindset? How disappointing for the future of PB. Especially with a simple update that can easily be 100% backward compatible. Does your attitude carry over to ALL speed optimizations?
I am not going to dignify that with a response.
quidquid Latine dictum sit altum videtur
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: simple speed optimization request

Post by wilbert »

@Tenaja, I'm curious about your recursive functions.
You say your project has over 80 of those that are called very often.
Maybe you could share a simple one and get feedback on how others think the speed could be optimized.
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Re: simple speed optimization request

Post by remi_meier »

freak wrote:[..]
I mentioned Java because it has automatic 0-initialization for class member variables (see the link). Btw, the 'junk' part was sarcasm.
[..]
Ok, I misunderstood.

But you surely didn't miss this part:
A local variable (§14.4, §14.13) must be explicitly given a value before it is used, by either initialization (§14.4) or assignment (§15.26), in a way that can be verified by the compiler using the rules for definite assignment (§16).
And you know that there are well thought-out
reasons for Java to initialize instance fields to 0?
  • Of course random values would be worse
  • Allow for evolution of serialized classes (by adding fields): http://docs.oracle.com/javase/6/docs/pl ... rsion.html
  • There is no way to check if a field gets initialized before use in a modular way, which is a requirement for Java
None of these reasons exist for PB except the first,
which is moot for local variables because the third
reason is not valid.
Athlon64 3700+, 1024MB Ram, Radeon X1600
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: simple speed optimization request

Post by Danilo »

@Tenaja:
It is time for you to try C++, C# and Java. You can't request optimizations for PB as you may see
in this topic. Try Intel C++, it's 500% of PureBasic features including parallel programming and everything
modern coders care for. PB is like QBASIC and it wants to stay like Win95 17 years ago.
freak does not care about modern programming, he likes old-style BASIC and gets lost in writing
old-style PureBasic-Tools like the Purifier and other stuff instead more modern stuff and optimizations.

The people here suggest to use ASM, i recommend to switch to C++/C#/Java instead - if you want to develop
big projects and not want to stay with the basics of computer programming for the next 20 years.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: simple speed optimization request

Post by Polo »

I'm very happy of the non-Win95 looking applications I have made so far thanks to Purebasic, this optimisation request is not optimisation, it just means longer code / more time.
Even if I'm a bit fustrated the PB Mac is not improving fast enough (especially for very simple things like the scrollbar gadget), I'm very happy of Purebasic overall :)
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: simple speed optimization request

Post by Danilo »

Polo wrote:this optimisation request is not optimisation, it just means longer code / more time
You know nothing about optimizations. A simple

Code: Select all

Procedure abc(xyz)
    a = 12
EndProcedure
is initialized double in PB and that's the point. For BASIC coders this might be OK,
but not for Pros.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: simple speed optimization request

Post by Polo »

Danilo wrote:
Polo wrote:this optimisation request is not optimisation, it just means longer code / more time
You know nothing about optimizations.
If you say so. What matters to me is how fast my app is, and my PB apps are usually faster than any C++/whatever coded app.
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: simple speed optimization request

Post by Shield »

Polo wrote:and my PB apps are usually faster than any C++/whatever coded app.
No freaking way. That's just a hype that held itself for ages. :wink:
Sure you can write efficient PB code by going low-level...but that's not what high level programming languages are created for. :wink:
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: simple speed optimization request

Post by wilbert »

Danilo wrote:The people here suggest to use ASM, i recommend to switch to C++/C#/Java instead - if you want to develop
big projects and not want to stay with the basics of computer programming for the next 20 years.
Why switch ? There's no reason to stick to one language.
Basic is a great language to learn about programming. And there's not only such a thing as execution speed, there's also the time involved to create something.
My experience with C (Objective-C in this case) is that you can do a lot more with it but when it comes to simple projects, it takes longer to create something compared to a language like PureBasic.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: simple speed optimization request

Post by Fred »

Danilo wrote:@Tenaja:
It is time for you to try C++, C# and Java. You can't request optimizations for PB as you may see
in this topic. Try Intel C++, it's 500% of PureBasic features including parallel programming and everything
modern coders care for. PB is like QBASIC and it wants to stay like Win95 17 years ago.
freak does not care about modern programming, he likes old-style BASIC and gets lost in writing
old-style PureBasic-Tools like the Purifier and other stuff instead more modern stuff and optimizations.

The people here suggest to use ASM, i recommend to switch to C++/C#/Java instead - if you want to develop
big projects and not want to stay with the basics of computer programming for the next 20 years.
Please calm down, there is no need to get overly aggressiv over freak or PureBasic. I decide of the PureBasic concept, and I don't want of a 'so called' modern programming language because it doesn't fit with beginners. For now, PureBasic is fast, even very fast for any kind of applications. It compiles to raw assembly code, so there is indeed room for optimisation, but it's very good in general. All the PureBasic commands are compiled with mainstream C compilers with all optimisations activated, so every PB coder benefits of that. And most of the time is spend in PB functions. So micro optimisations like these, which makes only differences on specific benchmarks, are meaningless for me. I do prefer spend my time on other more useful things like new commands or improving the compiler. PB isn't here to compete with C/C++ compilers which are developped by dozen of peoples who only concentrate on optimizing the code output. Now, if you are not happy with it, it's your choice, but please respect PureBasic and the team, thank you.

BTW, I did wrote the purifier, and even your lovely C/C++ doesn't have it build in. You need costly tools like Purify, MemoryValidator to detect easily a memory overflow. That's a kind of tool which can save you days of debugging, so yes, this is very important to me. Ha, it's free with PureBasic.
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Re: simple speed optimization request

Post by remi_meier »

Fred wrote:[..]PB isn't here to compete with C/C++ compilers which are developped by dozen of peoples who only concentrate on optimizing the code output. Now, if you are not happy with it, it's your choice, but please respect PureBasic and the team, thank you.

BTW, I did wrote the purifier, and even your lovely C/C++ doesn't have it build in. You need costly tools like Purify, MemoryValidator to detect easily a memory overflow. That's a kind of tool which can save you days of debugging, so yes, this is very important to me. Ha, it's free with PureBasic.
Indeed you are working on this alone. May I give some
suggestions of how you could change that?
  • Implement a plug-in interface like the one you wanted to add years ago (to allow external optimizers). E.g. give us access to your IR after parsing. That would allow us to add many interesting features.
  • Provide your parser of the PB language as a library, so we would not need to write our own (which will never be 100% the same as you do not provide a language specification for PB). With this we could do many more source-level tools like for example refactoring tools.
  • Use platform standards like adding debug-info to executables in a standardized format. E.g. allow us to use GDB or Valgrind (which is free btw.) to debug our programs
All in all make the compiler modular.
Then again I don't really use PB anymore and could not
guarantee that I'd really write such plug-ins as contributing
to the PB community is really only a hobby of mine.
Athlon64 3700+, 1024MB Ram, Radeon X1600
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: simple speed optimization request

Post by Fred »

That's some good ideas, i will look at it.
Post Reply