• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

PowerBASIC has been sold! (PowerBasic IS ALIVE !)

Started by Marc Giao, January 31, 2017, 10:29:10 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Mike Lobanovsky

Hint: do not preprocess your BASIC code. Introduce BASIC aliases for all C PP macros (or use them verbatim) and let the VC++ handle the rest.

A C99 compliant preprocessor implementation alone is perhaps more sophisticated than the entire PB. It is in fact a language in its own right.
Mike
(3.6GHz Intel Core i5 w/ 16GB RAM, 2 x GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

James C. Fuller

Mike,
   After rereading your gpl explanation it appears FreeBasic cannot be used to create closed source binaries?
James


Brian Alvarez


James, PHP does not support macros either, yet, i use them heavily in it. PluriBASIC makes the code replacements. In fact, i didnt use the C++ macros at all (#define) in my implementation of macros.

Mike Lobanovsky

#63
James,

Unless I speak illegible English (which I may; nobody's perfect in their 5th or 6th usable tongue), it doesn't appear at all. Any modern GNU GPL compiler or translator may be freely used to translate and/or compile any programmer's code into any project binary the programmer may ever wish -- open or closed source, free to use or commercial -- except their own source code to be used in a non-GPL'ed environment. GNU GPL adepts' hypertrophied vanity wouldn't permit them to artificially narrow the circles of their potential user base by forbidding their compilers and translators to be used to generate non-GPL'ed machine code.

So, the GNU GPL restrictions only apply to those compilers' and translators' own source code. It may not be used wholly or partially in someone else's compilers and translators that would not obey a similar GNU GPL restriction in their own (thus derivative) sources. Additionally, the precompiled binaries of GNU GPL'ed compilers and translators may not be brute-forced to fit into a non-GPL'ed toolchain, bypassing their usual source-compilation-linking stages implied in my previous sentence, by way of direct machine code modification of those binaries in a hex editor.
Mike
(3.6GHz Intel Core i5 w/ 16GB RAM, 2 x GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Mike Lobanovsky

Brian,

C/C++ PP is not just about #define. Google for a decent open source implementation of a C standard compliant preprocessor (there are a few around) and see what I mean. It would be a bliss for any BASIC to host a full-blown C-style preprocessor, and all the retrograde old farts still professing the defunct Dartmouth orthodoxy may go to hell in slender rows and columns.  ;D

Let your BASIC users have full access to pro-grade preprocessing while you're on the C/C++ territory. When in Rome, do as the Romans do. :)
Mike
(3.6GHz Intel Core i5 w/ 16GB RAM, 2 x GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Brian Alvarez

I will be glad to work on implementing any new features to macros that i find useful. :)

Mike Lobanovsky

Brian,

Don't rely on your personal perspective when evaluating the usefulness of C/C++ features. They have evolved under the supervision of millions upon millions professional users from all over the world. What is a lone indie BASIC developer against this C civilization?  :)

You may however have your own opinion on C/C++ decorations, such as e.g. C curly braces or semicolons. But please don't fall into the other extreme heresy of meaningful code tabulation. ;D
Mike
(3.6GHz Intel Core i5 w/ 16GB RAM, 2 x GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Brian Alvarez

#67
 As i said earlier, i realize c++ has it's well deserved place. In fact, PluriBASIC supports some C++ style statements beside the BASIC ones, for example, you can do this:

switch (Index) ' 'This also compiles for PowerBASIC.
    {
        case 1:
            SomeUdt = "This wont stay!"
        case 2:
            SomeUdt = "because of falltrough"
            break
        default:
            SomeUdt = "No falltrough here"
    }
   
for (int i = 0; i <= 10; i++)  'This also compiles for PowerBASIC.
    {
        stdout "Iteration" + STR$(i);
        break
    }


Or you can also say this:

IF SomeVariable != SomeOtherVariable THEN

But miss a curly bracket in a big project and it is sometimes very hard to find where is it missing.

I realize a lot of users have a better perspective of the things than a lone programmer, but i also realize that sometimes many developers follow the crowd because they are just a "lone programmer" and sometimes the crowd are wrong.

I also rely always on code tabulation, but i hate it when it is imposed in order for the code to work properly (im looking at you python), i like it when it is for clarity! not for functionality! I mean, why should i have to re-arrange my code to work when it should be enough to just copy and paste?

That said, i agree on the point you mention, my perspective is pretty limited when compared with the crowd. Anyway (as a genuine request and not a retoric request), can you tell me one thing that can be done in MS VS that cannot be done in PowerBASIC? I know there are things, can you name a few?






Mike Lobanovsky

#68
If two would pass for a few meaning more than one, what about the following:

0. Scopes (OMG, I nearly forgot to put those in!)

1. Intrinsics

2. Standard PE COFF file generation and linking (as palliation to x64 inline asm)

3. Standard statically linked library generation

4. Template classes

5. Operator overloading (classes)

6. Intelligent code optimization


Regard this as the beginning of a long list of what MS VS can but PB/PBEdit can't.

I'm sure there's also a ton of fine details in the PB functionality that have no ready correspondence in VC/VC++.


(that fall-through switch of yours should really scare most orthodox BASIC'ers to death! ;D )
Mike
(3.6GHz Intel Core i5 w/ 16GB RAM, 2 x GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Frederick J. Harris

#69
I'd still like to see a PowerBASIC 64 bit compiler built in keeping with Bob's 'smaller - faster' design philosophy.  But I do mostly C++ now.  Basically, I don't follow trends, but prefer to do things my own idiosyncratic way.  I strictly do C++ 98 as ISO/IEC 14882:1998.  In my opinion, the C++ standardization committee has been trying to morph C++ into C# ever since the early 2000s.  I reject it, as by 1998 C++ was a fully developed programming language with all the features I needed.  Nothing added since then in my opinion provided anything that couldn't be done lower level in a more efficient manner. 

From reading this thread I simply wondered if Pluribasic translated its basic statements into a type of C++ which could be built against my TCLib.lib, as that would allow a starting program size in the 4k range as opposed to 25 times that or more with the more recent C++ usages. 

In terms of the speed of modern C++ compilers - they are pretty fast.  A 50,000 line program should build in a few seconds.  Maybe not as fast as PowerBASIC, but close.  As Mike mentioned, C++ compilers perform much more complex optimizations than PowerBASIC does.   

I do struggle with the editor issue with C++.  I use a bunch of them, without any clear favorites.  Well, maybe that's not right.  I prefer the CodeBlocks editor or Notepad++.  Occasionally I use Visual Studio 2008, but not much.  I exclusively do command line compiling or command line compiling with batch files like James does. 

James C. Fuller

Fred,
  Does that size represent the version that allows global classes?
I never did incorporate that into my version as I found with a bit of extra coding I didn't need them.

James

Brian Alvarez

#71
Yes, C++ has a lot of stuff, and i agree its good stuff, like being able to access pretty low stuff comands (fast!) with simple (intrinsic) statements. Nobody objects that. What i don't like, is that some of the "intrinscs" (well, not really intrinsic to the OS or CPU, but to the compiler) that are used more often were left out! STR$(), VAL(), automatic unicode string data casting... etc.

Frederick, PluriBASIC has a meta-statement called #OPTIONS, it allows a bunch of switches that alter the behavior of the engine, and that directly affects the output of the code. Im sure it can adapt to whatever flavor of c++ out there, or can be made to adjust. The only bad thing about this, is that i do not distinguish between the features you mention and the ones that were added later. Can you give me an example?

Frederick J. Harris

No, I never added that Jim.  When I originally started out with Matt Pietrek's code from Microsoft System Journal, that was in there, as well as code to process command line strings.   Each added about 512 bytes to the final executable.  So both add about 1 k.  I could add it to my to-do list. 

I think the main impediment to obtaining smaller program sizes from C++ revolve around usage of the C++ Standard Library.  I believe anytime one attempts to use anything from there it is necessary to build with the /EHsc switch, i.e., enable C++ Structured Exception Handling.  I believe that this in itself is one of those things that is going to pull in piles of support code to support this sophisticated functionality.  For myself, C style error handling is sufficient, i.e., test within functions for error conditions, and when one occurs exit the function and return an error code either in the return value or through a parameter.  Of course, C++ coders will tell you that the C++ Exception Handling mechanism is superior.  Perhaps in 500,000 line programs or 5,000,000 line programs it is.  For myself, I've never worked on programs of that size. 

The fundamental idea underlying my TCLib and its ability to minimize program size is that all of the advantages of C++ over C can be realized if one can see one's way clear to avoiding building against the C++ Standard Library.  That's why I had to come up with my own string class, dynamic multi-dimensional array capabilities (which, by the way, utilize templates), etc.  At first it was a confusing thing for me to think my way through, as I think its not a mental exercise all C++ coders make to seperate the bare bones C++ language capabilities from those capabilities provided by the standard libraries.   

I never started working on this until it became fairly clear to me that the likelihood of a 64 bit native PowerBASIC compiler wasn't so good anymore.   I'll be retiring in 9 days and I'm moving from Pennsylvania to Colorado, but once I get there and settled I wouldn't mind trying to work global classes back into TCLib.  I assume Pietrek's code works, so it ought to be just a matter of inserting it back in and testing it.

Theo Gottwald

Brian, the trick is to work along a "Syntax-Tree".
You can use programms like Visio for that.
If you have a "Syntx-Tree" you can programm along that tree and avoid mistakes that will definitely happen if you nor use a "Syntax Tree".
A "Syntax-Tree" Shows exactly what "statements>" and even what "Letters" are allowed in which place.
So using it, and programming along it - you avoid such problems.
I am quite sure that Bob used such a Treee also, becuase thats the only way to gain maximum compiler-Speed.

Brian Alvarez

 Hello Theo. Yes, it can compile C++ 64 apps. However, after some comments now i dont know what to do legality wise... maybe i wont be allowed to share the c++ part. :(

I am currently working on the DDT generator. I mean, it already works but i need the guts of the code it generates.

Instead of making a function for each statement i use a pretty fast engine that allows only certain code in certain places. For example, this statement checks the syntax and generates the code for a DIALOG NEW statement:

ADD_FUNCTION(%FN_DIALOGNEW, "1, ", ",i,s,[i],[i],i,i[,i][,i][TI]", "")

It will prepend a 1, meaning it is a DIALOG NEW statement. For dialog new PIXELS it generates a 2.. for DIALOG NEW MAP it generates a 3 i think etc., then it expects a non-optional comma, then an integer expression, then a comma and then a string expression, then another comma and then an omittable integer expression.... etc.

This way it is very easy to generate new DDT statements or modify existing ones. This one is for ARRAY SCAN:

ADD_FUNCTION(%FN_ARRAY_scan, "1, ", "#{,R}{,c}{,x}{,TI}E", "")

The i = integer expression, the I means integer variable. so, TI means it expects (optionally) a TO Index& expression. The Last E means it should be able to raise a runtime error (ERR) responsive to ON ERROR etc.

It is very fun to work with it... unfortunately i dont have as much time to work on it as I would like to. And to be honest, with recent comments, i dont even know if it will be possible to be released with the C++ funtionality enabled....

For the moment i am using it with big success.