Easy object oriented programming (just look at my example)

Got an idea for enhancing PureBasic? New command(s) you'd like to see?

Was this a good idea?

Yes.
50
56%
No.
19
21%
Maybe.
20
22%
 
Total votes: 89

PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> the given would be no change of the language but only an additional feature.
> All we ask for is BASIC support for OOP.

Perhaps my reply was a bit aggressive and ill-informed. My understanding
was that OO would totally change the way PureBasic is. If this is not the case,
and it just becomes another library or something, then no, I'm not against
that sort of addition to the language. So I apologize for my stance, but I
thought it would mean the end of PureBasic as I knew it. :shock:
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post by freedimension »

PB wrote:> the given would be no change of the language but only an additional feature.
> All we ask for is BASIC support for OOP.

Perhaps my reply was a bit aggressive and ill-informed. My understanding
was that OO would totally change the way PureBasic is. If this is not the case,
and it just becomes another library or something, then no, I'm not against
that sort of addition to the language. So I apologize for my stance, but I
thought it would mean the end of PureBasic as I knew it. :shock:
No, definitely not. If it were like that I for myself would fight as hell against that change, believe me. But as it would only be a rather "small" addition to the compiler, like Structures, Linked Lists and the like, you don't have to fear anything.
In contrary, perhaps with this new feature, you could learn step by step with an easy syntax a little OOP programming without diving into C++/C# or Java directly. Many people programming in PB (like myself) have learnt a lot of programming with the Windows API that way, why not expand that experience to another horizon, namely OOP?
<°)))o><²³
aaron
Enthusiast
Enthusiast
Posts: 267
Joined: Mon Apr 19, 2004 3:04 am
Location: Canada
Contact:

Post by aaron »

OOP stuff is horrid. The example given at the start of this thread is just as readable and useful with a procedure based coding style, possibly even more so. Maybe I'm a little crusty (a C and ASM programmer from way back), but I just don't see the lure of object oriented code. The real OO compilers (C++, java, C#?) end up generating larger slower code than procedure based languages (such as C and Purebasic in most cases). Next you'll want to be adding garbage collection and some other crud like overloading (ARG!).

I voted with my money for a clean pure non-object oriented programming language when I bought purebasic. If object oriented features can be added so that I don't have to touch them and they don't increase code size or slow program execution because of compiler tradeoffs due to supporting OO, then I could care less if it is put in or not. If it affects my code and programs though, then we'd have a bit of a problem.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

aaron wrote:The real OO compilers (C++, java, C#?) end up generating larger slower code than procedure based languages (such as C and Purebasic in most cases). Next you'll want to be adding garbage collection and some other crud like overloading (ARG!).
Absolutely right :!:
aaron wrote:...If it affects my code and programs though, then we'd have a bit of a problem.
Of course, me too. I'd go back to use 3.93 version.

The ONLY advantage i see on OOP is that when a project is abandoned by any programmer/s, it can be taken easier by a new programmer.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

The issue is, you can do everything you can do in OO using non OO programming!

If something is too complex to code without OO,
then it's probably to complex to code with OO as well.

I can't help to feel that clases, instances, inheritance of object properties etc
just adds overhead, uses much more memory.
And allows more sloppy coding.
(since a child object inherits the parent object properties)

Another issue is that PB is a non OO language,
adding OO would basically split PureBasic in two.
at worst two separate compilers would be needed to get the most out of non OO (classic) and OO compiling.

If the only reason for wanting OO is for self contained objects that holds all it's own values and functions,
then that can be done using normal procedures and dynamically structures.
in fact, on the lower level (lower than the OO layer that is) that is probably what is done internally by a compiler anyway.

I can't help but feel that custom solutions for a big game would be much better than using a stanard OO system that most likely have certain limitations.

Remember that a OO implementation would limit you to using that implementation, and not all solutions would be always the best.
And once added, it can't really be "removed" either.

To me (using PHP as the example here) I have used classes
even before the PHP5 OO makeover.
However being able to connect to 4 servers at once using 4 instances of the same class, can as easily be achieved by using libraries and threads,
or procedures and dynamically allocated structures.

Another issue is it would add a large complexity layer to PB for beginners,
OO is hard to grasp fully (I'm just fumbling around).
And it would be a pain to see beginners fiddling with OO example snippets and code posted on the forums,
when pretty muchthe same could be achieved using somewhat easier code.

And the example at the start here, looked very much like nesting of arrays/structures etc to me :)

Btw! is it possible to "call" a procedure using a pointer?

i.e.

structure myoo
*methoda
*methodb
endstructure

and simply populate that with @myprocedure
and then "call" the methods.
That would allow swapping the procedure pointers
on structure instances allowing very dynamic code :)

You know, OO coding without a OO version of PureBasic :P
Leonid
New User
New User
Posts: 2
Joined: Sat Feb 19, 2005 12:57 pm
Location: Israel

Post by Leonid »

aaron wrote:I voted with my money for a clean pure non-object oriented programming language when I bought purebasic.
I am a C-programmer too and am united with Aaron completely.
Leonid.
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post by LarsG »

I say GO OO! :D

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

The following is from http://searchwin2000.techtarget.com/sDe ... 81,00.html
The concepts and rules used in object-oriented programming provide these important benefits:

* The concept of a data class makes it possible to define subclasses of data objects that share some or all of the main class characteristics. Called inheritance, this property of OOP forces a more thorough data analysis, reduces development time, and ensures more accurate coding.
(This is basically default values, optional procedure arguments with default values, plus macros would handle all this I think or?)
* Since a class defines only the data it needs to be concerned with, when an instance of that class (an object) is run, the code will not be able to accidentally access other program data. This characteristic of data hiding provides greater system security and avoids unintended data corruption.
(In PureBasic this is acalled "Protected" see docs about Procedure usage)
* The definition of a class is reuseable not only by the program for which it is initially created but also by other object-oriented programs (and, for this reason, can be more easily distributed for use in networks).
(With PureBasic we have include files, PB libs, dlls, copy'n'paste Procedure snippets etc.)
* The concept of data classes allows a programmer to create any new data type that is not already defined in the language itself.
(In PureBasic custom data types are called structures aren't they:P)

I'm sure some of you more experienced PB coders can give better PB comparisons to OO "benefits" than I just did.
So I'm requesting that. Shouldn't be that hard.
even I was able to counter at least half of the concepts/benefits that OO has. (per that article at least).
Bonne_den_kule
Addict
Addict
Posts: 841
Joined: Mon Jun 07, 2004 7:10 pm

Post by Bonne_den_kule »

I don't want OO PB, but it could be nice with a RAD IDE, which makes it easyer to make multiwindow programs.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Leonid wrote:
aaron wrote:I voted with my money for a clean pure non-object oriented programming language when I bought purebasic.
I am a C-programmer too and am united with Aaron completely.
Leonid.
NOTE: (As i understood) Aaron is not saying NO to OOP in PB :!:
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Leonid
New User
New User
Posts: 2
Joined: Sat Feb 19, 2005 12:57 pm
Location: Israel

Post by Leonid »

Psychophanta wrote:(As i understood) Aaron is not saying NO to OOP in PB :!:
I am here only from February and can not say NO or YES.
I can only leave PureBasic (unfortunately)
if it will be OO language.

But now, without OOP, I like this new Language ....
Leonid.
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post by freedimension »

You all just don't get the point :(

With what we have in mind

- you don't have to use OOP
- you don't have to learn OOP
- the PB-Core-API wouldn't change (meaning the Libraries)
- your code without OOP, wouldn't make you suffer any drawbacks

but

- you would have the possibility to use OOP for larger Projects, if you like to
- beginners could learn something about OOP (but they wouldn't have to)
<°)))o><²³
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Post by fsw »

freedimension wrote:You all just don't get the point :(

With what we have in mind

- you don't have to use OOP
- you don't have to learn OOP
- the PB-Core-API wouldn't change (meaning the Libraries)
- your code without OOP, wouldn't make you suffer any drawbacks

but

- you would have the possibility to use OOP for larger Projects, if you like to
- beginners could learn something about OOP (but they wouldn't have to)
8)

But it's already possible with 'INTERFACE' and 'STRUCTURE'.
And there are some examples (how to do it) in this forum...
The only thing left to do is to take the code ( from the examples...) and make reusable commands out of it...

Or am I missing something :?:
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

I've been playing with OO in Purebasic for some time, and I don't think it is a good idea.

If you want to compile small efficient executables using objects then go with one of these:

http://smarteiffel.loria.fr
http://www.lingolanguage.com
http://caml.inria.fr/

If you want to keep it clean and simple, stay with Purebasic.

The strange thing is that OCAML and Eiffel are French. Lingo isn't far away in the Channel Islands.

What is about the French and their clever compilers?
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

A lot of talented coders in France. like Splinter Cell: Chaos Theory it's being made in France btw.
Post Reply