Easy OOP features

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

... i'm going for a lay down somewhere.
--Kale

Image
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

Dare wrote:Be nice Kale, opinions are opinions, not declarations of war against you personally.It wasn't an argument until you started up. :D
it just winds me up that people keep insinuating that PB is somehow gimped because it isnt an OOP language.
--Kale

Image
benny
Enthusiast
Enthusiast
Posts: 465
Joined: Fri Apr 25, 2003 7:44 pm
Location: end of www
Contact:

Post by benny »

To be honest. Since I coded in Java lately - I start to think in objects
when I code. So, I really miss an easy way to use objects in PureBasic, too.

I totally agree with mp303 on this. Just some basic usage of objects in a
simple way would make PureBasic even better. And noone would be forced
to use objects, if he/she doesnt want to ...

Anyway, it is up to Fred to decide in which direction Purebasic evolves. And
don't get me wrong - I am really happy with the current version of PB :!:
regards,
benny!
-
pe0ple ar3 str4nge!!!
MLK
User
User
Posts: 57
Joined: Sat Jan 24, 2004 8:46 pm
Location: Germany

Post by MLK »

as purebasic is a very nice language to start coding with, it would make sense to support OOP. i would really like to get as easy in contact with OOP as i got in contact with PP.
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

Kale wrote:... i'm going for a lay down somewhere.
hehe. Not for too long, I hope. You have a book to finish and I for one am looking forward to reading it. :)


With all the requests for Pure-OOP, I smell opportunity. I am wondering why some crash hot coder doesn't do a really good OOP "pre-processor language" and sell it. If I had the nous, I would. Unfortunately for me, I don't have the nous.
Dare2 cut down to size
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

"Face it, the world is object-oriented - to resist it, is just unnatural."

Well the world is OO but computers are procedural. Thats why C++ OOP is so inefficient when compared to a well written C app.

That said, a preprocessor for OO might not be a bad idea.
Straker
Enthusiast
Enthusiast
Posts: 701
Joined: Wed Apr 13, 2005 10:45 pm
Location: Idaho, USA

Post by Straker »

Pre-processor for OOP (top post):

http://www.purebasic.fr/english/viewtop ... 8&start=48

:roll:
Image Image
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

Yea I take that back. I was just bored. Definitely sticking with C++ for my OO needs.
mp303

Post by mp303 »

Kale wrote:
mp303 wrote:And really, what is your problem? Why are you so dead-set against OOP features in PB? You won't be forced to use them.
because Purebasic is NOT an OOP language!
But that's not an argument. We already agree that it isn't - we're discussing wether it could be. I don't understand why this seems to infuriate and frustrate you this badly.

If you have any actual arguments against OOP features, I'd like to hear your reasons. So far I haven't heard any.

If your best argument is that OOP is "evil", I think you should take a chair - no one's going to listen to that anyway.

So tell us:

What is so terrible about OOP, that you have to protect other PB users from ever touching it?

How exactly does the addition of OOP features to PB threaten to destroy PB for you and everyone else?
mp303

Post by mp303 »

dracflamloc wrote:Well the world is OO but computers are procedural. Thats why C++ OOP is so inefficient when compared to a well written C app.
Computers are no more procedural than they are object-oriented, that's all up to the programming language. Have you looked at machine code? See any procedures in there?

If your argument is, that a programming language should be as close to machine language as possible, then in fact, procedures should not even be allowed. We should all go back to using GOTO.
Thalius
Enthusiast
Enthusiast
Posts: 711
Joined: Thu Jul 17, 2003 4:15 pm
Contact:

Post by Thalius »

OOP Can be very useful ( especially for large projects ... ).

The idea is not to make PB an OOP language nor to "gimp" it .
But it would be nice to have a clean and easy to use way to implement a Class based structure ( not only to recycle code ) for example in way of a pre-compiler ( use it or don't use it its up to you ... same thing with jaPBe .. some use it others use the PB IDE - Matter of taste). Am working on a rathe rhuge project atm ... with over 9000 include files ( couldn't solve it another way for order... ) .. and while procedural based surely has its advantages sometimes it would be handy to recycle some basic functions you have to split up otherwise.

*hands kale a towel to bite in ... =)

Cheers, Thalius
"In 3D there is never enough Time to do Things right,
but there's always enough Time to make them *look* right."
"psssst! i steal signatures... don't tell anyone! ;)"
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

Purebasic is a procedural language based on BASIC. Why should it have to be re-writen from scratch just to support features that you could achieve in others ways and features that the majority of people (who want to use basic) would not use. To support OOP correctly would take a complete compiler re-write and if you havn't noticed Fred has just finished a major version.

OOP In Purebasic (PDF)
http://www.purebasic.fr/english/viewtopic.php?t=19416
mp303 wrote:If you have any actual arguments against OOP features, I'd like to hear your reasons. So far I haven't heard any.

What is so terrible about OOP, that you have to protect other PB users from ever touching it?
http://www.geocities.com/tablizer/oopbad.htm
--Kale

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

Post by thefool »

They can call it "easy object oriented programming" all they want. Its NOT efficient, nor easy and readable.
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

Kale wrote:.. To support OOP correctly would take a complete compiler re-write and if you havn't noticed Fred has just finished a major version.
This is not entirely correct.
It depends how much oop you want...

My little class parser is just 4.5kb in code and 12kb as exe, and it works great.
Still need to implement some stuff but it will not increase the size too much.

This is my oop code:

Code: Select all


;oop example by fsw

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;- start main:

Class MyObject
  ValueOfThat.l
  AnotherValue.s
  This(par.l)
  That()
EndClass

NewObject myThing.MyObject
NewObject AnotherThing.MyObject

With myThing
  \This(347)
  \That()
EndWith

With AnotherThing
  \This(123)
  \That()
EndWith

myThing\That() ;double check the value
AnotherThing\That() ;double check the value

End

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; for now no constructor or destructor (maybe I will never incude them)

Procedure MyObject_This(*Self.MyObject, par.l)
  *Self\ValueOfThat = par
  MessageRequester("MyObject", "This: " + Str(par))
EndProcedure

Procedure MyObject_That(*Self.MyObject)
  *Self\AnotherValue = " That: "
  MessageRequester("MyObject", *Self\AnotherValue + Str(*Self\ValueOfThat))
EndProcedure
This is translated to:

structure for address of vtable and properties
interface for methods
declare the methods
datasection is the actual vtable
create new object

Thats it.
Too much oop is bad (IMHO), it will obscure the code.
Kale wrote: OOP In Purebasic (PDF)
With V4 this is outdated, but it shows the principle behind it.
:D
Kale wrote:
mp303 wrote:If you have any actual arguments against OOP features, I'd like to hear your reasons. So far I haven't heard any.

What is so terrible about OOP, that you have to protect other PB users from ever touching it?
http://www.geocities.com/tablizer/oopbad.htm
This link is pretty old and if you really read through the text you will see that this guy is just promoting his idea of the holy coding grail.
Didn't see anything that makes me think: "This is good!"
This guy worte down a lot, but his own code proves him wrong, it's longer than the oop code and it's more obscure (IMHO).


As I stated above, too much oop is bad (IMHO), it will obscure the code.
But a resonable amount of object oriented concept can be excellent (IMHO).
:D
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

fsw wrote:As I stated above, too much oop is bad (IMHO), it will obscure the code.
But a resonable amount of object oriented concept can be excellent (IMHO).
:D
You are being reasonable, rational and balanced. Stop it at once!

:D
Dare2 cut down to size
Post Reply