Page 1 of 2

Structural Compiler-Modernizing instead of a ton of new fea.

Posted: Fri Oct 18, 2013 6:45 am
by TheoGott
Purebasic has made a good development lastly and a lot of progress.
However as this is the wishlist thread and not the "Praise thread", i want to express the shortcomings here.

2009 i was last time reminding that PureBasic is still
a "Stack Call based" Single-Pass Compiler. And today still this has not changed.

I believe that this is the reason, why
- i shall need declare procedures if they are "out of order"
- its still impossible to use Gosub and Return inside Procedures,
and why some people say that
- its not allowed to jump out of Loops and other constructs just with Goto.

Coming from Powerbasic (that doesn't look much alive at this time), i had always a compiler who "cared himself about this technical stuff".
And that is what a compiler is good for: Let the user think of the Algo, and care for the rest automatically.

Ok, at least a workaround can be built in.

Writing Declares should not be a part, left to the Japbe-Editor.
If the Editor can do it, take that code, built it into the compiler and write "those declares you need yourself". Let the user think of something else.

Also about leaving Loops, or Jumping out of Returns ... in PowerBasic when i leave the Procedure, the compiler destroys the stack-frame and all things are "cleaned up". No mess left.
In case of error, a "Jump out" is just practical.

Then i would like to see real B-Strings and the new H-Strings.
Under x64 i would like B-Strings and Unicode B-Strings larger then the normal 32-bit string lenght.

And thats all for today. :D

Re: Structural Compiler-Modernizing instead of a ton of new

Posted: Fri Oct 18, 2013 11:49 am
by Rings
TheoGott wrote:Then i would like to see real B-Strings and the new H-Strings.
Under x64 i would like B-Strings and Unicode B-Strings larger then the normal 32-bit string lenght.
to clarify,
what are B-Strings ?
did you mean that here: http://bstring.sourceforge.net/

for H-String , i did not found any usefull in the net

For Strings in generell, i would see a Stringbuilder-library.
(fo example in pure PB, see here: http://forums.purebasic.com/german/view ... f9457b1649 )

btw, are strings in PB are limited to 32 bit length only also under x64 ?

For the use of GOSUB,well, its a view of politic.
-Modern Languages do not allow it (See VB.NET) ,
-otherwise its a standard language element
in procedural BASICs.
-The RETURN Keyword is reserved for leaving a Procedure.
-Since GOSUB isn't in VB.NET, i code without GOSUB since over 10 years now and
i did not missed it.

I bet that if it would be easy to implement a thread safe gosub,
fred would have done it.

Re: Structural Compiler-Modernizing instead of a ton of new

Posted: Fri Oct 18, 2013 12:14 pm
by PB
> The RETURN Keyword is reserved for leaving a Procedure

You mean ProcedureReturn.

@TheoGott: You can exit cleanly out of loops with the Break command,
leaving the stack and everything nicely cleaned up with no mess. :)

Re: Structural Compiler-Modernizing instead of a ton of new

Posted: Fri Oct 18, 2013 12:22 pm
by Rings
PB wrote:> The RETURN Keyword is reserved for leaving a Procedure

You mean ProcedureReturn.
you are right. i'm totaly lost today....

Re: Structural Compiler-Modernizing instead of a ton of new

Posted: Fri Oct 18, 2013 9:31 pm
by freak
Sorry, but the word "modernizing" just doesn't fit well together with a request for better Gosub support.

My idea of modernizing would be more along the lines of removing Gosub/Goto alltogether. Its an unneeded relic from the past.

Re: Structural Compiler-Modernizing instead of a ton of new

Posted: Fri Oct 18, 2013 10:29 pm
by luis
freak wrote: Its an unneeded relic from the past.
Nope, especially in a language like PB. Anyway if you remove it I'll just fall back using JMP. Hope it will not come down to that now that we finally have local labels.

Re: Structural Compiler-Modernizing instead of a ton of new

Posted: Fri Oct 18, 2013 10:58 pm
by freak
luis wrote:
freak wrote: Its an unneeded relic from the past.
Nope, especially in a language like PB. Anyway if you remove it I'll just fall back using JMP. Hope it will not come down to that now that we finally have local labels.
That is your opinion. I beg to differ.

Re: Structural Compiler-Modernizing instead of a ton of new

Posted: Fri Oct 18, 2013 11:30 pm
by luis
You are stating the obvious.

Sure it's my opinion. It is shared by some anyway, not specifically in this forum, cross language and with some supporting thoughts in this direction coming from people like Kernighan-Ritchie, Knuth and others.
You wrote your opinion just before (it was your opinion and not a fact right?) and than I wrote mine (with some reasoning supporting my view linked in those posts).

Then you added a third post (?) stating that what I wrote was my opinion (obviously) and that yours it's different (it was already clear).

I will not answer "this is your opinion, I beg to differ" too because I can see it does not add anything and we will probably enter in an infinite loop so I'll just use a GOTO and jump out of here in a clean, uncluttered, easy to follow, to maintain and efficient way :wink:


@TheoGott

You can read something about the bacgkround of declares and why we live with them from here: -> http://www.purebasic.fr/english/viewtop ... 10#p417010

I use, like many here, a self made tool creating them for me.

Re: Structural Compiler-Modernizing instead of a ton of new

Posted: Sat Oct 19, 2013 1:50 am
by netmaestro
It would be nice to be able to call procedures out of order without declares. That's the solitary item under discussion here that I would consider of any use.

In 1980 I wrote an application for a college to handle admin stuff. GoTo was my favorite command and I jumped all over everywhere. The program worked well and was in service for several years, and the Systems Analysis course used it as a text for the students - to show them how NOT to program. Ack. I'm famous there but not in a good way.

Re: Structural Compiler-Modernizing instead of a ton of new

Posted: Sat Oct 19, 2013 3:12 am
by heartbone
luis wrote:You are stating the obvious.

Sure it's my opinion. It is shared by some anyway, not specifically in this forum, cross language and with some supporting thoughts in this direction coming from people like Kernighan-Ritchie, Knuth and others.
You wrote your opinion just before (it was your opinion and not a fact right?) and than I wrote mine (with some reasoning supporting my view linked in those posts).

Then you added a third post (?) stating that what I wrote was my opinion (obviously) and that yours it's different (it was already clear).

I will not answer "this is your opinion, I beg to differ" too because I can see it does not add anything and we will probably enter in an infinite loop so I'll just use a GOTO and jump out of here in a clean, uncluttered, easy to follow, to maintain and efficient way :wink:


@TheoGott

You can read something about the bacgkround of declares and why we live with them from here: -> http://www.purebasic.fr/english/viewtop ... 10#p417010

I use, like many here, a self made tool creating them for me.
You are a wise and brave man luis.
I like you a lot.
I hope this forum supports private messaging.

On topic:
B-strings???

SMHASMS
WTF :?:

Modernizing?
I think not.
There are plenty of what should be much higher priority items on the development team's plate.

Re: Structural Compiler-Modernizing instead of a ton of new

Posted: Sun Oct 20, 2013 10:42 pm
by TheoGott
Ok, let me say few things for better understanding.
I am coming from the PowerBasic Side of the Universe,
that is where the term "PB" means "PowerBasic" :lol: .

While i have my PureBasic licence for many years,
see here ....
Still i am programming with PowerBasic a lot and know alll Bells and Whistles there since Version 6.
In PureBasic i am a beginner. Trying to get a leg into.

Now to the points:

1. GOSUB ... in PowerBasic a GOSUB/RETURN just compiles to a
CALL / RET Assembly mnemonic. See here:
The RETURN of GOSUB
For time-critical code thats just a fine way to structure code without the overhead of a procedure call. Which is 2,3 4 times slower depending on details.
Its not about coding philosophy, its just about speed.
Now PB (here PB->PureBasic :-) supports Assembly, so i thought i could really use CALL/RET for that, but i had to realize that this also seems to not be valid inside Procedures?

2. I have tested memory allocation with strings in Purebasic x64 to see how much memory i can get for a single string. In my tests it was never mopre then "32 bit" (2..4 Gig) in practical way even much less due to memory fragmentation. As a typical Basic Programmer i do use mostly Strings for all and then it would be nice to have B-Strings that can use a 64-bit adress-space so far its supported by windows.
See ... B-Strings are strings that are not NULL-Terminated: See Discussion on 64-Bit strings here.

3. I got that H-String thing from somebody else, therefore its not really my wish.
But here you can see what it is. H-String
For me this is no priority. i know that Jose would like it ...

4. Declares ...
I had that in the past. I have loaded several libraries together and one called subprogrammes of the other. After some time i got to the point that it got a large confusion and i had to merge things because at that time PB (before version 9) was also Single Pass compiling.
Now that PowerBasic is a multipass-compiler i know the difference -> ITS JUST EASIER DOING.
You can sort Procedures thematically and YOU do not need to think about.
Ok, the Editor is doing it possibly "under the hood". But that is the wrong place.
The compiler should do it.
Its not the use of a compiler to educate programmers but to compile "as good as he can".
And to keep things as simple as possible. (This could be a switch on/off thing).

5. Jumping out of Structures is not that much important, i think if the compiler is going to be rewritten to "Freds best knowledge of today", he will automatically resolve this point and have better optimized code.I am talking from this topic.

Re: Structural Compiler-Modernizing instead of a ton of new

Posted: Mon Oct 21, 2013 12:03 am
by Danilo
TheoGott wrote:1. GOSUB ... in PowerBasic a GOSUB/RETURN just compiles to a
CALL / RET Assembly mnemonic. See here:
The RETURN of GOSUB
For time-critical code thats just a fine way to structure code without the overhead of a procedure call. Which is 2,3 4 times slower depending on details.
Its not about coding philosophy, its just about speed.
Now PB (here PB->PureBasic :-) supports Assembly, so i thought i could really use CALL/RET for that, but i had to realize that this also seems to not be valid inside Procedures?
Have a look at: [Windows] Sub / EndSub / Call Macros

I understand you want it added to the PB compiler (just wait then), but I think it is better than nothing... ;)

Re: Structural Compiler-Modernizing instead of a ton of new

Posted: Mon Oct 21, 2013 6:52 am
by Thorium
I think the PB compiler could need some modernization. Or maybe it's the wrong word. I dont see the need to keep it a single pass compiler. Computers are very fast today, modules would make it easier to implement parallel compilation by compiling each module to a object. Would also not need to compile every module every time, only the ones that changed. So from a performance standpoint i dont see the multi pass compiler much slower than the single pass compiler.
A multi pass compiler would allow for some nice optimizations, like making manual declares obsolet, better optimization of code size by only including referenced code. Even some more performance optimizations applied to the code. All in all producing a better output.

Re: Structural Compiler-Modernizing instead of a ton of new

Posted: Mon Oct 21, 2013 8:07 am
by TheoGott
Its not only Fred, if i take a look on my own programming, its also like that sometimes.
I start a new project, and "on the way" i find out "How i can make it better".
I believe that the same happened ro Fred also. Because:
When he started with PureBasic he did not have the same experience like he has now.

But then the question is, "WHEN is the right time to completely rewrite something from Top to Bottom?".
I know that question. From my experience the best moment is immediately.
The longer its moved around the more work needs to be done later.

Until now PureBasic was expanded, lots of features added, ... but he avoided the large, internal step because it will bring lots of errors and tons of work. And from a marketing standpoint ... how will you explain a person whats really changed? Its even to question if ONE person alone could do it.

Now we have the LTS Release, and he could take 2 years time to really make a "Large strike" and completely modernize the compiler.

Or he could make a completely new Product "Fred++" - I'd buy it, like i bought PureBasic.

Re: Structural Compiler-Modernizing instead of a ton of new

Posted: Mon Oct 21, 2013 11:07 am
by luis
@thorium

Did you read the thread in the link I posted ?
What you or myself think about a double pass compiler (its benefits) is irrelevant if freak says the declare mechanism it's here "by choice".

Like all the discussion about adding OOP to PB. Is it impossible ? No, But it's a choice and it will not change according to Fred.

And there was another post from Fred talking about the extremely low consideration (practically none) he's giving to the idea of a compiler rewrite (time required to do it, time required to stabilize it again, etc. etc.).
I cannot link that because it was inside a bug report and now it is hidden in the invisible "done" forum.

So... I think all this is a waste of energy. Just pointing this out, not telling to anyone he should stop :)