Page 1 of 2
C-Backend
Posted: Mon Sep 27, 2021 6:44 am
by loulou2522
Hi all,
It would be verypleased if someone can explain what is C-Backend ant the utility For purebasic.
THanks
Re: C-Backend
Posted: Mon Sep 27, 2021 8:59 am
by User_Russian
Simply put it is a translator in the C language.
https://www.purebasic.fr/blog/?p=480
Prior to version 6.00, a translator in the assembler language was used.
Re: C-Backend
Posted: Mon Sep 27, 2021 9:05 am
by BarryG
A new way for your code to be compiled, using superior-performance code. See here ->
https://www.purebasic.fr/blog/
As you'll see there, just using the C backend compiler (in Compiler Options) for the graphics test app increased its speed by 50%, without the developer changing a single line in his code. It's fantastic!
Others will explain it better than I, but that's a major improvement in itself.
Re: C-Backend
Posted: Mon Sep 27, 2021 7:31 pm
by davido
@BarryG,
Thanks for the explanation.
Re: C-Backend
Posted: Mon Sep 27, 2021 9:14 pm
by infratec
In PB the 'backend' is the part which translates the PB code to the language of the used tool to generate machine code.
Up to PB 5.73 the tool to generate the machine code is the fasm compiler. So the backend translates the PB code to fasm assembler.
A (f)asm-backend.
From PB 6.0 onwards it is possible to use a C-backend (at the moment a gcc-backend).
It tranlates the PB code to c code for the gcc compiler.
There are several advantages:
Since C is a highlevel language, the c compiler can optimize the generated machine code.
And since gcc is very 'old' and has a very large community, the optimizations are very good.
Fred does not need to do the optimze stuff by himself, like in the asm backend.
The used gcc is available on many architectures, not only x86 or x64.
So it is possible to use PB on a raspberry pi with linux as OS. The cpu is an arm derivate.
But it doesn't matter, since gcc does this part.
But there is also a (small) price to pay:
The generated machine code (executable) can get larger.
The compilation time is longer, since gcc is not a one parse compiler.
It needs more loops over the c code to generate the best optimized machine code.
Summary:
Fred has less work to maintenance the optimizations and don't need to take care of the underlaying CPU type,
as long as the OS is supported by PB.
Re: C-Backend
Posted: Thu Sep 30, 2021 6:16 pm
by fsw
infratec wrote: Mon Sep 27, 2021 9:14 pm
The used gcc is available on many architectures, not only x86 or x64.
So it is possible to use PB on a raspberry pi with linux as OS. The cpu is an arm derivate.
Looking forward to compile my [in PB written] apps natively to a Apple M1 CPU

Re: C-Backend
Posted: Fri Oct 01, 2021 1:41 pm
by Fred
My Mac Mini M1 should get home today

Re: C-Backend
Posted: Fri Oct 01, 2021 1:58 pm
by useful
Fred wrote: Fri Oct 01, 2021 1:41 pm
My Mac Mini M1 should get home today
I.e. the linux version, including the ARM version, will not be waiting in the near future? All the attention will be devoted to MAC?
Re: C-Backend
Posted: Fri Oct 01, 2021 5:17 pm
by infratec
Apples M1 is ARM based
But if you read and understand the stuff above you should know now that the CPU doesn't matter as long there is gcc available for it
and the OS is an already supported one.
Re: C-Backend
Posted: Sat Oct 02, 2021 4:29 am
by fsw
Fred wrote: Fri Oct 01, 2021 1:41 pm
My Mac Mini M1 should get home today
Awesome

Re: C-Backend
Posted: Fri Oct 08, 2021 5:00 pm
by minimy
Hello, i understand what PB can write code for ARM?
¿Can write app for android?
Sorry my ignorance..
Greetings and thanks for the great tool PB!!
Re: C-Backend
Posted: Tue Oct 12, 2021 1:24 pm
by jacdelad
No(t yet). Maybe in the future, but that's not priority. And there's more to do than just switch the compiler.
I would pay an extra 80 bucks for PureBasic for Android. Like, the compiler as an extra, would be cool.
Re: C-Backend
Posted: Tue Oct 12, 2021 5:58 pm
by Caronte3D
jacdelad wrote: Tue Oct 12, 2021 1:24 pm
I would pay an extra 80 bucks for PureBasic for Android. Like, the compiler as an extra, would be cool.
Me too!

Re: C-Backend
Posted: Tue Oct 12, 2021 8:20 pm
by Tenaja
Caronte3D wrote: Tue Oct 12, 2021 5:58 pm
jacdelad wrote: Tue Oct 12, 2021 1:24 pm
I would pay an extra 80 bucks for PureBasic for Android. Like, the compiler as an extra, would be cool.
Me too!
Ditto!
Re: C-Backend
Posted: Wed Oct 13, 2021 10:14 am
by the.weavster
jacdelad wrote: Tue Oct 12, 2021 1:24 pmI would pay an extra 80 bucks for PureBasic for Android. Like, the compiler as an extra, would be cool.
+1