Easy object oriented programming (just look at my example)

Got an idea for enhancing PureBasic? New command(s) you'd like to see?

Was this a good idea?

Yes.
50
56%
No.
19
21%
Maybe.
20
22%
 
Total votes: 89

User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Easy object oriented programming (just look at my example)

Post by Joakim Christiansen »

I know that OO have been suggested before and Fred said no. :(
But what i'm suggesting is that Fred makes his own version of OO. :D

Something like my "fantasy" example down there is using: :?

Code: Select all

; Define a structure
Structure str_bullets
  x.w
  y.w
EndStructure

; Define the object
Object Player
  NewList lst_bullets.str_bullets
  x.w = 320
  y.w = 240
  Procedure MoveLeft()
    x - 16
  EndProcedure
  Procedure MoveRight()
    x + 16
  EndProcedure
  Procedure Draw()
    DisplaySprite(#spr_Player, x, y)
  EndProcedure
EndObject

; Create Player1 as object Player
NewObject player1.Player

; Example of things you could do with the object:
player1\MoveLeft()
player1\MoveRight()
player1\x = 10
player1\Draw()

AddElement(player1\lst_bullets())
player1\lst_bullets()\x = player1\x
player1\lst_bullets()\y = player1\y

DeleteObject player1
The object in my example has local variables and structures inside it, also a local list with a structure. Just to show a little of what I think would be possible.

Would this realy destroy the BASIC dialect :?:
The reason why I would want something like this is because I think it would make game programming much easyer.
And it would also make PB more proffesional and complete.

I'm sorry if this have been discussed to many times before and I should just shutt up. :oops: :cry:
I like logic, hence I dislike humans but love computers.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Yesssss. I voted yes. :D
But i would replace some things:

Code: Select all

; Define a structure
Structure str_bullets
  x.w
  y.w
EndStructure

; Define a class
Structure Player
  NewList lst_bullets.str_bullets
  x.w = 320
  y.w = 240
  Procedure MoveLeft()
    x - 16
  EndProcedure
  Procedure MoveRight()
    x + 16
  EndProcedure
  Procedure Draw()
    DisplaySprite(#spr_Player, x, y)
  EndProcedure
EndStructure

; Create Player1 as object Player
player1.Player

; Example of things you could do with the object:
player1\MoveLeft()
player1\MoveRight()
player1\x = 10
player1\Draw()

AddElement(player1\lst_bullets())
player1\lst_bullets()\x = player1\x
player1\lst_bullets()\y = player1\y
Last edited by Psychophanta on Wed Nov 16, 2005 10:21 am, edited 3 times in total.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

psycho, i'm not entirely in favour of objects and oo stuff, but that makes sense, the thing you created there, and it stays readable and (from fred's point of view, i might guess :-)) somewhat manageable... i could be wrong though, that has happened before ;-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

:wink:
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
SR-Games
User
User
Posts: 21
Joined: Wed Feb 02, 2005 12:47 am
Location: Cockeysville, MD

Post by SR-Games »

A big NO from me. OOP is great, but it has no place in a BASIC language. Sticking OOP in a BASIC language completely defeats the purpose of using a BASIC language. There are plenty of good OOP based languages out there.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

SR-Games wrote:There are plenty of good OOP based languages out there.
Yeah! Some of us hope PureBasic is added and surpass most of those languages and in a near future :D
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

Doesn't BASIC stand for Beginner's All-Purpose Symbolic Instruction Code ?
(had to look it up, I knew this way back but forgotten now :)
So I'm saying nay to OO suggestion :)

I saw what it did to PHP (PHP5) and don't like it, nor do I use it. (the OO stuff that is)
SR-Games
User
User
Posts: 21
Joined: Wed Feb 02, 2005 12:47 am
Location: Cockeysville, MD

Post by SR-Games »

Please don't get me wrong, I like OOP and use C++ Builder 6.0 Enterprise for all contract work, and I even like Jamagic for apps & 2D because of its OOP. But I am an old-schooler when it comes to BASIC and am a purist, BASIC should never be turned into a C++ wannabe language. (Heck, some purists would even argue that a BASIC language should always be interpreted, not compiled. (But since the expanded BASIC cartridge for my TI 99 4A was "compiled", I don't agree with that stance.))
Blade
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Aug 06, 2003 2:49 pm
Location: Venice - Italy, Japan when possible.
Contact:

Re: Easy object oriented programming (just look at my exampl

Post by Blade »

Joakim Christiansen wrote: Something like my "fantasy" example down there is using: :?
Your example is very similar to the Actionscript used in FlashMX, IMHO it's a really cool way of coding! The problem is that you are limited to the "flash world", can't create general purpose applications...
Some one could say that it's similar to Java too, but java is slow(er) and requires a bloated virtual machine.

I'd love that kind of language to create small and fast exes, but please don't contaminate "our" PB... you will obtain two parallel languages in one package, a big chaos! :shock:
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

My example was quite easy to understand, and that fetature would only make programming in PureBasic easyer. (basic is another word for easy)
How "BASIC" would you really want PB to be, we are not kids... (and you could choose if you want to use OOP any way...)
And if we can't add more advanced features to the language because it's named PureBasic, then change the damn name.

You should just see the "BASIC" on my Atari, that was much harder then PB.
I like logic, hence I dislike humans but love computers.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Easy object oriented programming (just look at my exampl

Post by PB »

> The reason why I would want something like this is because I think it
> would make game programming much easyer

Then you should have bought an OO-based language in the first place.
Registering PureBasic and then casting votes to change it is a slap in
the face to everyone else who registered it for what it is. IMHO. And
I don't care if the Yes votes outnumber the No votes -- anyone who
voted Yes should have bought an OO app in the first place. They knew
what they were getting when they bought PureBasic so they shouldn't
be trying to change it and ruin it for others. You get what you paid for!
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post by freedimension »

I don't know how about the others of my fraction, but I think that conservative thinking of some people in here is a slap in the face of the other users that only want progress and improvement.
Don't get me wrong, but the given would be no change of the language but only an additional feature. We wouldn't force you to use it, we don't vote for PB to become a strict OOP-Language like Java or C#. This wouldn't hinder you to program old style "BASIC" (though I'm asking myself what's so BASIC about PureBasic? The name?).

All we ask for is BASIC support for OOP. And don't get me wrong, but there sure are a lot of other BASICs out there that already have a crude implementation of OOP. Take VB(6/.net) for example. Even the most basic of all languages, Assembler has nowadays build in OOP.
<°)))o><²³
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

i guess there are four views...

1. stay pure (no oop)

2. go fancy (psycho's style oop which is akin subroutine calling with just a different name)

3. do real oo support (just minimalist so we can use all new xp and the like stuff)

4. go all the way oop (full featured full fledged)

to me, a combo of 2 and 3 would be great!!! i don't need full stuff, but the way psycho described it does make programming easier, all you have to think of is the procedures within the object are just procedures... just easier maintained, yeah, i can see a point though not the light yet :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Hmm

Post by Fangbeast »

Frankly, I don't give a flying hamster's bottom if PureBasic has OOP or not as long as..

a. The commands that I love and use daily are still in there
b. The libraries of commands I use stay lean and not get bloated into my final executable because of 'feature creep'
c. All this extra stuff that I don't use has no impact in speed and size on my final product

I believe someone said (I didn't count it) that there are over 400 commands in the current purebasic and I only use maybe a 1/4 of these. The 3/4 that I don't use are not compiled into my final program (I checked), do not slow down, nor bloat my application as the compiler is smart enough (and the libraries are split enough) to not compile in what I don't use.

I believe that as long as the compiler is designed in this clever fashion, it doesn't matter what is added to the language because what you don't use will not impact on your final product and that's the bottom line for most programmers.

Visual Basic is a good example of a product with feature creep in gargantuan proportions necessitating huge runtime libraries, form caches and a gazillion functions ready for each application that will never use them.

To illustrate the point a few years ago, I downloaded a home inventory package totalling 8 meg in size and wasn't very impressed. VB6. Recoded the same thing with a few more features in 80K in PureBasic and most of the size was the graphic buttons. Recoded it with PB3.92 recently and only added 4k with the new lib structures, really good stuff and impressive as hell.

The way PB is designed, I think that anything could be added to it with the same compiling logic and that is good for people of all programming languages and I could still get my 84k program out of it in the future.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: Easy object oriented programming (just look at my exampl

Post by Psychophanta »

Blade wrote:I'd love that kind of language to create small and fast exes, but please don't contaminate "our" PB... you will obtain two parallel languages in one package, a big chaos! :shock:
THEN: What do you think about inline ASM and FASM assembler interface (using ! prefixes) ? Aren't already two parallel languages in PB now ?

Well, i must said and repeat again just what Freedimension wrote. Agree with him and agree with Joakim.

About the four views explained by Blueznl I would choose 4. :)

NOTE: Probably i would never use OOP stuff. For my needs it is not needed :)
Last edited by Psychophanta on Fri Mar 04, 2005 9:43 am, edited 1 time in total.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Post Reply