Easy object oriented programming (just look at my example)
-
- Enthusiast
- Posts: 767
- Joined: Sat Jan 24, 2004 6:56 pm
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.
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.
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

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
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
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
Please, can you put here some BMX small code which makes use of a linked list without using OOP code

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

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.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!
Please, can you put here some BMX small code which makes use of a linked list without using OOP code

-
- Enthusiast
- Posts: 767
- Joined: Sat Jan 24, 2004 6:56 pm
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...)
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...)
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
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.
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.
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
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
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
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
-
- Enthusiast
- Posts: 145
- Joined: Tue Mar 01, 2005 8:41 pm
- Location: Near a Computer
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?)

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?)

@}--`--,-- A rose by any other name ..
-
- Enthusiast
- Posts: 145
- Joined: Tue Mar 01, 2005 8:41 pm
- Location: Near a Computer
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
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