Easy OOP features
Easy OOP features
I know it's currently theoretically possible to do OOP in PureBasic. The problem is, the code becomes completely unreadable, highly error-prone, and it's just very difficult to get it to work at all...
How about adding some OOP features that novice users would have a chance of using and understanding?
Look at VBScript, for example - OOP is extremely easy to learn and put to good use here, and it's not like the language is any harder to learn.
But even a very limited and simplistic OOP functionality like VBScript has, would enable you to easily structure very large programs. And would bring new power and possibilities to the PureBasic language.
For example, the Visual Designer could generate a base class for your application, instead of generating code that you have to edit; you would simply extend the generated class, and never again edit the base class code manually...
How about adding some OOP features that novice users would have a chance of using and understanding?
Look at VBScript, for example - OOP is extremely easy to learn and put to good use here, and it's not like the language is any harder to learn.
But even a very limited and simplistic OOP functionality like VBScript has, would enable you to easily structure very large programs. And would bring new power and possibilities to the PureBasic language.
For example, the Visual Designer could generate a base class for your application, instead of generating code that you have to edit; you would simply extend the generated class, and never again edit the base class code manually...

ARGGGGGGG! No more OOP threads please!!! Purebasic is not an OOP language! argggggggg!
There are already two ways to achieve an OOP kind of approach, one using prototypes and a better one using Interfaces.
http://www.purebasic.fr/english/viewtopic.php?t=19416
Argggggggg! *goes to bed*

OOP is not an easy thing full stop, but prototypes and Interfaces are about as easy as you are going to get regarding OOP.
If you think it could of been implemented in an easier way other than these, don't you think Fred would of done it? I think Fred has tried to make these things as easy as possible already.
Read up on Interfaces, they really aren't very hard to understand and can be extremely useful.
If you think it could of been implemented in an easier way other than these, don't you think Fred would of done it? I think Fred has tried to make these things as easy as possible already.

Read up on Interfaces, they really aren't very hard to understand and can be extremely useful.
Both the approaches described in the Help files, and in the above thread, are clumsy, error-prone and unreadable. They are also a lot harder to comprehend than the OOP concepts in most other languages - including even the simplest scripting languages like those in your webbrowser. These work-arounds for OOP in PB are an "emergency" solution, at best - and suitable for expert programmers only ... and even to experts, they're just impractical.Kale wrote:There are already two ways to achieve an OOP kind of approach, one using prototypes and a better one using Interfaces.
Face it, the world is object-oriented - to resist it, is just unnatural.
Besides that, OOP can be incredibly simple - I've seen non-programmers learning VBScript and writing basic OOP code after a week.
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.
If somebody were against, say, linked lists, while-loops, or 3D hardware support, does that mean they should not be supported?
Why do you insist that PB has to be a "lowest common denominator" language?
nonsense - all OOP concepts can be related to the real world with examples that my ten-year old at home has no problems grasping. in fact, I find it a lot easier to explain basic object-methodology than explaining "a function" or "a structure" - these are archaic programming concepts that relate to the computer, not to the real world.Kale wrote:OOP is not an easy thing full stop
Do you really think that? I don't think so. The current implementation is a backup solution, at best - it's intended use is clearly for expert programmers, and these features are most likely only present so that certain OOP features on the operating system will at least be accessible. I do not believe that Fred's intention was that ordinary users would write structured code using these concepts.Kale wrote:If you think it could of been implemented in an easier way other than these, don't you think Fred would of done it? I think Fred has tried to make these things as easy as possible already.![]()
Sure, but it's not OOP.Kale wrote:Read up on Interfaces, they really aren't very hard to understand and can be extremely useful.
Precisely. I'm not asking for C# or Java.thefool wrote:Kale, those are 2 non-easy and not very well intergrated methods. We don't want pb to become full oop, just a bit easier.
Something with the complexity level of VBScript, perhaps - something that anyone with a few hours to spare can learn, if they want to.
Just simple objects with methods and properties, private/public scope, and inheritance. That's all.
OOP gives you a powerful means of organizing your code naturally, in accordance with the real world. Instead of trying to force real-world concepts to adapt to code.
Read the above sentence again, please, and think about it. It's just plain logical, and that's why OOP makes sense. The only way it does not make sense, is if you have no connection to the real world and live behind your computer screen 24/7/365.

Not logical, no - but it is object-oriented.Dare wrote:lol. The world isn't object-oriented. It isn't even logical.
If you don't understand how, it's either because you don't understand what "object-oriented" means - or because you're so involved in the computer-world that you're becoming disconnected from the real world. For your sake, I hope it's the first. Read up.
Please note, I am not claiming OOP to be the "end all do all" solution for all programs without exception.
A lot of programs do not benefit from object abstraction.
But most programs have parts that could benefit.
For example, in this game that I wrote, particles are currently various structures in linked lists. There is no real relationship between these data structures and the code that controls them.
With OOP, "Particle" would have been the first object I would have had. Then "SmokeParticle", "BulletParticle" etc. as classes inheriting from "Particle", as these have a lot of things in common, like the basic timing of their movement, various variables etc.
Currently it's just a function for each, which means that everything is doubly coded - the different structures contain a lot of the same properties. The different functions contain a lot of the same code. Sure, I could improve on this by creating more functions - but this would increase the complexity of my code, as well as the number of function calls.
With OOP, everything that particles have in common would be there once, separate, in a nice, closed unit. And everything that is different in a smoke-particle would be there, again, only once, neatly separated, in a closed unit, and the same for any other type of particle, current or future.
This is something you can only achieve with OOP.
Yes, you can achieve something functionally similar with PB as it looks at the moment - by using more functions, by separating single structures into two or more structures etc... But it won't be pretty.
Simple OOP does not have to cost a lot of overhead. It does not have to bother you or affect you in any way at all, if you can ignore the added link in the Help file. If you do not wish to learn how to use it, you can perfectly well continue writing bulky function-oriented code, while the rest of the world can move on and start writing real programs!
A lot of programs do not benefit from object abstraction.
But most programs have parts that could benefit.
For example, in this game that I wrote, particles are currently various structures in linked lists. There is no real relationship between these data structures and the code that controls them.
With OOP, "Particle" would have been the first object I would have had. Then "SmokeParticle", "BulletParticle" etc. as classes inheriting from "Particle", as these have a lot of things in common, like the basic timing of their movement, various variables etc.
Currently it's just a function for each, which means that everything is doubly coded - the different structures contain a lot of the same properties. The different functions contain a lot of the same code. Sure, I could improve on this by creating more functions - but this would increase the complexity of my code, as well as the number of function calls.
With OOP, everything that particles have in common would be there once, separate, in a nice, closed unit. And everything that is different in a smoke-particle would be there, again, only once, neatly separated, in a closed unit, and the same for any other type of particle, current or future.
This is something you can only achieve with OOP.
Yes, you can achieve something functionally similar with PB as it looks at the moment - by using more functions, by separating single structures into two or more structures etc... But it won't be pretty.
Simple OOP does not have to cost a lot of overhead. It does not have to bother you or affect you in any way at all, if you can ignore the added link in the Help file. If you do not wish to learn how to use it, you can perfectly well continue writing bulky function-oriented code, while the rest of the world can move on and start writing real programs!

because Purebasic is NOT an OOP language! If you want to use an OOP language go and jump on another bandwagon.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.
People are still arguing wether OOP really does solve all our problems?
http://www.devx.com/DevX/Article/26776/0/page/1
http://www.geocities.com/tablizer/oopbad.htm
I could quote more but to be frank im absolutely sick to the back teeth of this &@$%@$ argument! If you want OOP go learn C++, Python, etc... :roll:
Be nice Kale, opinions are opinions, not declarations of war against you personally.It wasn't an argument until you started up. 
And be gentle in your reply to this. I am, after all, a potential customer for your book.
@mp303:
I just tried backgarden = new frontgarden but nothing changed. Lawn still needs mowing out back.
I also sussed out inheritance, but no, Bill Gates is still stinking rich and not one dollar came my way. In fact in real life inheritance seems to be a case of deleting an object (wealthy benefactor).


And be gentle in your reply to this. I am, after all, a potential customer for your book.

@mp303:
I just tried backgarden = new frontgarden but nothing changed. Lawn still needs mowing out back.
I also sussed out inheritance, but no, Bill Gates is still stinking rich and not one dollar came my way. In fact in real life inheritance seems to be a case of deleting an object (wealthy benefactor).

Dare2 cut down to size