Author Topic: BaCon  (Read 10097 times)

Pjot

  • Guest
Re: BaCon
« Reply #15 on: September 21, 2010, 02:46:33 PM »
Quote
Both BaCon and QB64 includes a full runtime with every compiled program.

Call me stupid but I simply don't understand what this means. Can you elaborate on the word "runtime"?

Thanks,
Peter

EDIT: I see your HELLO WORLD reference now. So I think I understand what you mean: the BaCon header file always contains all macros and definitions, while the C file contains the program. I guess you mean that this header file contains a lot of code which is not actually being used in the Hello World program. This header file you refer to with the term "runtime".

If this is what you mean, then you have to understand the way C macros work. For the header file of BaCon is used by the C Pre Processor to expand inline functions in the BaCon code. Meaning that only those macros are used which appear in the BaCon program. Meaning that the C compiler just uses the code actually referred to.

Surely, all macro code is generated during conversion, but beware, not all code is actually being used by the C compiler. That is the reason why the BaCon binarties are so small.

Also statements like "#include <stdio.h>" do not actually include a whole library. These statements just refer to header files which allow the C compiler to understand some libc function names.

So in terms of "runtime", BaCon binaries depend dynamically on libc, libm and libdl.

Nevertheless, the C code emitted by BCX is superior. It is very clean code which actually is human readable and it is easy to understand. And the code emitted by BaCon is not.

In a sense, BaCon uses C as intermediate code just to be able to create a binary. BaCon does not care if the C source is readable or not - it cares if it is compilable.

Regards
Peter
« Last Edit: September 21, 2010, 03:12:24 PM by Pjot »

JRS

  • Guest
Re: BaCon
« Reply #16 on: September 21, 2010, 03:28:03 PM »
Thanks Peter for taking the time to explain how BaCon compiles it's source.

I was wondering how you got your executables so small when QB64 is generating a 800KB runtime footprint for PRINT "Hello World".


Pjot

  • Guest
Re: BaCon
« Reply #17 on: September 22, 2010, 12:47:14 AM »
Well in BaCon, the "Hello world" program in binary form has a size of 25kB, after a 'strip'. This is still 5x bigger than a plain C implementation where the "Hello world" results into a 5kB program. Probably BCX can generate binaries as small as the plain C sources also, which is very nice.

On the other hand, a GTK GUI program in BaCon, for example the Source Code Editor, has barely 50kB after compilation (yes fifty), while it is a full blown GUI application.

Regards
Peter

JRS

  • Guest
Re: BaCon
« Reply #18 on: September 22, 2010, 12:59:35 AM »
I would like to add that your Gtk Server library is another example of the fine work you do. I remember when I pleaded for a DLL version of Gtk-Server back in 2005/6 and you created a ScriptBasic extension module. (one function wonder  :o )
« Last Edit: September 22, 2010, 01:20:51 AM by JRS »