Page 4 of 6
Posted: Sat Aug 13, 2005 10:29 am
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
Posted: Sat Aug 13, 2005 10:35 am
by thefool
does the new pb ide support plugins?
Posted: Sat Aug 13, 2005 11:34 am
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.
Posted: Sat Aug 13, 2005 2:50 pm
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!
Posted: Sat Aug 13, 2005 3:28 pm
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?
What Fred wants is fine with me
Posted: Sat Aug 13, 2005 11:18 pm
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.
Posted: Sun Aug 14, 2005 9:24 pm
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.
Posted: Mon Aug 15, 2005 12:17 pm
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
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
Kevin
Posted: Mon Oct 24, 2005 3:26 pm
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

Posted: Mon Oct 24, 2005 5:22 pm
by Nik
Why don't you learn real Java then its not the same but it is a good OO developing language
Posted: Mon Oct 24, 2005 6:30 pm
by Joakim Christiansen
It looks like PureBaisc is never going to have OOP, so we should just stop talking about it.
Posted: Mon Oct 24, 2005 7:27 pm
by Truth_Seeker
I get that feeling too

.
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 