OOP Support (it is time)

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
X
Enthusiast
Enthusiast
Posts: 311
Joined: Tue Apr 04, 2006 6:27 am

Re: OOP Support (it is time)

Post by X »

What if Fred developers a OO PB compiler and charges x2 the cost of the current PB compiler, as well as annual maintenance cost? Would that be ok? I've been looking around forever for a 1/2 way decent OO Basic language w/o a runtime. PB seems the only candidate with that possibility.
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

Re: OOP Support (it is time)

Post by PMV »

DaylightDreamer wrote:But i think it is really time to add unless partial OOP support in it.
There is "partial OOP support" ... known as "Interface" like Trond has
posted it. If you need more "OOP-like"restrictions, then you need
another language.

MFG PMV
Marlin
Enthusiast
Enthusiast
Posts: 406
Joined: Sun Sep 17, 2006 1:24 pm
Location: Germany

Re: OOP Support (it is time)

Post by Marlin »

PMV wrote:There is "partial OOP support" ... known as "Interface" like Trond has
posted it. If you need more "OOP-like"restrictions, then you need
another language.
As far, as I'm concerned, it is not about restrictions at all,
but about an easy way for clean, orderly programming.

Looking at Tronds example above, I see a lot of fussing around,
with code distributed all over,
something, people like me, would need a very, very good reason to use at all.

Now, do have a look at the Procedures inside Structures thread
and see, how nice and easy it can be ...
If liberty means anything at all, it means the right to tell people what they do not want to hear.
- George Orwell
User avatar
skywalk
Addict
Addict
Posts: 4210
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: OOP Support (it is time)

Post by skywalk »

I agree with Marlin here. Why so messy and disjointed?

And PMV :!:
PMV wrote:If you need more "OOP-like"restrictions, then you need
another language.
Why are you always so quick to send people to other programming languages?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
TomS
Enthusiast
Enthusiast
Posts: 342
Joined: Sun Mar 18, 2007 2:26 pm
Location: Munich, Germany

Re: OOP Support (it is time)

Post by TomS »

Why so messy and disjointed?

Because interfaces were added to support oop libraries and not to create oop code with purebasic.
If you want nice clean oop code, use a pre-compiler. Does it for me.
There are still parts of the oop philosophy missing, but it's a start.

Before whining in 10+ threads about a feature that Fred "allegedly" (Haven't actually seen this post, but some people here said so unanimous) said will probably never be added to PB, why don't you use some of those pre-compilers?!

And because of this (Fred's statement), I reckon PMV suggested to use another language.

Another Thread won't change Fred's mind. He's well aware of the advantages and disadvantages of OOP and he alone can decide whether to add this feature to PB, or not.
After all he's the one to maintain the code etc...

Bottom line: Stop opening anymore threads about a topic that has been discussed for years over and over again.
Use a pre-compiler like Simple-OOP or switch to, or at least use another language in addition to PB, if you think, you can't live without OOP.
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Re: OOP Support (it is time)

Post by Guimauve »

skywalk wrote:Why are you always so quick to send people to other programming languages?
The answer is very simple. Fred have tell all of us the fact that PureBasic will not become an OOP language sooner or later. It's very annoying to read an Features Requests about OOP over an over again.

OOP does not guaranteed that your program will be more structured. (I have see so many OOP C++ code that are so badly coded. It's a miracle that the compiler can eat a code like that without crashing the OS it's self). When the code is just a piece of junk, it's a piece of junk whatever if it's written in C, C++, C#, ADA, ASM, Fortran, PureBasic, MatLab, Excel VBA, Delphi, name it.

The be honest I hate OOP because I don't like when a programming language restrict me like the C++ way. I prefer to restrict my self to my programming rules with PureBasic and the BOP techniques. What is BOP you say ?

Based Object Programming or if you wish Structures and Pointers and they are already supported by PureBasic. The BOP techniques has been used in C longtime ago, just before the C++ come to life. In my point of view, the BOP is perfectly suitable techniques for a Basic programming language.

So my question is :

If you like an OOP language why did you purchased or use PureBasic in the first place ?

Best regards
Guimauve
User avatar
skywalk
Addict
Addict
Posts: 4210
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: OOP Support (it is time)

Post by skywalk »

@Gimauve,
1st, this is not my topic.
I merely commented on the current workarounds and how they appear clumsy and wanted to applaud the excellent incremental suggestions to improve the encapsulation of methods.

2nd, Feature Requests is open...
There is no mention of "all requests welcome except OOP stuff!"

3rd, I never claimed OOP was my mantra of coding. Actually, I agree with you in general. Still, there is no reason OOP cannot coexist in your structured coding tool bag, if carefully applied.

Finally, my choosing of PureBasic is irrelevant.
My ignorance of, or resistance to improvements of PureBasic is not. :wink:
...waiting on 4.6++ :lol:
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: OOP Support (it is time)

Post by MachineCode »

skywalk wrote:2nd, Feature Requests is open...
There is no mention of "all requests welcome except OOP stuff!"
But when you're requesting something that has specifically, clearly and repeatedly had a "no" answer in the past in many topics, then such requests are just seen as whining. In other words, yes the feature requests is open, but not open to abuse. It's open for fresh requests, not repeated bleating.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Re: OOP Support (it is time)

Post by Trond »

Another way:

Code: Select all


Interface IPerson
  Shout(Msg.s)
  Whisper(Msg.s)
EndInterface

Structure SPerson
  *Interface
  Name.s
EndStructure

Procedure IPerson_Shout(*Self.SPerson, Msg.s)
  MessageRequester("Shout!", *Self\Name + ": " + UCase(Msg))
EndProcedure

Procedure IPerson_Whisper(*Self.SPerson, Msg.s)
  MessageRequester("Whisper!", *Self\Name + ": (shhh!) " + Msg)
EndProcedure

Procedure Person(Name.s)
  Protected *Self.SPerson = AllocateMemory(SizeOf(SPerson))
  With *Self
    \Interface = ?IPerson
    \Name = Name
  EndWith
  ProcedureReturn *Self
EndProcedure

Bill.IPerson = Person("Bill")
Bob.IPerson = Person("Bob")

Bill\Shout("Hello world!")
Bob\Whisper("Goodbye, world!")

DataSection
  IPerson:
    Data.i @IPerson_Shout()
    Data.i @IPerson_Whisper()
EndDataSection

PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

Re: OOP Support (it is time)

Post by PMV »

Marlin wrote:As far, as I'm concerned, it is not about restrictions at all,
but about an easy way for clean, orderly programming.
But it is. You can write Code with "Interfaces" like you write it in
C++. Yes, there are some missing functionality in Interfaces like
full inheritance or a missing "class"-keyword.

What the problem is, there are no restrictions in manipulating
the "interface-objects" and you can call any procedure at any point.
No restricted scopes of procedures possible.
The lack of restrictions to have to write code OOP-like is what all
are missing. You can write code like Trond has posted it. And a
second developer can change anything. Changes that shouldn't
possible in OOP.

Java is an example of a language, that has this restrictions, but
allows procedural code. So you aren't forced to use OOP, but
it is good practice. OOP is nothing special. I mean, i can write code
OOP like or procedural, it is all the same for me. Other people
can not jump between OOP and procedural. Some need OOP, some
doesn't understand the case and want procedural or something else.
If PureBasic learns OOP, i think i will use it too. Sometimes. But
for big projects, OOP is not always the best choice. It is the language
itself what makes the difference. If you need OOP, then use a OOP-
language. I doesn't have a problem, when someone doesn't use PB.
A language is nothing more than a tool. You doesn't use a unhandy
hammer if you want it handy. :wink:

What would more help than full OOP-restrictions is something like this:
Modules
:)

MFG PMV
inc.
Enthusiast
Enthusiast
Posts: 406
Joined: Thu May 06, 2004 4:28 pm
Location: Cologne/GER

Re: OOP Support (it is time)

Post by inc. »

TomS wrote:If you want nice clean oop code, use a pre-compiler. Does it for me.
And one of these Precompilers also does provide a PB-"native" Code output: http://www.purebasic.fr/english/viewtop ... 14&t=30236
So when compiling the precompiler does generate a temp codefile in the users system temp directory.
Just catch that one and you easely can use this PB-Native Codeoutput for sharing with people not having the precompiler installed like in the forum i.E.
And BTW. that codepart also enjoyed codebeautyfying like auto-indentation and auto-spacings etc.

I intended to make this "pb-oop2pb-code" translation available via functionkey in the IDE, but I stopped developing that project due to low user usage.

Cheers
Check out OOP support for PB here!
Marlin
Enthusiast
Enthusiast
Posts: 406
Joined: Sun Sep 17, 2006 1:24 pm
Location: Germany

Re: OOP Support (it is time)

Post by Marlin »

@PVM
Again: I am not talking about restrictions
and certainly not about anyone being forced to use
a certain programming paradigm.

I like PB very much as it is,
especially the speed and simplicity.

Tronds examples are quite helpful,
especially to get ideas,
but, I'd say again, I'd need a very, very good reason to use PB in such a way.
(It can not currently be without some unavoidable amount of unneeded involvement.)

Reading into this Modules thread (admittedly not in complete detail),
I get the idea, that this would require more fundamental changes.

And this is something, Fred could conceive of (some years ago). ;-)

Using precompilers, is not something that looks nice, simple and easy to me either.

The Procedures inside Structures concept does look to me like a comparably small,
but nice and significant improvement to PB,
building on what is allready there, not requiring any fundamental changes.

Just a nice and simple new feature,
no obligation to use it and no need to change any existing [user] code required.
You can put your code, where it belongs and not have issues
with naming collisions with procedures in other structures or the main source.
(This naming thing would be one of the mayor advantages.)
If liberty means anything at all, it means the right to tell people what they do not want to hear.
- George Orwell
DaylightDreamer
User
User
Posts: 52
Joined: Wed Feb 04, 2009 8:11 am
Location: Armenia

Re: OOP Support (it is time)

Post by DaylightDreamer »

I like this "the Procedures inside Structures thread" idea.
I think it solves a lot.
Yogi Yang
Enthusiast
Enthusiast
Posts: 107
Joined: Sun Dec 11, 2005 2:19 pm

Re: OOP Support (it is time)

Post by Yogi Yang »

X wrote:I've been looking around forever for a 1/2 way decent OO Basic language w/o a runtime.
Oh that is a fancy statement. Have you checked out RealBasic or for that matter the new version of PowerBasic? I don't have anything against PB but there are alternatives.
--
Yogi Yang
eesau
Enthusiast
Enthusiast
Posts: 589
Joined: Fri Apr 27, 2007 12:38 pm
Location: Finland

Re: OOP Support (it is time)

Post by eesau »

Yogi Yang wrote:
X wrote:I've been looking around forever for a 1/2 way decent OO Basic language w/o a runtime.
Oh that is a fancy statement. Have you checked out RealBasic or for that matter the new version of PowerBasic? I don't have anything against PB but there are alternatives.
RealBasic is slow and bloated. PowerBasic has syntax from the stone age and terrible support. I wouldn't call them decent alternatives.
Locked