PB vs C

For everything that's not in any way related to PureBasic. General chat 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 »

Fred wrote: Tue Sep 24, 2024 1:35 pm...ternary are meant to be used in an expression: a = b <> 0 ? 11 : 42
...it can also be nested.

Precisely. Plus, there is a certain elegance in the syntax.

Code: Select all

Define a, c = #True
!v_a = (v_c) ? ((v_a == 0) ? (789 - 9) : 123) : (v_a == 123) ? (456 + 4) : (456 - 6);
Debug a
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
Kiffi
Addict
Addict
Posts: 1484
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: PB vs C

Post by Kiffi »

TI-994A wrote: Tue Sep 24, 2024 1:54 pm Precisely. Plus, there is a certain elegance in the syntax.

Code: Select all

Define a, c = #True
!v_a = (v_c) ? ((v_a == 0) ? (789 - 9) : 123) : (v_a == 123) ? (456 + 4) : (456 - 6);
Debug a
You call it elegant, I call it unmaintainable. :wink:
Hygge
Little John
Addict
Addict
Posts: 4770
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: PB vs C

Post by Little John »

Kiffi wrote: Tue Sep 24, 2024 1:57 pm You call it elegant, I call it unmaintainable. :wink:
That's how I call it, too.
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 »

Little John wrote: Tue Sep 24, 2024 1:59 pm
Kiffi wrote: Tue Sep 24, 2024 1:57 pm
TI-994A wrote: Tue Sep 24, 2024 1:54 pm Precisely. Plus, there is a certain elegance in the syntax.

Code: Select all

Define a, c = #True
!v_a = (v_c) ? ((v_a == 0) ? (789 - 9) : 123) : (v_a == 123) ? (456 + 4) : (456 - 6);
Debug a
You call it elegant, I call it unmaintainable. :wink:
That's how I call it, too.

Here's the PureBasic version:

Code: Select all

Define a, c = #True

If c
  If a = 0
    a = 789 - 9
  Else
    a = 123
  EndIf
ElseIf a = 123
  a = 456 + 4
Else 
  a = 456 - 6
EndIf

Debug a

The ternary is a far superior operator and is an acquired taste; once you know how to use it. :wink:
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
Little John
Addict
Addict
Posts: 4770
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: PB vs C

Post by Little John »

If I would like hard readabe soure code, I would use e.g. Perl rather than PureBasic.
Fred
Administrator
Administrator
Posts: 18153
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB vs C

Post by Fred »

TI-994A wrote: Tue Sep 24, 2024 2:12 pm
Little John wrote: Tue Sep 24, 2024 1:59 pm
Kiffi wrote: Tue Sep 24, 2024 1:57 pm
TI-994A wrote: Tue Sep 24, 2024 1:54 pm Precisely. Plus, there is a certain elegance in the syntax.

Code: Select all

Define a, c = #True
!v_a = (v_c) ? ((v_a == 0) ? (789 - 9) : 123) : (v_a == 123) ? (456 + 4) : (456 - 6);
Debug a
You call it elegant, I call it unmaintainable. :wink:
That's how I call it, too.

Here's the PureBasic version:

Code: Select all

Define a, c = #True

If c
  If a = 0
    a = 789 - 9
  Else
    a = 123
  EndIf
ElseIf a = 123
  a = 456 + 4
Else 
  a = 456 - 6
EndIf

Debug a

The ternary is a far superior operator and is an acquired taste; once you know how to use it. :wink:
Nested ternary is smaller to write, but it's really hard to follow, you proved my point :D
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 »

Fred wrote: Tue Sep 24, 2024 2:24 pmNested ternary is smaller to write, but it's really hard to follow, you proved my point :D
You're right; the ternary operator might prove a little daunting to the uninitiated, clearly. :lol:

Nevertheless, it's nice to have the choice now that it's available inline.
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 »

I'll pass. But then, I also don't like multiline statements with : .
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
plouf
Enthusiast
Enthusiast
Posts: 281
Joined: Fri Apr 25, 2003 6:35 pm
Location: Athens,Greece

Re: PB vs C

Post by plouf »

this thing with "invention of C" has become very tired.
vast majority, practically ALL here, know how C works and for this reason we choose PB..

because if you look at with search feature you will see hundred of times this has started

i think is a good idea to block these threads automatically...
Christos
threedslider
Enthusiast
Enthusiast
Posts: 377
Joined: Sat Feb 12, 2022 7:15 pm

Re: PB vs C

Post by threedslider »

Why? this forum is an expression of freedom for everyone to express their opinion ... :?

It is not against to PB, on contrary it is to make PB better in future programming :?: :!:
plouf
Enthusiast
Enthusiast
Posts: 281
Joined: Fri Apr 25, 2003 6:35 pm
Location: Athens,Greece

Re: PB vs C

Post by plouf »

Because as explained.
It has expressed too many times and vast majority of users do not agree with "c -sification" swe prefer basic-ification

Already discussed in past forum threads

Evolve is good but on BASIC steps not C steps
Christos
threedslider
Enthusiast
Enthusiast
Posts: 377
Joined: Sat Feb 12, 2022 7:15 pm

Re: PB vs C

Post by threedslider »

Lol

Basic and C have a common in some programming and you know PB has C backend too as well. If you want 100% Basic so you need to seek a basic compiler with no assembler nor C backend... :?

I say for PB not becoming to C but adding more stuff as inspiration to C, I seek for PB more powerful more possibility that is all and it is more advantageous for everyone...
plouf
Enthusiast
Enthusiast
Posts: 281
Joined: Fri Apr 25, 2003 6:35 pm
Location: Athens,Greece

Re: PB vs C

Post by plouf »

Lol lol lol

Your "idea" is wrong all geound up to the top from
" c has 32 keyword and easy"
"Both are low level and high level"

Also "no assebly" ?! You clearly have mo idea how compilers work and why they are called compilers....

To many other ideas posted.
You terrible look like repeating google found ideas and common talked by the usual repeated "talkshows" in internet and other channel

I have very kindly told you to use search feature to read numerus times discussed .. no need to repeat


Ps. I expect to see you provide GNU-C forums with ideas from PB , to make it easier :)
Christos
threedslider
Enthusiast
Enthusiast
Posts: 377
Joined: Sat Feb 12, 2022 7:15 pm

Re: PB vs C

Post by threedslider »

Dude...

As you are Basic-ification, I think you don't know something in C has really 32 keywords only... sorry it is not my fault :shock: ... know yourself instead of saying anything ...

I know C and C++ too, stop making no sense as you say about from me :? ... it is not useful to talk with you, sorry.
User avatar
idle
Always Here
Always Here
Posts: 5834
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: PB vs C

Post by idle »

There's no need to degenerate into flame wars guys.

I like pb syntax, it's forgiving and self evident.
Post Reply