Page 3 of 5

Re: PB vs C

Posted: Tue Sep 24, 2024 10:04 pm
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.

Re: PB vs C

Posted: Tue Sep 24, 2024 10:08 pm
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

Re: PB vs C

Posted: Tue Sep 24, 2024 10:45 pm
by threedslider
Thank you very much, however I remain careful.

Re: PB vs C

Posted: Wed Sep 25, 2024 1:26 am
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:

Re: PB vs C

Posted: Wed Sep 25, 2024 2:19 am
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.

Re: PB vs C

Posted: Wed Sep 25, 2024 2:56 am
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.

Re: PB vs C

Posted: Wed Sep 25, 2024 7:05 am
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.

Re: PB vs C

Posted: Wed Sep 25, 2024 8:29 am
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.

Re: PB vs C

Posted: Wed Sep 25, 2024 11:45 am
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:

Re: PB vs C

Posted: Wed Sep 25, 2024 12:01 pm
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:

Re: PB vs C

Posted: Wed Sep 25, 2024 12:05 pm
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:

Re: PB vs C

Posted: Wed Sep 25, 2024 12:17 pm
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"))

Re: PB vs C

Posted: Wed Sep 25, 2024 2:13 pm
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).

Re: PB vs C

Posted: Wed Sep 25, 2024 2:40 pm
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.

Re: PB vs C

Posted: Wed Sep 25, 2024 3:50 pm
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.