Page 3 of 4

Posted: Wed Jun 25, 2003 2:59 am
by mp303
PS: for a lesson in beautifully pure and simplistic OOP, refer to PHP - it has only a few simplistic OOP features, but it makes all the difference; it doesn't have the rigid strictness of C++ or Java - it has just enough to enable the programmer to, voluntarily and at his own disgression, organize his data structures and code in an object-oriented fashion. I repeat: voluntarily and at his own disgression; this is where OOP, in true OO languages like C++ and Java, gets too difficult for mortal basic programmers - because you're not only ABLE to use all the features, you're FORCED to. That's of course NOT what I want for a language like PB - Basic should be accessible to beginners - but a language as powerful as PB could easily be made useful for the intermediate or even professional programmers, if it were spiced up with a little OO!

Just my two cents :)

Posted: Wed Jun 25, 2003 7:00 pm
by fsw
mp303 wrote:PS: for a lesson in beautifully pure and simplistic OOP, refer to PHP - it has only a few simplistic OOP features, but it makes all the difference; it doesn't have the rigid strictness of C++ or Java - it has just enough to enable the programmer to, voluntarily and at his own disgression, organize his data structures and code in an object-oriented fashion. I repeat: voluntarily and at his own disgression; this is where OOP, in true OO languages like C++ and Java, gets too difficult for mortal basic programmers - because you're not only ABLE to use all the features, you're FORCED to. That's of course NOT what I want for a language like PB - Basic should be accessible to beginners - but a language as powerful as PB could easily be made useful for the intermediate or even professional programmers, if it were spiced up with a little OO!

Just my two cents :)
One Euphoria User wrote a OOP library for Euphoria and it seems to work well.

Maybe a PureBasic user (with enough knowledge of OOP) could make the same, with at least the functionallity mentioned above.

So all OOP entusiast here can use it, if they want to.

But the question is how many would use it ?

Posted: Wed Jun 25, 2003 10:35 pm
by mp303
I don't think it's possible to implement this kind of functionality with a library - and the compiler itself is not open or extensible, so I don't think that's possible. But I would implement it myself if it were ;)

And how many would use it you ask? That's of course hard to predict, but considering how powerful the libraries and compiler already are, with time, this language could surely start to attrack VB programmers, who can already do OOP now, but are stuck with a slow compiler that produces bulky DLL-dependent binaries ;)

Posted: Wed Jun 25, 2003 10:50 pm
by tinman
mp303 wrote:I don't think it's possible to implement this kind of functionality with a library - and the compiler itself is not open or
Of course you could. Both Windows and Amiga OSes have OO functionality and both rely on the passing of messages to tell the objects what functions to call or what properties to retrieve. That kind of thing is pretty easily done in a library.

Posted: Thu Jun 26, 2003 10:08 am
by mp303
Uhm, I don't mean the underlying implementation, which is of course extremely easy to support - I mean the integration with the language ... the only thing you can do with PB libraries, as far as I'm aware, is add functions? ... so you would have a library with functions like CreateObject, DeleteObject, CreateClass etc. - and yeah, that would work, but the code would be completely unreadable, and you'd be spending most of your time writing these command names instead of writing code ;)

I think an actual language extension is required. But seeing as how Structs already support specialization (e.g. you can base one Struct on another), all that's really required is:

- the ability to associate functions with Structs.

- to allow "overriding" of associated functions, e.g. replacement of an associated function, in a specialized Struct, with a different function.

This would already allow object-oriented programming, provided that you perform stuff like construction and destruction calls manually. You could already create inheritance, for example, simply by hiding the parent Struct's functions with new ones, as the new ones could manually call the parent Struct's functions if necessary.

I can't imagine it would be much work to extend the compiler and language with these few simple additions, and it would already allow basic object oriented programming, since you could logically tie your data and your functionality together ... third-party includes would be usable right out of the box, since you'd only have to look at the Struct declarations to know which functionality (Functions) to use with what data (Structs), and not have to read lengthy verbal descriptions by the author first :)

Posted: Thu Jun 26, 2003 10:51 am
by GedB
You can get almost all of the benefits of OO using DLL libraries.

1) Encapsulation:
The DLL exposes a set of functions. This is your interface.

2) Polymorphism:
DLLs can be interchangable as long as they support the right interface.

3) Inheritance:
Like the VB bods you can achieve inheritance through composition.

http://www.larrymusa.com/vboop.asp

Sure, this is not true inheritance, but inheritance is one of the most abused concepts in OO. All of the OO gurus recommend that Composition should be favoured over inheritance:

http://medialab.di.unipi.it/web/IUM/Pro ... abuse.html
http://c2.com/cgi/wiki?CompositionInsteadOfInheritance
http://saturn.cs.unp.ac.za/~peterw/obje ... sld007.htm

Posted: Thu Jun 26, 2003 10:57 am
by freak
@mp303:

The point here is not how much work it would be, to make PB an OO
language.
This is a Basic language, and OOP just isn't 'basic', sorry.

The fact is, Fred said, he will maybe build an Interface like thing to
easily access OOP stuff, but PB itself will NEVER be OOP, you can be
sure of that.

If you want to do real oop programming, you have to stick with another
language.

Timo

Posted: Thu Jun 26, 2003 3:01 pm
by mp303
freak,

I know what fred said, and what I just told you is, I wouldn't want PB to be an OOP language - if I wanted to do real OOP, I'd be using C++, Java, Delphi ... basically, all I'm asking for is the ability to tie a method to a Struct - and according to fred's last comment, he'll need to implement Struct\Function() anyways to support ActiveX ...

At least, if we had this feature, it would be possible to organize your code in an object-oriented fashion - as GedB pointed out, you don't need an OOP language for that.

To summarize: I wouldn't like PB to become an OO language - you're perfectly right, it shouldn't be, because basic is supposed to be a language that non-programmers can learn ... the OO concepts are too complicated for most beginners, and unnecessary for the small projects that they implement. But the simple ability to tie functions to structures isn't going to change anything - it will enable us "object thinkers" to organize our projects in an object-oriented fashion, and the code would still be readable by non-OO programmers.

I don't understand why you're so eager to throw us OO people out of your little Basic club? :) ... I've been programming for about 15 years, and although I have plenty of experience with many other languages, I always come back to Basic - I love basic, it's clear and simple and human-readable, and that has to appeal to everyone ... on top of that, the PB implementation is flexible and fast too - extremely appealing, especially for realtime applications. But OO also appeals to me, and currently I can't have both...

GedB,

sure, okay, you could implement an entire DLL for every class ... you could manage everything manually, keep notes, use naming conventions for your structs and functions etc. etc. but then it might be easier to just get over it and program in C++ instead ;)

Posted: Thu Jun 26, 2003 4:41 pm
by GedB
mp303,

Oh no, you'd never want that approach. No way. My point was that you could use DLLs to achieve the type of objectives you'd normally use OO for - as you say.

Posted: Thu Jun 26, 2003 4:55 pm
by mp303
I see, but still ... it would be nicer to have the language support - especially for beginners who wanted to try out some basic OOP without having to learn about DLLs first. As a beginner, I think I would prefer to learn about programming first, and operating-system technology later, if at all ;)

Posted: Thu Jun 26, 2003 5:13 pm
by GedB
Hmmm,

Personally I use PureBasic purely for the low level stuff, so perhaps I am being selfish. I appreciate the lack of clutter.

Perhaps I am being a little selfish...

Posted: Thu Jun 26, 2003 5:36 pm
by freak
@mp303

> I wouldn't want PB to be an OOP language ...

Hum, so i got you wronhg on that point, it sounded to me like you wanted exactly that, sorry.

> I don't understand why you're so eager to throw us OO people out of your little Basic club? :)

:lol:
I don't want to throw anybody out, it is just that this whole discussion has
been around here many times, and always with the same arguments on
both sides, and always with the same end. I'm getting a little tired of that,
that's all

Timo

Posted: Thu Jun 26, 2003 7:53 pm
by wcardoso
Hey guys, dont fight anymore!!. All we love the compactness and simplicity of PB, and those who love OO style are good boys too. The answer is use the right tool for the programming task in hands, that is if you can solve with procedural style compilers (PB) great!; but if you need some OO characteristics then use another tool like RealBasic, QBasic, Delphi, etc.
Please dont blame the OO style people, after all the humans are "OOLS", or Object Oriented Life Specie. All we have properties (hair color, age, name...), data (our memory, training, remembers...), methods (eat, walk, talk...), inheritance (our childrens), ancestors (our parents), etc, etc.
What I try to show is OO is a natural thing, and all the complexity reside in the way to explain the abstract concepts in a natural way. :P

Posted: Fri Jun 27, 2003 1:38 am
by mp303
freak,

what arguments? ... all I've heard so far from your side is "Fred says" and "OOP isn't Basic" ;)

you're right though, OOP isn't basic - it's not a language at all - it's a way of thinking, an approach to well-structured analysis, design and programming, but it is a concept that can be applied to any programming language, including of course Basic ... all I'm arguing for is the freedom of choice - if you don't want to do OOP, that's up to you, but even so, I think you would find it useful to be able to tie your procedures to your structs? I could use it for OOP, and you could use it simply to avoid confusion in your code about which functions were supposed to operate on what structures.

in short: the language does not have to be object oriented, in order for a programmer to be able to write object-oriented code in it. And I repeat: I don't want to PB to become an object-oriented language - but I WOULD like the freedom to choose for myself how I want to structure MY programs, and the simple ability to tie a function to a struct would give me this freedom - without taking anything away from you. Please, let me hear your arguments against THAT? :)

Posted: Fri Jun 27, 2003 3:23 am
by El_Choni
after all the humans are "OOLS", or Object Oriented Life Specie.
I am not an object! I am a free number! :D (any Prisoner fan out there?)