PB vs C
-
- Enthusiast
- Posts: 377
- Joined: Sat Feb 12, 2022 7:15 pm
Re: PB vs C
@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
No need to delete or lock thread. We're all entitled to opinions.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.

-
- Enthusiast
- Posts: 377
- Joined: Sat Feb 12, 2022 7:15 pm
Re: PB vs C
Thank you very much, however I remain careful.
Re: PB vs C
Code: Select all
!v_a = (v_c) ? ((v_a == 0) ? (789 - 9) : 123) : (v_a == 123) ? (456 + 4) : (456 - 6);

Re: PB vs C
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.BarryG wrote: Wed Sep 25, 2024 1:26 amAgreed that the ternary syntax is anything but elegant. What a nightmare to read and understand.Code: Select all
!v_a = (v_c) ? ((v_a == 0) ? (789 - 9) : 123) : (v_a == 123) ? (456 + 4) : (456 - 6);
![]()
Re: PB vs C
That wasn't a very good example, as a lover of the operator that one even made me cringe.BarryG wrote: Wed Sep 25, 2024 1:26 amAgreed that the ternary syntax is anything but elegant. What a nightmare to read and understand.Code: Select all
!v_a = (v_c) ? ((v_a == 0) ? (789 - 9) : 123) : (v_a == 123) ? (456 + 4) : (456 - 6);
![]()
Code: Select all
NewDirection = Direction = left ? right : left
-
- Addict
- Posts: 4774
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: PB vs C
Elegance is in the eye of the beholder.Quin wrote: Wed Sep 25, 2024 2:56 amNow that is elegant.Code: Select all
NewDirection = Direction = left ? right : left
Re: PB vs C
Still:
It's PB not PC, PureBASIC not PureC. See the difference.
So keep it BASIC. Even if Panora's box is already open.
If you want C, you don't have to abuse PureBasic.
It's PB not PC, PureBASIC not PureC. See the difference.
So keep it BASIC. Even if Panora's box is already open.

If you want C, you don't have to abuse PureBasic.

Re: PB vs C
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
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

{Home}.:|:.{Dialog Design0R}.:|:.{Codes}.:|:.{History Viewer Online}.:|:.{Send a Beer}
-
- Enthusiast
- Posts: 377
- Joined: Sat Feb 12, 2022 7:15 pm
Re: PB vs C
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 itselfLord 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.
If you want C, you don't have to abuse PureBasic.

-
- Enthusiast
- Posts: 377
- Joined: Sat Feb 12, 2022 7:15 pm
Re: PB vs C
Can we simulate the ternary by a macro with PB ?
It is same and can be more complex in arguments to function macro

It is same and can be more complex in arguments to function macro

Re: PB vs C
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
Every time one of these arguments comes up I ask this, and no one answers it... 
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).

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

Re: PB vs C
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.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...
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).
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.

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