Page 1 of 5
PB vs C
Posted: Mon Sep 23, 2024 5:20 pm
by threedslider
Often PB is speed as C but in term of so many way to code is what about to PB than C ?
PB is a high level programming so C is both low level and high level programming, I mean maybe PB is missing some stuff of low level to compete to C
C has 32 keywords and it is very versatile, easy and very powerful, PB has many keywords then very powerful too with easy more than to C, but versatile yes PB has some but not as C.
That is it, a missing is low level to PB to make more if I am not wrong, a way is to manage our own linked lists designed and to open more possibility to as compiler design, interpreter, OS or device driver, etc.. But of course I think PB can do some thing well...
Imagine PB with both low level and high level programming, sure it will be a king for Basic compiler all the time !
Hope the team can make this more powerful and keep procedural programming for your love it as well very strong
It is just a missing some ingredient to PB for accomplish again more powerful
What do you think ?
Re: PB vs C
Posted: Mon Sep 23, 2024 5:47 pm
by useful
We already have-in C built in, but we only need more detailed documentation.!
How about an analog of the idea from
https://bun.sh/blog/compile-and-run-c-in-js
?
That is, dynamic Purebasic (by compiling to C TinyCC ) at runtime!!!

Re: PB vs C
Posted: Mon Sep 23, 2024 5:49 pm
by Fred
I don't follow you, C doesn't come with anything, just the raw keywords. If you want to use a linked list in C, you need to write it or use a lib. You can also write your own list in PB the similar way.. PB is already very low level for a BASIC language, with inline ASM, lib import, pointers etc.
Re: PB vs C
Posted: Mon Sep 23, 2024 6:06 pm
by useful
I call PureBasic - C with strings for finishers, not for beginners.
I.e. for those who have ever tried both Asm and C and Win32 and Cocoa and Gtk and Qt, but it's too lazy to remember all this.
Let the genius Fred remember all this instead of us!

Re: PB vs C
Posted: Mon Sep 23, 2024 6:30 pm
by threedslider
useful wrote: Mon Sep 23, 2024 5:47 pm
We already have-in C built in, but we only need more detailed documentation.!
How about an analog of the idea from
https://bun.sh/blog/compile-and-run-c-in-js
?
That is, dynamic Purebasic (by compiling to C TinyCC ) at runtime!!!
True the combo of both make PB more powerful

Re: PB vs C
Posted: Mon Sep 23, 2024 6:37 pm
by threedslider
Fred wrote: Mon Sep 23, 2024 5:49 pm
I don't follow you, C doesn't come with anything, just the raw keywords. If you want to use a linked list in C, you need to write it or use a lib. You can also write your own list in PB the similar way.. PB is already very low level for a BASIC language, with inline ASM, lib import, pointers etc.
Sorry, you are right about low level for PB as you say

... I underestimate our love too much PB, I don't have your knowledge and you are pure genius !
It's true I haven't fully explored this PB, you just have to do your job and show what PB is really capable of
Thanks to Fred for the precision and keep quiet until I have used it thoroughly ^^
Re: PB vs C
Posted: Mon Sep 23, 2024 7:05 pm
by StarBootics
I have make the switch to plain C instead of PureBasic few months ago and I have reprogrammed a program in C, a small one, and what I have discovered is the size of the executable is bigger with PureBasic.
The program written in PureBasic : 375.4 Ko
The same program written in C : 232.0 Ko
Now a days, the size of the executable don't really matter but 143.4 Ko difference that's a lot.
A variant of this program where also created with PureBasic using many libraries coming with PB and the size of the executable is 656.6 Ko.
If I compare the size of this variant with the C version of it the size difference is 424.6 Ko, about 2.8 times bigger.
That being said, the main problem with PureBasic is when I want to share the source code with the world nobody outside of the PB community can do something with the source code. When I write a C source code and share it with the world anyone can compile the source code.
So I'm still using PureBasic for few programs I have created over the last 20 years and I need to maintain but from now on the new programs I 'm creating are written in plain C instead of PureBasic.
Best regards
StarBootics
Re: PB vs C
Posted: Mon Sep 23, 2024 7:06 pm
by Quin
useful wrote: Mon Sep 23, 2024 5:47 pm
We already have-in C built in, but we only need more detailed documentation.!
Possibly this should be in feature requests, but I fully agree. That's been the largest thing stopping me from embracing the C backend, there's virtually no documentation on any of it, it's all just ASM.
Re: PB vs C
Posted: Mon Sep 23, 2024 9:29 pm
by idle
Give it time for the c backend to mature.
There are lots of things that could be done with the c backend but it's not so clear cut so inline c is currently somewhat limited as we don't actually have a full c installation with the required headers and those are specific to the c compiler, so this limits what we can achieve with inline c, also the compiler directives for inline c #include get put into the main function which isn't what you want when your importing a c lib as that leads the c compiler compiling the includes when the intent is just to inform the compiler and linker of the symbols your importing.
The switch to c backend has been a great step forward and pretty much necessary with the addition of Arm for macs
so well done Fred for looking at the crystal ball.
Re: PB vs C
Posted: Mon Sep 23, 2024 9:31 pm
by AZJIO
threedslider wrote: Mon Sep 23, 2024 5:20 pm
What do you think ?
viewtopic.php?p=465003#p465003
StarBootics wrote: Mon Sep 23, 2024 7:05 pm
So I'm still using PureBasic for few programs I have created over the last 20 years and I need to maintain but from now on the new programs I 'm creating are written in plain C instead of PureBasic.
The reason is the level of knowledge. It’s hard to immediately write in a complex language without understanding how everything works. I started with AutoIt3, which practically does not use a pointer. Having understood how the program logic works, I switched to PureBasic, and now I’ve learned how to work with pointers and have a little better idea of how it works in memory. I may not switch to C because I understand that I will need to learn WinAPI and GTK and write functions that are in PureBasic. If the reason is only that someone will not be able to compile my code, it is not so critical for me.
Re: PB vs C
Posted: Mon Sep 23, 2024 9:56 pm
by skywalk
I agree the C back end was a tremendous choice, extending the utility of PB for beginners and power users.
Of course, we recognize there are trade-offs when using a go between for C compilation.
But, I am in no hurry to recreate cross platform API libs for windows, gadgets, threading, strings and more.
PB is still the best RAD tool I've come across.
I can't wait to see the performance jump with a better string lib and continued bug fixes.
And the maturing of the C back end to allow direct #include of most C libs.
Re: PB vs C
Posted: Tue Sep 24, 2024 10:53 am
by TI-994A
Both structurally and syntactically, and in performance as well, PureBasic is a great language as it is.
Personally, If anything were to be desired, I have always been partial to the
ternary operator;
which is now possible with inline-C. 
Re: PB vs C
Posted: Tue Sep 24, 2024 11:00 am
by Quin
TI-994A wrote: Tue Sep 24, 2024 10:53 am
Both structurally and syntactically, and in performance as well, PureBasic is a great language as it is.
Personally, If anything were to be desired, I have always been partial to the
ternary operator;
which is now possible with inline-C.
Full agreement from me, the ternary operator is the #1 syntax feature I want PB to get, probably followed by numeric maps.
ternary with inline-c is possible, but not in all cases. You can't make new variables with it for example.
Re: PB vs C
Posted: Tue Sep 24, 2024 12:49 pm
by BarryG
TI-994A wrote: Tue Sep 24, 2024 10:53 amI have always been partial to the
ternary operator
That's just a variation of "Iff" ->
viewtopic.php?t=25788
Re: PB vs C
Posted: Tue Sep 24, 2024 1:35 pm
by Fred
Not really as ternary are meant to be used in an expression: a = b <> 0 ? 11 : 42
It's a bit complex to read as it can also be nested.