PB vs C

For everything that's not in any way related to PureBasic. General chat etc...
threedslider
Enthusiast
Enthusiast
Posts: 377
Joined: Sat Feb 12, 2022 7:15 pm

PB vs C

Post 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 ! :mrgreen:

Hope the team can make this more powerful and keep procedural programming for your love it as well very strong :lol:

It is just a missing some ingredient to PB for accomplish again more powerful :shock:

What do you think ?
User avatar
useful
Enthusiast
Enthusiast
Posts: 402
Joined: Fri Jul 19, 2013 7:36 am

Re: PB vs C

Post 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!!! :) :shock: :oops:
Dawn will come inevitably.
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB vs C

Post 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.
User avatar
useful
Enthusiast
Enthusiast
Posts: 402
Joined: Fri Jul 19, 2013 7:36 am

Re: PB vs C

Post 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! :D :D
Dawn will come inevitably.
threedslider
Enthusiast
Enthusiast
Posts: 377
Joined: Sat Feb 12, 2022 7:15 pm

Re: PB vs C

Post 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!!! :) :shock: :oops:
True the combo of both make PB more powerful :shock:
threedslider
Enthusiast
Enthusiast
Posts: 377
Joined: Sat Feb 12, 2022 7:15 pm

Re: PB vs C

Post 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 :oops: ... I underestimate our love too much PB, I don't have your knowledge and you are pure genius ! :mrgreen:

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 :shock:

Thanks to Fred for the precision and keep quiet until I have used it thoroughly ^^
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: PB vs C

Post 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
The Stone Age did not end due to a shortage of stones !
Quin
Addict
Addict
Posts: 1122
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: PB vs C

Post 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.
User avatar
idle
Always Here
Always Here
Posts: 5835
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: PB vs C

Post 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.
AZJIO
Addict
Addict
Posts: 2141
Joined: Sun May 14, 2017 1:48 am

Re: PB vs C

Post 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.
User avatar
skywalk
Addict
Addict
Posts: 4210
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: PB vs C

Post 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.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
TI-994A
Addict
Addict
Posts: 2698
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: PB vs C

Post 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. :D
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Quin
Addict
Addict
Posts: 1122
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: PB vs C

Post 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. :D
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.
BarryG
Addict
Addict
Posts: 4122
Joined: Thu Apr 18, 2019 8:17 am

Re: PB vs C

Post 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
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB vs C

Post 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.
Post Reply