Harbour

Discuss anything else that does not suite other forums.

Moderator: Rathinagiri

Post Reply
gedumer
Posts: 2
Joined: Thu Oct 16, 2008 10:10 pm

Harbour

Post by gedumer »

This is slightly off-topic, but...

Can someone please give me an informed opinion of the Harbour compiler?

Is it a real native code compiler, or is it simply an interpreter that is attached to a starter executable? If it is a true native code compiler, how does it stack up to C and other similar compilers with regard to speed, size, etc.? Any additional info and insight would be appreciated.

HMG appears to be a great GUI tool, but it won't be too helpful unless the compiler that generates the code is top notch.

Thanks...
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: Harbour

Post by Roberto Lopez »

gedumer wrote:This is slightly off-topic, but...

Can someone please give me an informed opinion of the Harbour compiler?

Is it a real native code compiler, or is it simply an interpreter that is attached to a starter executable? If it is a true native code compiler, how does it stack up to C and other similar compilers with regard to speed, size, etc.? Any additional info and insight would be appreciated.

HMG appears to be a great GUI tool, but it won't be too helpful unless the compiler that generates the code is top notch.

Thanks...
I guess that the best place to do this question is the Harbour developers mailing list.

The following is the content of pcode.txt file included with Harbour source code, it could (at least partially) answer your question:

///////////////////////////////////////////////////////////////////////////

Code: Select all

/*
 * $Id: pcode.txt 2248 2000-03-02 11:58:22Z vszel $
 */

The Clipper OBJ and pcode model (GNU|Open|Clipper project)
==========================================================

Let's consider the following Clipper sample Test.prg:


function Main()

   ? "Hello world!"

return nil


Once it gets compiled into a OBJ, what is there inside it?
In fact, what we get is the equivalent to the following C language
application:


SYMBOL symbols[] = { ... };

void MAIN( void )
{
   BYTE pcode[] = { ... };

   VirtualMachine( pcode, symbols );
}


Basically, Test.prg source code has been converted into a sequence
of pcode bytes contained in the array pcode[] = { ... }.  All our MAIN()
function does is invoke, at run-time, a Clipper VirtualMachine() that will
process those pcode bytes.

Let's review the Test.prg pcode structure in more detail:

0000 (2A) LINE 0                    2A 00 00
0003 (2A) LINE 3                    2A 03 00
0006 (13)   SYMF [QOUT]             13 02 00
0009 (01)   PUSHC "Hello world!"    01 ...
0018 (27)   DO(1)                   27 01 00
001B (2A) LINE 5                    2A 05 00
001E (7B)   UNDEF                   7B
001F (79)   SAVE_RET                79
0020 (1E)   JMP 0023                1E 00 00
0023 (60) ENDPROC                   60


We could define a hbpcode.h file to better read that pcode:

hbpcode.h

#define  LINE    0x2A
#define  SYMF    0x13
#define  PUSHC   0x01
#define  DO      0x27
#define  UNDEF   0x7B
...


So finally it will look like:

BYTE pcode[] = { LINE, 0, 0,
                 LINE, 3, 0,
                 SYMF, 2, 0,
                 PUSHC, 'H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '!', '0',
                 DO,   1, 0,
                 LINE, 5, 0,
                 UNDEF,
                 SAVE_RET,
                 JMP, 0, 0,
                 ENDPROC };


And what is SYMBOL symbols[] ?  Clipper creates a symbol table in
the OBJ that later on will be used to create a dynamic symbol table
shared by the entire application. Each of those symbols has the following
structure:

   typedef struct
   {
      char * szName;   // Clipper in fact keeps an array here (11 bytes).
      BYTE   bScope;
      LPVOID pVoid;
   } SYMBOL;

#define PUBLIC 0    // the scope of the function!

SYMBOL symbols[] = { { "MAIN",  PUBLIC, MAIN },
                     { "QQOUT", PUBLIC, QQOUT } };


Let's remember that the name of a function (MAIN, QQOUT) is the address of the
function, so our symbol table will be ready to use it to jump and execute any
linked function.

In fact, the pcode SYMF 2, 0 in our sample, will instruct the VirtualMachine()
to use the 2 symbol, which is QQOUT.

Let's read the pcode:

LINE 0, 0   =>  We are located at line 0
LINE 3, 0   =>  We are located at line 3
SYMF 2, 0   =>  We are going to call QQOUT from our symbol table
PUSHC ...   =>  This string is going to be used as a parameter
DO   1, 0   =>  ok, jump to QQOUT and remember we have just supplied 1 parameter
LINE 5, 0   =>  We are back from QQOUT and we are located at line 5
UNDEF       =>  we are going to return this value (NIL)
SAVE_RET    =>  Ok, return it
JMP  0      =>  We don't jump to elsewhere, just continue to next pcode byte
ENDPROC     =>  This is the end. We have completed this function execution

All these instructions will be evaluated from our VirtualMachine() function
(Clipper names it _plankton()). All functions end using ENDPROC, so when
the VirtualMachine() finds ENDPROC it knows it has reached the end of a
function pcode.

Now that we clearly understand this basic model we are ready to start
implementing 'production rules' on our yacc (clipper.y) syntax to generate
the specific output file (test.c) with the above structure (or we could
easily just generate the OBJ file for it).

to be continued...

Antonio Linares
www.fivetech.com

///////////////////////////////////////////////////////////////////////////
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
gedumer
Posts: 2
Joined: Thu Oct 16, 2008 10:10 pm

Re: Harbour

Post by gedumer »

Thanks Roberto... it's pretty much an interpreter. More like Java or .Net, I believe, as opposed to typical on-the-go interpreters like Chipmunk BASIC, CINT C, LUA, Ruby, etc. The pcode must be designed quite well since the performance of your HMG examples is pretty impressive. I wonder how a full blown DB app would perform with a high volumn of data? Have you or anyone else on the forum ever developed and tested such a program for performance?

At any rate, I appreciate the info... it was very helpful.
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: Harbour

Post by Roberto Lopez »

gedumer wrote:Thanks Roberto... it's pretty much an interpreter. More like Java or .Net, I believe, as opposed to typical on-the-go interpreters like Chipmunk BASIC, CINT C, LUA, Ruby, etc. The pcode must be designed quite well since the performance of your HMG examples is pretty impressive. I wonder how a full blown DB app would perform with a high volumn of data? Have you or anyone else on the forum ever developed and tested such a program for performance?

At any rate, I appreciate the info... it was very helpful.
At this time, there is various benchmarks being published in the Harbour developers mailing list. These benchmarks are related to multi-threading feature to be available in 1.1 version.

I'm sure that the Harbour team will give yo any detailed information that you could need.

You'll find directions to subscribe or read the list at harbour site: http://www.harbour-project.org

Regards,

Roberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Harbour

Post by Rathinagiri »

I had developed an ERP solution for a manufacturing concern with about 3000 raw materials and 100 products. I am using MySQL database as the back end where as HMG is in the front end. It is networked with 15 computers and works nicely without any problem.

I had developed this over a period of 3 years. :)

And, the credit goes to Roberto.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
swapan
Posts: 242
Joined: Mon Mar 16, 2009 4:23 am
Location: Kolkata, India
Contact:

Re: Harbour

Post by swapan »

Great RathinaGiri!

So u know one freeware RDBMS also! BTW are taking any advantage of a RDBMS or just using it like dbfs? How's the speed? What kind of network setup ur this user is having?

Regards,

Swapan
rathinagiri wrote:I had developed an ERP solution for a manufacturing concern with about 3000 raw materials and 100 products. I am using MySQL database as the back end where as HMG is in the front end. It is networked with 15 computers and works nicely without any problem.

I had developed this over a period of 3 years. :)

And, the credit goes to Roberto.
Thanks & Regards,
Swapan Das

http://www.swapandas.com/
Post Reply