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
Fou-Lu
Enthusiast
Enthusiast
Posts: 201
Joined: Tue Jul 12, 2005 8:30 am
Location: I'm pretty sure this is all a nightmare
Contact:

Post by Fou-Lu »

GedB wrote:A big, big no from me.

If you want OO, then you must have memory management. Preferabbly garbage collection, reference counting at the very least.

Object style coding without the memory management is a bad, bad thing.
How do you know how OOP would be programmed for PB? Maybe there's another way to do that that you don't know yet. :wink:

I myself don't need OO. But if there's someone who needs it, we can only deny when we are sure that this is a "threaten" to PureBasic.

Again: This feature is unnecessary, it will only be added if there are no drawbacks!

~Fou-Lu (aka Lørd Cinneris (actually Elias Sant'Ana))

Image Image
Dreglor
Enthusiast
Enthusiast
Posts: 759
Joined: Sat Aug 02, 2003 11:22 pm
Location: OR, USA

Post by Dreglor »

I can see the use of oop

but i think defining a object should be diffrent from above
it should be more like the

Code: Select all

class myobject
  x.f
  y.f
  move(x,y)
  draw()
endclass
define and declare the procedures outside of the class
i think some of the advance features of oop could be acomplished thru pointers and doesn't have to be internal coded in
right now i love just to have just that format in there its basic and looks clean
~Dreglor
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

OO or not OO :?:

It always depends what your code tries to accomplish.

I use OO-code (mostly GUI programming) and procedural-code side by side and for me it's the way to go.

Regarding BASIC's and OOP there is:
Extreme Basic (p-code)
SpeedBasic (basic 2 c++)
B++ (basic 2 c++)
Bloc (basic 2 object pascal)
BlitzMax (basic 2 c++)
RapidQ (p-code)
HotBasic (basic 2 asm)
and soon FreeBASIC (basic 2 asm)

The BASIC language of the future is powerful and general purpose - this includes basic OO functionality.
This way you can code however you want.
User avatar
Kukulkan
Addict
Addict
Posts: 1396
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Post by Kukulkan »

Hi you all,

Didelphodon posted in the german forum a oop-pre-compiler which allows you to write code like this:

Code: Select all

Class MyClass1
    attribute1.l

    Method setAttribute1(value.l)
        *this\attribute1 = value
    EndMethod

    Method.l getAttribute1()
        MethodReturn *this\attribute1
    EndMethod
EndClass

Class MyClass2 Extends MyClass1
    attribute2.l

    Method setAttribute2(value.l)
        *this\attribute2 = value
    EndMethod

    Method.l getAttribute2()
        MethodReturn *this\attribute2
    EndMethod
EndClass

NewObject *obj.MyClass2

*obj\setAttribute1(1)
*obj\setAttribute2(2)
Debug Str(*obj\getAttribute1()) + " / " + Str(*obj\getAttribute2())
*obj\destruct()

End
It is simple to use as a little precompiler before you use the pb-compiler. You can find more informations and the precompiler on the german website: http://members.chello.at/pure-basic-essentials/ (try downloads).

The site is in german, but the precompiler works very good. If there would be some good feedback on the forum or guestbook of this site, Didelphodon may extend this much more. He is paused in the moment, cause of some illness but will keep on working on this in future (i hope so).

The best thing on a way like this is, that everybody can choose if he wants to use oop or not. If it was possible to use this as an addin in the pb-ide, everyone would be happy, or not?

Kukulkan
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

does the new pb ide support plugins?
User avatar
geoff
Enthusiast
Enthusiast
Posts: 128
Joined: Sun Apr 27, 2003 12:01 am
Location: Cornwall UK
Contact:

Post by geoff »

I am against adding OOP.

I have recent experience of javascript with DHTML. So much is implicit (or inherited) that you can't be sure if it will work, why it doesn't work or what you need to do to make it work. And when it does work you can't be sure if it is correct or a lucky coincidence that something you have omitted has taken a correct default value (or property), but will not work in different circumstances.

I think it unrealistic to expect any major addition to PB not to worsen the existing functionality. When anything becomes more complex it becomes more difficult to debug. Notice how each release of PB gets progressively more difficult to get right, notice how each release of Windows takes longer to develop. Complex things tend to be less reliable, look at the Space Shuttle.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Hi geoff.

You probably know this, but in case you dont: You can use JavaScript as a simple or functional (is that the term?) language as well as with in a heavy duty OOPish way. DHTML access to things like, say, stylesheets, require properties, etc, to set/get values, but JS in and of itself needn't have too much reliance on OOP. It had to retain old funtional approach for all the old apps that used it that way.

On the "To OOP or not to OOP" question:

Provided OOPing PB did not break what we have, it is not necessarily a bad thing. Whilst I don't think I personally would use it (the OOP bits) often, there are cases when it would be useful. Esp when dealing with external stuff that is OOPish.

However first PB needs to get it's data types out of the stone age. Even QB (DOS!) had 8 byte floats!
@}--`--,-- A rose by any other name ..
Truth_Seeker
Enthusiast
Enthusiast
Posts: 145
Joined: Tue Mar 01, 2005 8:41 pm
Location: Near a Computer

Post by Truth_Seeker »

Kukulkan wrote:Hi you all,

Didelphodon posted in the german forum a oop-pre-compiler which allows you to write code like this:

Code: Select all

Class MyClass1
    attribute1.l

    Method setAttribute1(value.l)
        *this\attribute1 = value
    EndMethod

    Method.l getAttribute1()
        MethodReturn *this\attribute1
    EndMethod
EndClass

Class MyClass2 Extends MyClass1
    attribute2.l

    Method setAttribute2(value.l)
        *this\attribute2 = value
    EndMethod

    Method.l getAttribute2()
        MethodReturn *this\attribute2
    EndMethod
EndClass

NewObject *obj.MyClass2

*obj\setAttribute1(1)
*obj\setAttribute2(2)
Debug Str(*obj\getAttribute1()) + " / " + Str(*obj\getAttribute2())
*obj\destruct()

End
It is simple to use as a little precompiler before you use the pb-compiler. You can find more informations and the precompiler on the german website: http://members.chello.at/pure-basic-essentials/ (try downloads).

The site is in german, but the precompiler works very good. If there would be some good feedback on the forum or guestbook of this site, Didelphodon may extend this much more. He is paused in the moment, cause of some illness but will keep on working on this in future (i hope so).

The best thing on a way like this is, that everybody can choose if he wants to use oop or not. If it was possible to use this as an addin in the pb-ide, everyone would be happy, or not?

Kukulkan
Very intresting, I tried to look at the site using WorldLingo. The IDE and precompiler that was being made there looked great. Do you think there might be a English version?
Thanks
Truth Seeker
pantsonhead
User
User
Posts: 39
Joined: Fri Mar 26, 2004 1:47 pm
Location: London, UK
Contact:

What Fred wants is fine with me

Post by pantsonhead »

I won't complain if PB never supports OOP.

I expect it would take a LOT of time and effort to implement and it will still won't be "right" for some users.

I use OOP in other langauges and when you need it, it's great.
But I haven't missed it it PB yet. If it ever did come along in PB, I would hope it was so transparent
that you could ignore it unless you decided to use it.

I'd rather Fred spent time getting OSX version finished before starting something extra like this.

I love PB for what it is now so whatever Fred wants is fine with me.
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

I'd love to have PB support OO properly.

It takes a lot more than just allowing an OO style syntax to do OO.
SoulReaper
Enthusiast
Enthusiast
Posts: 372
Joined: Sun Apr 03, 2005 2:14 am
Location: England

Post by SoulReaper »

hello all :)

I voted yes the reason is pure basic is a basic and yes good for beginners and advanced - but the reason I bought it was I was looking for a next generation language and i looked at loads of differnt basics...

I believe i have found the langauge and it is called pure basic and in time it will prove itself :wink:

very few basic use machine code inline which is a big plus
just to show the power JAPBE editor is written in Pure Basic!
ok I have said enough :roll:

love beating that pure basic drum :twisted: :lol:

Kevin
porfirio
Enthusiast
Enthusiast
Posts: 111
Joined: Mon Nov 15, 2004 11:00 pm
Location: portugal

Post by porfirio »

I like very mutch pb as i like VB.NET.
The OO is very cool and gives you alot of vantages.

I would love to see a programing language like javascript
Its the most cool OO language and you can do esey classes with sub classes and vars etc.
Sadly theres no JS for programing only for scripting in webpages etc...
have you imagined this?

Code: Select all

hwnd=new Window(10,10,500,400,#pb_system_menu,"my win")
btn=new hwnd.Button(5,5,72,20,"OK")
btn.click=function(e){
   MessageRequester("My app","You clicked button")
   hwnd.title="I changed the title :p"
   btn.value="New value on the button !!"
}
That would be so cool!!
But its kinda impossible :(
Forgive-me for my english, i'm portuguese!
Nik
Addict
Addict
Posts: 1017
Joined: Fri May 13, 2005 11:45 pm
Location: Germany
Contact:

Post by Nik »

Why don't you learn real Java then its not the same but it is a good OO developing language
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

It looks like PureBaisc is never going to have OOP, so we should just stop talking about it.
I like logic, hence I dislike humans but love computers.
Truth_Seeker
Enthusiast
Enthusiast
Posts: 145
Joined: Tue Mar 01, 2005 8:41 pm
Location: Near a Computer

Post by Truth_Seeker »

I get that feeling too :(.
Thanks
Truth Seeker
Post Reply