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

Re: PB vs C

Post by threedslider »

@idle : yes sorry I didn't want to get there, I just wanted to give an idea of ​​a better PB for everyone. If this doesn't suit everyone, don't hesitate to delete this thread ... Me too I Iike PB and to forget this conflict.
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 »

threedslider wrote: Tue Sep 24, 2024 10:04 pm @idle : yes sorry I didn't want to get there, I just wanted to give an idea of ​​a better PB for everyone. If this doesn't suit everyone, don't hesitate to delete this thread ... Me too I Iike PB and to forget this conflict.
No need to delete or lock thread. We're all entitled to opinions. :D
threedslider
Enthusiast
Enthusiast
Posts: 377
Joined: Sat Feb 12, 2022 7:15 pm

Re: PB vs C

Post by threedslider »

Thank you very much, however I remain careful.
BarryG
Addict
Addict
Posts: 4122
Joined: Thu Apr 18, 2019 8:17 am

Re: PB vs C

Post by BarryG »

Code: Select all

!v_a = (v_c) ? ((v_a == 0) ? (789 - 9) : 123) : (v_a == 123) ? (456 + 4) : (456 - 6);
Agreed that the ternary syntax is anything but elegant. What a nightmare to read and understand. :shock:
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 »

BarryG wrote: Wed Sep 25, 2024 1:26 am

Code: Select all

!v_a = (v_c) ? ((v_a == 0) ? (789 - 9) : 123) : (v_a == 123) ? (456 + 4) : (456 - 6);
Agreed that the ternary syntax is anything but elegant. What a nightmare to read and understand. :shock:
C is a great language but it can be far to expressive for its own good, just because you can doesn't mean you should.
Quin
Addict
Addict
Posts: 1124
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: PB vs C

Post by Quin »

BarryG wrote: Wed Sep 25, 2024 1:26 am

Code: Select all

!v_a = (v_c) ? ((v_a == 0) ? (789 - 9) : 123) : (v_a == 123) ? (456 + 4) : (456 - 6);
Agreed that the ternary syntax is anything but elegant. What a nightmare to read and understand. :shock:
That wasn't a very good example, as a lover of the operator that one even made me cringe.

Code: Select all

NewDirection = Direction = left ? right : left
Now that is elegant.
Little John
Addict
Addict
Posts: 4777
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: PB vs C

Post by Little John »

Quin wrote: Wed Sep 25, 2024 2:56 am

Code: Select all

NewDirection = Direction = left ? right : left
Now that is elegant.
Elegance is in the eye of the beholder.
User avatar
Lord
Addict
Addict
Posts: 900
Joined: Tue May 26, 2009 2:11 pm

Re: PB vs C

Post by Lord »

Still:
It's PB not PC, PureBASIC not PureC. See the difference.
So keep it BASIC. Even if Panora's box is already open. :evil:
If you want C, you don't have to abuse PureBasic.
Image
User avatar
HeX0R
Addict
Addict
Posts: 1187
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: PB vs C

Post by HeX0R »

I'm using this ternary thing excessively in PHP, but more due to lazyness.
But I must admit, I never felt it was missing in PB, if it was there, I would probably make good use of it, but if not... I don't care.
Before we add cosmetic syntax "improvements", I'd vote to add native SSL/TLS to the network lib (AND useful error handling!).
Although, even here I am fine with our community driven solution at the time being.
You become frugal the older you get :mrgreen:
threedslider
Enthusiast
Enthusiast
Posts: 377
Joined: Sat Feb 12, 2022 7:15 pm

Re: PB vs C

Post by threedslider »

Lord wrote: Wed Sep 25, 2024 8:29 am Still:
It's PB not PC, PureBASIC not PureC. See the difference.
So keep it BASIC. Even if Panora's box is already open. :evil:
If you want C, you don't have to abuse PureBasic.
Yes, relax @Lord, again PB is not becoming to C and I don't abuse it... I mean PB can have an improving derived to C to make more powerful and more possibility so don't worry about that ok because PB is still stays as PB itself :wink:
threedslider
Enthusiast
Enthusiast
Posts: 377
Joined: Sat Feb 12, 2022 7:15 pm

Re: PB vs C

Post by threedslider »

Can we simulate the ternary by a macro with PB ? :)
It is same and can be more complex in arguments to function macro :shock:
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: PB vs C

Post by ChrisR »

As written by BarryG, the macro IIF does almost that but without a return value and not with the same syntax.

Code: Select all

Macro IIf(expr, truepart, falsepart)
  If Bool(expr) : truepart : Else : falsepart : EndIf
EndMacro

Procedure Min(ValueA, ValueB)
  If ValueA < ValueB
    ProcedureReturn ValueA
  EndIf
  ProcedureReturn ValueB
EndProcedure

a=Random(1) : Debug "a = " + Str(a)
b=Random(1) : Debug "b = " + Str(b)
IIf(a=b, Debug "a=b", Debug "Min = " +Str(Min(a,b)))

c=Random(1) : Debug "c = " + Str(c)
IIf(a=b, IIf(a=c, Debug "a=b=c", Debug "a=b"), IIf(a=c, Debug "a=c", Debug "b=c"))
Quin
Addict
Addict
Posts: 1124
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: PB vs C

Post by Quin »

Every time one of these arguments comes up I ask this, and no one answers it... :mrgreen:
What exactly does "keep it basic" mean? PB is what I'd consider to be BASIC-enspired. "real" BASIC has subs/functions, dim var as string etc., and PB is one of the farthest languages from the rest of the BASICs I've used (VB, BCX, B4X, etc).
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 »

threedslider wrote: Wed Sep 25, 2024 12:01 pm... I mean PB can have an improving derived to C to make more powerful and more possibility...
Of course. To suggest improvements is always a good thing, and it's the only way for any product to evolve and stay relevant; just like PureBasic has been doing all these years.

And the nature of this forum is usually a very welcoming and nurturing one. The behaviour of the detractors that see the need to criticise and rain on such suggestions is the only inelegance on display here.

PureBasic has introduced many new features over the years, and none have swayed it away from its BASIC characteristics that we all know and love.

As for the ternary operator, perhaps a page could be taken from Kotlin, which actually implements it with a very simple and readable BASIC-like syntax. That would be an excellent addition to PureBasic.
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
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 »

Quin wrote: Wed Sep 25, 2024 2:13 pm Every time one of these arguments comes up I ask this, and no one answers it... :mrgreen:
What exactly does "keep it basic" mean? PB is what I'd consider to be BASIC-enspired. "real" BASIC has subs/functions, dim var as string etc., and PB is one of the farthest languages from the rest of the BASICs I've used (VB, BCX, B4X, etc).
My guess at "keep it basic" is having a syntax that is more wordy and allows new programmers to quickly bring up graphical applications within hours to days of starting.
No trailing ; semicolons, pointers are pointers everywhere in the code.
(C defines a pointer once and then you must remember everywhere else it is referenced. :evil: )
This is my favorite syntactical sugar PB brings.
Also very glad PB uses base 0 for array indexing.

It is debatable the number of keywords of PB vs C, since many are api and lib driven.
Ex. UseSHA3Fingerprint, UseSQLiteDatabase, etc. are not in C.
The existence of so many starting libs under one uniform IDE and syntax, it is a disservice to label it basic.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Post Reply