Page 3 of 5

Re: simple speed optimization request

Posted: Wed Jan 18, 2012 10:00 pm
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

Re: simple speed optimization request

Posted: Wed Jan 18, 2012 10:17 pm
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?

Re: simple speed optimization request

Posted: Wed Jan 18, 2012 11:10 pm
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.

Re: simple speed optimization request

Posted: Wed Jan 18, 2012 11:16 pm
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.

Re: simple speed optimization request

Posted: Thu Jan 19, 2012 7:43 am
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.

Re: simple speed optimization request

Posted: Thu Jan 19, 2012 10:01 am
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.

Re: simple speed optimization request

Posted: Thu Jan 19, 2012 10:30 pm
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.

Re: simple speed optimization request

Posted: Thu Jan 19, 2012 11:06 pm
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 :)

Re: simple speed optimization request

Posted: Thu Jan 19, 2012 11:18 pm
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.

Re: simple speed optimization request

Posted: Thu Jan 19, 2012 11:39 pm
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.

Re: simple speed optimization request

Posted: Fri Jan 20, 2012 2:43 am
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:

Re: simple speed optimization request

Posted: Fri Jan 20, 2012 8:33 am
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.

Re: simple speed optimization request

Posted: Fri Jan 20, 2012 2:21 pm
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.

Re: simple speed optimization request

Posted: Fri Jan 20, 2012 2:48 pm
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.

Re: simple speed optimization request

Posted: Fri Jan 20, 2012 3:03 pm
by Fred
That's some good ideas, i will look at it.