Classes in PureBasic

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
idle
Always Here
Always Here
Posts: 5835
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Classes in PureBasic

Post by idle »

All I'd like to see added regarding classes is automated function assignment and public variables to Interfaces
so we don't have to manually write vtable entries in a datasection or poke them in memory
and can access a classes public vars through it's interface rather than calling a function
I don't think either of those would be to difficult to implement.

I'd much prefer to see the compiler getting enhanced to increase it's use cases, rather than the team adding libraries
things like unsigned types, bit fields, native static libraries and extend the macro preprocessor abilities.

Advanced features don't preclude beginners uses of the language but when an advanced user hits the wall
they'll just move on to another general purpose language and eventually leave.
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Classes in PureBasic

Post by luis »

idle wrote: I'd much prefer to see the compiler getting enhanced to increase it's use cases, rather than the team adding libraries
things like unsigned types, bit fields, native static libraries and extend the macro preprocessor abilities.
Advanced features don't preclude beginners uses of the language but when an advanced user hits the wall
they'll just move on to another general purpose language and eventually leave.
I agree 110%.

Libs are nice, even if sometimes in PB are overly simplified or at least what it's exposed is.
They are nice to have and certainly are one big point especially for beginners, but a more versatile compiler and a more versatile language it's a lot better then more and more libraries added all with some shortcoming.
They are also nice from a certain point of view because their presence tends to standardize the way some problems are solved and they reduce external dependencies when code is posted in the forum.
Using the pre-cooked libraries code can be shorter and easily testable and "recognizable" by anyone.

But in end for me they are first of all a nice cushion to have to try quick and dirty solutions in a hurry or to prototype something, when they fits good enough.

Give me a better tool I can use to write what I need as I see fit.

That's what a language should be first of all.

The order should be IMO:

1) the language... the best possible

2) the compiler... the best possible for that language

3) the "standard library" ... a nice help to have but probably to be used sparingly in some real projects where quality counts more then development time.

So I would like too to have more efforts spent on 1 and 2.

Also, for point 3: less stuff extremely versatile is better then 100 libraries missing important stuff and usable only for some scenarios, and being less it would require less work to be ported on the 3 oses and hopefully would have less bugs, and if any for less time.

But I'm sure other people likes just the opposite, and PB clearly will continue to go its way, so it's just to talk a little between us while at the bar/pub.
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
idle
Always Here
Always Here
Posts: 5835
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Classes in PureBasic

Post by idle »

If there was the native ability to make static libraries and PB libs
then we the users could add libraries rather than the team, I don't see the logic in the team expending their time adding libraries
it'd be better spent focusing on addressing the short comings that prevent us from doing it ourselves and then let the user community do it.
I don't mind the zimmer frame approach of bolting on libs, they're most welcome but I'd really like to see the compiler get more wheels
and become truly general purpose rather than having to resort to fasm and fasm macros whenever there's something the compiler can't do.
I appreciate the effort the team puts into PB but I'd really like to see more effort put into addressing advanced users requests
classes being one of them and it wouldn't be to difficult to do it, excluding polymorphism.
the compiler already has the ability to handle encapsulation and inheritance so why not polish it up a little.
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
skywalk
Addict
Addict
Posts: 4210
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Classes in PureBasic

Post by skywalk »

I expect big changes now that M$ is open sourcing .NET and targeting cross compilation with clang and llvm. Maybe PureBasic can benefit from the same technologies?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Classes in PureBasic

Post by Danilo »

skywalk wrote:I expect big changes now that M$ is open sourcing .NET and targeting cross compilation with clang and llvm. Maybe PureBasic can benefit from the same technologies?
What do you expect? I don't expect anything from it. PB had never ever a connection to .NET nor LLVM,
and the hundred-thousands of methods in .NET classes are best used with an OOP language. Actually, it is
the thing we are talking about here.
PB is one of few tools that still resists to add additional OOP (Classes, Methods, Inheritance, automatic Constructors/Destructors).
User avatar
skywalk
Addict
Addict
Posts: 4210
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Classes in PureBasic

Post by skywalk »

Not the .NET stuff. That is bloatware that trails Java bloatware. I mean VS 2015 will have targeted compiles for arm and linux, etc. using clang and llvm. If it is good enough for MS, why wouldn't PB consider a similar approach?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Classes in PureBasic

Post by PB »

Before someone edited their post, they mentioned PureBasic is slow to
evolve and won't embrace the future for various reasons. Well, to be
frank, that's why I bought the language. Basic is Basic. It's not OOP.
It's not meant to be OOP. It's not meant to be some sort of gee-whiz
Super Basic with OOP elements.
It's the Basic that we dinosaurs know
and love. :P

If someone wants OOP, then they're in the wrong place. But don't try
to change what's here just because it's not what you expected. Keep
searching instead for the OOP language (with classes) that satisfies
your needs. Can't find one? That's your problem, not Fred's. Simple.

Comprehend: http://www.purebasic.fr/english/viewtop ... 35#p403070

Now, get over this whole OOP and classes whining. It's old. So old.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Classes in PureBasic

Post by Danilo »

PB wrote:Well, to be frank, that's why I bought the language. Basic is Basic. It's not OOP.
It's not meant to be OOP. It's not meant to be some sort of gee-whiz
Super Basic with OOP elements.
It's the Basic that we dinosaurs know
and love. :P

If someone wants OOP, then they're in the wrong place.
Sorry, but VB6, VB.NET, BlitzMax, Monkey-X, Xojo (formerly known as RealBasic),
all support some kind of OOP. AFAIK PureBasic is the only modern product that
does not support object-oriented programming (letting QuickBasic aside, it isn't considered modern anymore).
Remember, this is on top of procedural PB, it is an addition and wouldn't change procedural PB in any way.
It would be an addition, and PB would greatly benefit from it.
Last edited by Danilo on Sun Nov 16, 2014 6:57 am, edited 1 time in total.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Classes in PureBasic

Post by PB »

> VB6, VB.NET, BlitzMax, Monkey-X, Xojo (formerly known as RealBasic)

Of those, VB6, BlitzMax, and Xojo are dead, so they don't count.

That leaves VB.NET and Monkey-X. VB.NET is Microsoft, so that
will probably last due to financial help. Monkey-X is by the same
author of BlitzMax, so how long will that last?

> It would be an addition, and PB would greatly benefit from it

Like I said, PureBasic is not meant to be some sort of gee-whiz
Super Basic with OOP elements. It's just Basic. Old-style Basic.

If Fred agreed with you, he wouldn't have posted this:

"PureBasic won't be object oriented, period."
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Classes in PureBasic

Post by Danilo »

PB wrote:Of those, VB6, BlitzMax, and Xojo are dead, so they don't count.
The result is the same, PureBasic is the only one not supporting OOP actively.

ALL modern languages are OOP, or support OOP style for a reason.

Anyway, not my probem. Just installed latest BlitzMax, Blide, and all of Brucey's addon-modules, including wxMax.
Last edited by Danilo on Sun Nov 16, 2014 7:11 am, edited 1 time in total.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Classes in PureBasic

Post by PB »

> PureBasic is the only one not supporting OOP actively

That's what makes it stand out and above the others. ;)

Anyway, I won't lock horns with you anymore. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Classes in PureBasic

Post by luis »

PB wrote:Before someone edited their post, they mentioned PureBasic is slow to
evolve and won't embrace the future for various reasons.
I always save the brutally sincere Danilo posts in their original forms when I can before they get edited, I don't like them as much after the edits :wink:
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: Classes in PureBasic

Post by Shield »

Alexi wrote:[..]will donate much more for an actively maintained language [..]
Myself, I'm unfortunately well past this point. I would have done it a couple of years back when I still had a code base in PB.
But I wonder how many other people think that (e.g. how much $$), though it won't probably matter anyway. :)
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Re: Classes in PureBasic

Post by fsw »

How about implementing OOP into PureBasic in a similar fashion as Go?
Go is not an OOP language but has all the tools to extend types with functions.

For starters only a few additional keywords are needed. Self and SelfType.

Example of working code (with implemented semi-OOP):

Code: Select all

Structure Animal
  Name.s
  mean.b
EndStructure

Structure Cat Extends Animal
  MeowStrength.i
EndStructure

Structure Dog Extends Animal
  BarkStrength.i
EndStructure
  
Procedure MakeNoise() Extends Animal
  
  If Self.mean = #True
    If SelfType = Cat
      Self.MeowStrength = 10
    ElseIf SelfType = Dog
      Self.BarkStrength = 10
    EndIf
  EndIf
  
EndProcedure


Or

Procedure MakeNoise() Extends Cat
  
  If Self.mean = #True
    Self.MeowStrength = 10
  EndIf
  
EndProcedure

Procedure MakeNoise() Extends Dog
  
  If Self.mean = #True
    Self.BarkStrength = 10
  EndIf
  
EndProcedure
If the implementation also allows overrides than the procedure "MakeNoise() Extends Cat" would override "MakeNoise() Extends Animal".

Also if things like constructors and destructors are really needed, this:

Code: Select all

Procedure Init() Extends Animal
  ; constructor
  ; do something
EndProcedure

Procedure Exit() Extends Animal
  ; destructor
  ; do something
EndProcedure
would cover it.
(Or extend Cat/Dog)

Super complicated OOP techniques and keywords are not needed to facilitate OOP programming style.

In the end only 4 new keywords would get you a long way...

Easier said than done :wink:

I am to provide the public with beneficial shocks.
Alfred Hitshock
coco2
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Nov 25, 2013 5:38 am
Location: Australia

Re: Classes in PureBasic

Post by coco2 »

I dislike OOP because it takes programming to too high a level. BASIC to me means getting 'down and dirty' on the mud with your hardware and OS, not prancing about up in clouds or rainbows! Boooo to OOP and yes I know how to use it :)
Post Reply