Some notes after my first PureBasic experience

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Some notes after my first PureBasic experience

Post by Lunasole »

Dear Fred. I knew about PB a years ago (ten or around it), but didn't used before.
But recently I have planned some game project, so after checking a lot of modern languages stopped on PureBasic.
I think It's just great & beautiful (already wrote some complete utils on it to become more familiar), I very appreciate the high level of optimization, BASIC language itself, native compilation using good old FASM and many others stuff including full support for three key platforms, 64-bit architecture and other modern.

There are also Python, it has some advantages, but in fact just another poor scripting language, which is too high-level, too unoptimized, and misses compilation to machine code.
Also there was Visual Basic 6 (which I used for years to write small desktop apps, etc, and sometime still using) - it has very cool and smartest IDE I ever seen, also debugger/interpretator that allows rewrite code "on fly", also partially supports native and has some other nice stuff. But for now it is abandoned, very slow, no multithreading support and lack of many features that PB has.

I'm not describe those two here just for fun. Both of them with all their complex of minuses support some feature that PB critically lack as language usable in game development - yes, that is OOP.

I've read some time Fred said:
>It will stay a procedural BASIC, I don't plan to add class and such I think it will split the PB world in 2 classes (!): the one which have understood fully how OOP work and other which don't. Which means than you couldn't share source codes easily anymore at one place. Procedural and Object Oriented Programming are two opposite concepts and it's not a good idea to mix them in a BASIC language (which is intended for beginners...)

For that I want to bring example of VB6 which has partially OOP realization so far ago as well as procedural concept (mixed it all together). And it is language for beginners too (exactly "was", now it is almost dead due to MS desire. but you know how popular it was in 200x). So I disagree that newbies cannot deal with OOP, common usage of which (classes, etc) is even simplest than procedures and arguments/pointers.
The other meaning is that beginners anyway grow up and come to necessity of some OOP usage in some tasks - this saves time and efforts A LOT. You just cannot (almost impossible) build games like Terraria, Starbound, Minecraft (please take a look at them, they are old-school enought 8) ) without using OOP. It is simply ridiculous to try program all the stuff from such games without using object system. So modern trends are all up to OOP, just no need to use it everywhere when it not needed like C++ propagates.

Another bright example of OOP usability from my own experience is "binary tree" algorithm. It is complicated enought to implement it using functions only, but using objects makes it work in a couple of lines.

And of course, some personal reasons. I just cannot complete my game (working single) in some adequate time if I try to make all the code using functions only. For now all experiments stopped because of that, so thats one reason why I'm here.
The second reason Is that I really loved PB for its speed and usability and lot of STL functions, but it lacks even basic OOP capabilities and this is very sad and bad (I've already tried some users solution from this forum, but old links are dead, some tools & precompilers I've found are abandoned and don't work with PB 5).

Well, seems that's all I wanted to say here about objects.
Please add some OOP if you still have some inspiration, I'm sure PB will only gain a competitive advantage from this and users will have more opportunities for doing serious things.
With a best wishes, from a far country Ukraine [and sorry for my english, not native-speaker :3]

PS. Also there was some issues with forum - I was not abble to register using local mail providers [ukr.net, mail.ru].
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

Re: Some notes after my first PureBasic experience

Post by heartbone »

It has all been stated before so let's go there.

http://blog.jot.fm/2010/08/26/ten-thing ... nt-page-2/
http://blog.pivotal.io/labs/labs/all-ev ... g-bullshit
http://www.infoq.com/news/2010/07/objec ... alk-erlang
http://zaemis.blogspot.com/2009/06/what ... h-oop.html
http://www.gamedev.net/topic/621939-wha ... -with-oop/

If the written thoughts of the haters isn't enough to convince you that you may be a victim,
then these well spoken and well reasoned logical thoughts of the OOP proponents surely should be.
OOP: You’re Doing It Completely Wrong (Stir Trek Edition)
Keep it BASIC.
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Some notes after my first PureBasic experience

Post by StarBootics »

Vade retro OOP !!!!!
The Stone Age did not end due to a shortage of stones !
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Some notes after my first PureBasic experience

Post by Dude »

Fred wrote:PureBasic won't be object oriented, period.
Source: http://www.purebasic.fr/english/viewtop ... 35#p403070
You're gonna need another language.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Re: Some notes after my first PureBasic experience

Post by GPI »

Dude wrote:
Fred wrote:PureBasic won't be object oriented, period.
Source: http://www.purebasic.fr/english/viewtop ... 35#p403070
You're gonna need another language.
Fun Fact - Purebasic *can* handle oop. Only the object-Managment is missing.

i wrote a code for the object managment:
http://www.purebasic.fr/english/viewtop ... 12&t=63132

My personal opinion: Freds statement is stupid. With Interfaces PB support oop. It would be so simple to add full OOP-Support. It doesn't need the complexity like in C++ with operator overloading and two parents.
sys64802
Enthusiast
Enthusiast
Posts: 105
Joined: Sat Sep 12, 2015 6:55 pm

Re: Some notes after my first PureBasic experience

Post by sys64802 »

I'm happy people is still asking for OOP in PB (and as GPI said, it could be just a really a simple version of it and it would be more than enough) because it shows how much it is missed.
And again ad GPI said, it's already there thanks to interfaces, it's just ugly and difficult to use and using macros like GPI did make me cringe with the result... some good gray matter wasted for that when we could have something better, properly implemented with a clean syntax without the need of using a preprocessor.

And in any case the biggest thing we can't do by ourself is making objects automatically deallocate when going out of scope. That's the main thing the compiler could do for us to fill the gap like already does for normal variables.

But on the other hand what is more practical ? Trying to bend the granitic mind of its author who will prefer to lose an arm than implement OOP in PB or chose another language and forget about PB ?
The paragraph you quoted says it all.

I think the second solution makes more sense, fortunately for you PB is the exception, the norm is to have some form of OOP in other languages, so just use another one.

It would be nice to have but don't waste time and energy on it, go with the flow and go were OOP is already appreciated.

Thanks for trying, at any rate :P
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: Some notes after my first PureBasic experience

Post by Lunasole »

sys64802 wrote: But on the other hand what is more practical ? Trying to bend the granitic mind of its author who will prefer to lose an arm than implement OOP in PB or chose another language and forget about PB ?
I'm not going to get his mind (except of created this thread already) any further, also anyway will not change PB to some other, because really liked it and hope to find "unofficial" solution (like GPI posted, nice & beautiful hack, but of course compiler support would be better). Also I think the one language which can to alternate PB by all paramethers is C++ only, but it is really complicated and bureaucratic and I'm sick of it.
Just tried to remember that here is 2015 and games are not written in pure functions and hardcore ASM anymore.

Also for Fred/Timo there are ways to not officially add OOP to PureBasic - just publish separated modified version of compiler or something like that and see what happens.
Last edited by Lunasole on Mon Oct 26, 2015 6:46 pm, edited 1 time in total.
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
User avatar
blueb
Addict
Addict
Posts: 1111
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: Some notes after my first PureBasic experience

Post by blueb »

:D
Happiness is not another place, but this place.
Not another hour, but this hour.
~ Walt Witman.
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Some notes after my first PureBasic experience

Post by Dude »

The author has said no to OOP, but people continually come here and try to convince him to do it, over and over and over. It literally never ends. There's a *million* threads like this. It's annoying as hell to see it come up so often. Everything said in this thread, has been said before. The OOP fans should just accept the author's decision and move on.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Re: Some notes after my first PureBasic experience

Post by GPI »

decision can be changed - and PB support OOP, but only in a bad way.
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Some notes after my first PureBasic experience

Post by c4s »

+1 for light improvements on the already present bits and pieces of OOP support (as GPI suggested). I really see no downside if PureBasic's box of programming tools gets enhanced.


@Dude
Honestly, those who are strictly against any kind of OOP in PureBasic seem to be the vast minority compared to those who are in favor. I'd say that's good, because in a broader sense only those who are able to quickly adapt to a changing and more complex environment will "survive". After all that is what's making the human species so successful... So obviously no good decisions are made forever -- rather they are reviewed and adapted!
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
TI-994A
Addict
Addict
Posts: 2704
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Some notes after my first PureBasic experience

Post by TI-994A »

c4s wrote:...in a broader sense only those who are able to quickly adapt to a changing and more complex environment will "survive". After all that is what's making the human species so successful...
Complexity aside, you're implying that the OO model is a good thing; not true.

Nevertheless, the real survivors should have no trouble adapting to C++ then. :wink:
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Re: Some notes after my first PureBasic experience

Post by GPI »

TI-994A wrote:Complexity aside, you're implying that the OO model is a good thing; not true.
OOP is a tool like everything else. It depends what you do with it. For example the destructor of an object is a powerful tool, which can help to find mistakes like not closed files.

for example:

Code: Select all

Procedure Test()
in=readfile(#pb_any,"test.txt")
if in
  a$=readstring(in)
  if a$<>"Version 1.0"
    procedurereturn #false
  endif
  [dosomething]
  closefile(in)
endif
endprocedure
Here i forget a closefile before procedurereturn. Such a bugs can be difficult to find. Next time when i open the file test.txt it will fail, because it is already open.

With an file-object it would be diffrent. The object will be destruct on procedurereturn and the destructor can check the handle - if it is open, it can output on the debug "missing close!" and can close the handle. Same thing for memory-buffers. It could detect, if you forget to free the memory. At the moment you haven't any chance to detect this or where. You only run out of memory after some time.

__________________________________________________
Quote-Tags repaired
27.10.2015
RSBasic
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Some notes after my first PureBasic experience

Post by Danilo »

Dude wrote:The author has said no to OOP, but people continually come here and try to convince him to do it, over and over and over. It literally never ends. There's a *million* threads like this. It's annoying as hell to see it come up so often. Everything said in this thread, has been said before. The OOP fans should just accept the author's decision and move on.
People are free to ask for any new features in this forum section.

If so many customers ask for something over and over and over again...
...it shows demand and should make Fred think about it - over and over and over again...

As has been said before: If new feature requests get implemented because of demand,
it does not take any current feature from you.

It is one thing to allow any such feature requests. Allow other people to ask for something they may like.
On the other hand, I agree that it may be better to move on, instead just waiting another 15 years for a feature
that is at least very unlikely to get implemented anytime soon (refering to Fred's comments).

Asking should still be allowed, otherwise PB Team couldn't see demand for specific things.
User avatar
TI-994A
Addict
Addict
Posts: 2704
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Some notes after my first PureBasic experience

Post by TI-994A »

GPI wrote:OOP is a tool like everything else. It depends what you do with it. For example the destructor of an object is a powerful tool, which can help to find mistakes like not closed files.
Firstly, OO is a programming paradigm; not a tool. And just as is the case with any programming model, OO has its fair share of pros and cons.

The example you cited stems from programmer-error. While class destructors can be good resource managers, classes can also be a major source of bugs that are far more tedious to trace.

Moreover, if a programmer is prone to such trivial errors to begin with, the OO model might quickly prove to be a bane rather than a boon.
Danilo wrote:Asking should still be allowed, otherwise PB Team couldn't see demand for specific things.
No arguments there. Feature requests should be an integral part of any successful product; albeit in a courtly manner.

And the decisions of the development team should be respected; not mocked. :D
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Post Reply