Page 5 of 6
Posted: Tue Oct 25, 2005 1:04 pm
by dell_jockey
I'm still on the fence on this one.... don't know either way.
I reckon that the current interfaces and the (near future) 4.0 prepocessor will go a long way to allow you to do what is done in C for years already: OO-like programming, without a fullblown OO language. Basically, this entails consolidating variables and (pointers to) code in structs, and using macro preprocessing to dereference pointers to the appropriate code/method. Scope rules (especially file scope rules) are used to prevent direct access to functions, everything needs to be handled through the pointer indirection embedded in the structs.
Posted: Tue Oct 25, 2005 6:00 pm
by Straker
OOP is more of a technique than just available commands. Encapsulation ( an OO concept ) can be done in procedural as well, i.e. coding your functions to perform one unit-of-work, which facilitates reusability. Too often, even in OO-code, coders bloat their functions and make them too specific to be used in more than one place in the overall application. OO nor Procedural forces good coding techniques. This is why programming is an art not a science.
BTW, Drac posted an OO-in-PureBasic tutorial on PureArea.net that was not referenced in this thread, so here it is
Drac's OO Tutorial. This has worked well for me.
I think with Didelphodon's pre-compiler (see page 4 of this thread), PureBasic is already OOP, however, it would be nice to see a native Class/EndClass structure that allows embedded functions. That would be the only thing necessary.
/voted yes
//does OOP for a living
Posted: Sat Oct 29, 2005 11:36 am
by Psychophanta
And well, must we expect something of this in PB 4?

The votations say yes.
I am playing with BlitzMax a little bit, but what i found?:
BlitzMax is a C++ with a modified syntax and some adds.
It's like a modified C++
The first post i wrote in this thread suggests a not so imitating way to do things. The way used by BMX is shamefully complex. A complexity clonation of C++.
Mark Sibly didn't crushed his mind about making things easy and different of C++ when developed BMX
Of course, there are ways to implement OOP in a language in a easy and pleasant way for the programmer
Num3 wrote:I've been using Bmax for a few months now, and you can program it using classic BASIC style or using OOP, it's just up to you to decide.
I see no inconvenience here, and sure would help in some situations!
In order to compare 2D graphics speeds and other things, I am trying now to convert some code from PB to BMX which need a linked list to be done.
Please, can you put here some BMX small code which makes use of a linked list
without using OOP code 
Posted: Sat Oct 29, 2005 7:36 pm
by dell_jockey
The interview with Fred was clear on this topic: he want to keep PB a procedural language.
Question 29: Will the support of OOP in PureBasic be further extended/improved? Or will PureBasic be orientated rather at the procedural BASIC also in the future?
Fred's answer: No. It will stay a procedural BASIC, I don't plan to add class and such I think it will split the PB world in 2 classes (!): the one which have understood fully how OOP work and other which don't. Which means than you couldn't share source codes easily anymore at one place. Procedural and Object Oriented Programming are two opposite concepts and it's not a good idea to mix them in a BASIC language (which is intended for beginners...)
Posted: Mon Oct 31, 2005 1:29 pm
by Psychophanta
However, continuing the Fred's answer, there are some ways to do a language to support fully OOP while it remains easy to read for everybody who simply can understand a Structure only contains data, and a Class can contain data and/or procedures inside.
Only that is necessary to understand OOP.
And in fact, PB has some OOP stuff, like inheritance (with keyword 'Extend' for Structures).
My only suggest is add a new format of Structures (can be called Classes, for example) which can allow inside data types and Procedures.
PB would be the first language easy for beginners, procedural in its roots, and OOP compatible.
Posted: Mon Oct 31, 2005 1:38 pm
by Dare2
I think Straker has nicely encapsulated the whole "pro" discussion and given us a classy solution, with inheritance in the links and references.

Posted: Mon Oct 31, 2005 1:42 pm
by Psychophanta
You are right, Dare, I am repeating and suggesting the samething than Straker

Posted: Wed Nov 02, 2005 1:35 pm
by gvc
You have my vote for a Class/EndClass-structure!
First of all, no-one's obliged to use it, so you can keep programming in PB as before.
A class is a structure with embeded procedures, so if you understand how structures work it's a small step to classes. By the way, is the concept of classes more difficult then, for example, using API-call's? I also wonder how to survive as a programmer on the Windows-platform without any notice of OOP? You even won't be able to use vbscript or javascript.
BASIC is a beginners language??? So, when you get more experienced you abandon BASIC and switch to another language??? After reading through a few topic's on this forum it's clear to me that's not the case. A lot of 'pros' are using BASIC, even to build commercial applications.
After 10 years of procedural programming I made the effort to learn how to use classes a few years ago. It was one of the biggest revelations as a programmer! It makes code much more reusable and easier to maintain. Why say no to such a possible advantage? Even 'script languages' support classes nowedays.
So IMHO, PB will support OOP, only the developer doesn't realize it yet
Geert
Posted: Wed Nov 02, 2005 4:15 pm
by Psychophanta
Agree

Posted: Fri Nov 04, 2005 3:40 am
by fsw
I second that
It's really sad that Fred (in his interview) clearly states:
NO CLASSES FOR PUREBASIC
His decision is simply WRONG
@FRED
Please reconsider your plans.
Posted: Fri Nov 04, 2005 3:46 am
by Truth_Seeker
I agree with the above post

.
Posted: Fri Nov 04, 2005 3:57 am
by Dare2
Maybe stop asking for OO and consider whether opportunity knocks?
Maybe there is a market for a preprocessor for OO?
And maybe someone here will build that preprocessor and sell it like hotcakes and become filthy, stinking rich? (Or at least be able to buy a pizza or two?)

Posted: Fri Nov 04, 2005 4:02 am
by Truth_Seeker
I sure hope the preprocesser will be open source... But the whole point I had for adding OO to purebasic is so we can work with c++ libraries and converting of C++ code.
Posted: Fri Nov 04, 2005 4:26 am
by Dare2
Yeah, I was being glib. But there is some truth in it too - fortunes can made when someone makes like easier for others.
Posted: Fri Nov 04, 2005 7:33 am
by Kukulkan
I tell you again: There is already such a preprocessor available:
Go to
http://members.chello.at/pure-basic-essentials/ and select "Downloads" and "Dokumente". On "Downloads" you can see a sample-code of accepted oo-code.
Kukulkan