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:

Re: Some notes after my first PureBasic experience

Post by Lunasole »

TI-994A wrote:Firstly, OO is a programming paradigm; not a tool.
Currently the clear paradigm difference between OOP and procedural doesn't exist anymore.
You can use both of them together and as result only getting more ways (and more effective ways) to solve some task, because one of them makes work with a high level of abstraction tasks (graphics, games, artificial neural networks, etc) so much easier than using pure procedures, and procedural implementations also has its huge pluses in all other tasks where OOP usage is excessive (most of regular tasks).
For example, I don't think you will be able to build any of games that I mentioned in first post without using OOP (don't even saying about much huge things, like modern 3D games and applications like Photoshop or web-browsers, etc). No one has build such for all years using clear procedural only, cause without objects realization of such projects is extremely complex.
PB as good and easy to learn language simply misses a lot of users while has no abilities that other alive languages have, cause 90% of users will not use OOP realized as precompiler or external include file found on forum, they just went out and keep using "another python or .NET or java" (because C++ is too hard for most users anyway) and then you keep wasting your CPU powers when buying, downloading and using all their apps, poorly coded on a such defective interpretative languages instead of something clear, simple and native-compiled like PureBasic.

So the rightest way would be OOP support as well as keeping procedural style. And users will decide what they will use and for what (not like in C++ with its official full OOP propaganda).
And of course we should respect authors decisions (which was made so many years ago), but sounding reasonable things is not bad too.
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Some notes after my first PureBasic experience

Post by Dude »

[Deleted. Sick of flogging a dead horse.]
Last edited by Dude on Wed Oct 28, 2015 8:29 am, edited 1 time in total.
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 »

Lunasole wrote:
TI-994A wrote:Firstly, OO is a programming paradigm; not a tool.
Currently the clear paradigm difference between OOP and procedural doesn't exist anymore.
IMO it never did. All both do is to flip binary switches.
You can use both of them together and as result only getting more ways (and more effective ways) to solve some task, because one of them makes work with a high level of abstraction tasks (graphics, games, artificial neural networks, etc) so much easier than using pure procedures, and procedural implementations also has its huge pluses in all other tasks where OOP usage is excessive (most of regular tasks).
However the corporate entities are much more comfortable using programming tools that reduces their reliance on people and increases their reliance on systems. Corporations are the segment of society that fund large programming projects, and that is why you see the big projects being created using the OO development tools, not because it can not be done using the procedural paradigm.
For example, I don't think you will be able to build any of games that I mentioned in first post without using OOP (don't even saying about much huge things, like modern 3D games and applications like Photoshop or web-browsers, etc). No one has build such for all years using clear procedural only, cause without objects realization of such projects is extremely complex.
And with OOP the realization of such projects is even more complex.
PB as good and easy to learn language simply misses a lot of users while has no abilities that other alive languages have, cause 90% of users will not use OOP realized as precompiler or external include file found on forum, they just went out and keep using "another python or .NET or java" (because C++ is too hard for most users anyway) and then you keep wasting your CPU powers when buying, downloading and using all their apps, poorly coded on a such defective interpretative languages instead of something clear, simple and native-compiled like PureBasic.
Almost true.
So the rightest way would be OOP support as well as keeping procedural style. And users will decide what they will use and for what (not like in C++ with its official full OOP propaganda).
And of course we should respect authors decisions (which was made so many years ago), but sounding reasonable things is not bad too.
I disagree, the "rightest" way is to use the most efficient programming tool. Unfortunately very few are up to the challenge of coding projects in assembler/assembly language, so a BASIC compiler is a reasonable compromise. If I ran a deep pocketed corporation's IT department, and did not want to depend on a particular programmer or group of programmers, then I'd probably opt for OOP development. Added to that, the available entry level labor force has become mostly OO programmers, so most corporations have less choice.

I believe that if we wait a few years, procedural programming will return as a popular development paradigm.
Keep it BASIC.
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Some notes after my first PureBasic experience

Post by Tenaja »

Lunasole wrote:For example, I don't think you will be able to build any of games that I mentioned in first post without using OOP (don't even saying about much huge things, like modern 3D games and applications like Photoshop or web-browsers, etc).
I have avoided oop, so can you enlighten me on exactly what about it is required to write modern games? I just cannot fathom any data structure that cannot be represented without oop. I can allocate structured blocks of memory all day long, and I have no trouble keeping track of them...

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 »

Lunasole wrote:Currently the clear paradigm difference between OOP and procedural doesn't exist anymore.
Not quite. The various programming paradigms would always exist independent of each other, although they can co-exist; and the more fundamental model could sometimes emulate the more complex ones. Ultimately, though, as heartbone has mentioned, they're all doing the same things, albeit with differing approaches.

The dependence on the OO model is borne of the plethora of third-party libraries that eases the burden of the various complex and repetitive programming requirements, from graphics, to game-logic, and so on. The indispensable need to utilise these offerings have bestowed this paradigm with its current place in the programming world. Of course, I'm not denying the convenience and flexibility that the OO model avails, but I am disputing its popularity as a better programming paradigm.

If the team does decide to integrate true OO into PureBasic some day, kudos. Otherwise, or until then, rest assured that we're not missing much, programming-wise.
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
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 »

@Lunasole:
If you like OOP for your (cross-platform?) game programming projects, you may want to
take a look at MonkeyX and the upcoming MonkeyX 2.

They support OOP from the start, including Classes, Inheritance, Templates/Generics, Properties, Function/Method overloading.
Additionally to Win/Linux/Mac you can develop for Android, iOS, HTML5/JavaScript, If you like to release your game for mobiles and tablets.

MX2 should be useable at the end of the year and will add even more OOP Features like
operator overloading, lambda's, function pointers, and more. It will be free and open source,
supported by community donations.
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 »

Danilo wrote:...you may want to take a look at MonkeyX and the upcoming MonkeyX 2.
And also read up a little more on its impeccable history, here:

Monkey programming language round 2...
Danilo wrote:MX2 should be useable at the end of the year...
Right; and if you're lucky, it might still be around for the next few years after that. :lol:
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
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Some notes after my first PureBasic experience

Post by Dude »

Tenaja wrote:I have avoided oop, so can you enlighten me on exactly what about it is required to write modern games? I just cannot fathom any data structure that cannot be represented without oop. I can allocate structured blocks of memory all day long, and I have no trouble keeping track of them...
Yep, it all depends on the skill level of the coder.
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:
Tenaja wrote:I have avoided oop, so can you enlighten me on exactly what about it is required to write modern games? I just cannot fathom any data structure that cannot be represented without oop. I can allocate structured blocks of memory all day long, and I have no trouble keeping track of them...
Yep, it all depends on the skill level of the coder.
Why use Procedures? You can program without it! Use Goto and Gosub instead. Everything is possible, it depends only on your skill as coder.

Sorry, but your arguments are so stupid and ignorant.

Of course objects are not necassary to program a game or anything. But there are cases, where objects are the smarter way to do things. I like the possibility to choice between both.

And as I sayed before: PB support already oop with Interfaces. The question is not should PB support OOP or not. The question is, why PB doesn't include the missing object-handling? There are only a small pice of code missing in the compiler. See my code in the Tips-section.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: Some notes after my first PureBasic experience

Post by Dude »

GPI wrote:your arguments are so stupid and ignorant.
I was directly referring to this:
Lunasole wrote:I don't think you will be able to build any of games that I mentioned in first post without using OOP
So I wasn't being ignorant. And now, we continue:
GPI wrote:The question is, why PB doesn't include the missing object-handling?
Fred's answered that question in his previous posts.
HanPBF
Enthusiast
Enthusiast
Posts: 570
Joined: Fri Feb 19, 2010 3:42 am

Re: Some notes after my first PureBasic experience

Post by HanPBF »

I have gone through the OOP pain and things or wording is misleaded sometimes.

- OOP is a paradigm; You can do OOP in Assembler, C or PB
- OOP is ...orientation...; things are seen different between JAVA, C++ or CLOS
- "OOP" as a word is a bu..sh.. word for management: "What apps do You build?" "Web" (in intranet!); "What language do You use?" "TypeScript" "Aaah, OOP!"; "What framework?" "VanillaJS" "O.k.!"
- PureBasic is not only not OOP it is also not a typed language! You can send a *Person.SPerson to a getName(*User.SUser) without compiler complaining
- OOP is sometimes single inheritance and sometimes multiple inheritance or multi-methods (CLOS) or interface inheritance only (VB6)
- OOP means encapsulation of concerns which You can do with modules, too
- OOP means a world of objects (and waht about processes, functions, algorithms?)
- AOP means, oops, too much in too many classes
- OOP is mostly objects for the GUI; yes, it makes sense to call one method 'draw' for many objects
- OOP encapsulation is about vendors being able to sell AND hide components from component users
- C++, etc. OOP means generics, AOP, iterators, etc., etc. all pressed in an OOP paradigm even it does not fit
- next big thing is functional programming (FOP) -> "functional programming is slower than procedural" What????
- FOP: IMHO write once, read never again
- recursive call to procedure: should be forbidden! Every recursive algorithm can be written iterative AND is then better liable!
- back to OOP: the biggest problem for me -> hierarchy; there is only one hierarchy possible; did You ever had a one and for ever lasting folder structure on Your system? Or a shared between colleagues folder structure in office without a mess at the end?
- OOP: is never alone; You need a lot of design patterns to work around the fixed structure of this concept
- OOP is always said to be "not the one solution to all problems" but I think most of people/management thinks exactly that!

Asking for OOP in PB is not the right question.
How shall the PB team change the overall procedural architecture into an OOP one?
Like C -> C++? Desaster!


This is OOP in PureBasic:

Code: Select all

procedure draw_Control(*C.SControl, Type=0)
	protected T
	if Type=0
		T = *C\Type
	else
		T = Type
	endif
	  
 select T
   case #Type_Button
     draw_Button_Control(*C)
     
    case #Type_ComboBox
    	draw_ComboBox_Control(*C)
    ;etc.	
    default
    	AncestorType = get_Ancestor_From_Is_Type_Map(*C\Type)
    	procedureReturn draw_Control(*C, AncestorType)      
  endSelect
endProcedure
; You can imagine the use...
Disadvantages:
- manual writing of overridden procedures
- manual definition of selection
- slower execution than direct call (but You want to use a dynamic method, right?)
- no autocompletion possible

Advantage:
- no super-tricky macro system -> debugger works
- easy decision what is drawn first and "fastest"
- leaving virtualization in GUI context
- You can optimize code where it needs to be optimized


So, before complaining about missing OOP in PB, PB shall implement a complete type system. Next discussion...
Then, we need a big voting about what should be contained in OOP and in what way.

And, furthermore, this OOP-discussion is a decade too late; today we are in a functional discussion.
I say: we have to come to a logical programming discussion and an interpreter discussion.

The most successful language today? -> JAVASCRIPT
JS is a herit of LISP! (btw. and not JAVA)

OOP brings more problems than it solves!

I need to do my job now and tomorrow.
And that means building, changing, error checking, changing back, testing, changing forward again and all that done yesterday.

With an OOP approach the doing would not change but OOP makes a bigger mess at the end.

But one thing is obvious in this discussion about OOP in PureBasic:
PureBasic is so smart, easy, fast and good that people want to have the things from C# or Java in it!
I think this comparison is not fair.

PB is a fast and easy to use compiler.

If You want more You can not find in market, build it!
I propose to do it in a pure beginners all purpose symbolic instruction code way :wink:
But don't forget that PB is more like C than like BASIC...
Thorium
Addict
Addict
Posts: 1305
Joined: Sat Aug 15, 2009 6:59 pm

Re: Some notes after my first PureBasic experience

Post by Thorium »

Lunasole wrote: 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.
I dont see any problem. Describe your problem and people might offer ideas how to do it imperative.
For me it's actualy the other way around. OOP often overcomplicates and abstracts to far. Imperative, my code quallity is much better, less bugs and most importantly easier to track bugs. But thats just my personal experience.
If you need OOP for your task then use it. If PB doesnt offers good enough support for OOP, take another language. I am working with PB professionaly, meaning i get paid to write PB programs. At the same time i use 4 different languages for different tasks.
Privately i work on a multiplayer game the server side is PureBasic+ASM+SQL. The client side is HTML5+JS. I considered SpiderBasic, but it's not up to the task. Progress is going quite well and it's a fairly complex game. It's like a browser game that plays and feels like a native application. HTML5 and WebSockets make it possible.
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:Why use Procedures? You can program without it! Use Goto and Gosub instead. Everything is possible, it depends only on your skill as coder.

Sorry, but your arguments are so stupid and ignorant.
Why even use computers at all? Let's just carve stone on cave walls. I'm not even sure if that statement of yours is stupid or ignorant. Sorry! :wink:
GPI wrote:Of course objects are not necassary to program a game or anything. But there are cases, where objects are the smarter way to do things. I like the possibility to choice between both.
If the tool affords the required functionality, use it. Otherwise, stop whining and move on.

You can't always get what you want. :lol:
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:
GPI wrote:Why use Procedures? You can program without it! Use Goto and Gosub instead. Everything is possible, it depends only on your skill as coder.

Sorry, but your arguments are so stupid and ignorant.
Why even use computers at all? Let's just carve stone on cave walls. I'm not even sure if that statement of yours is stupid or ignorant. Sorry! :wink:
My personal opinion is, that you can program everything only with Procedures or in Objects. Both are only tools to solve a problem. But I think, that sometimes objects are the more ellegant way. Like use Procedures instead of gosub.

But many persons here seems to see more in objects. They generate a "religion" out of it, and thats stupid. Also that many only repeat freds statment isn't very smart. He has made a decision - a long time ago. It is possible, that he changed his mind? Of Course. Look in the development of PureBasic, not long ago there was no #pb_any. Why? Because Fred decided, that the programmer should generate an id! He changed his mind and added #pb_any.

There are countless request for it. There countless solutions, how to add objects here in forum. And my personal opinion is, that when something like this happend, fred should talk to his team about a standard for this problem.

Adding object-handling will not open the gate to hell. And nobody sayed that every function/library of PureBasic should be converted to objects.

My problem with many posts here is, that they can be summarised to "I hate objects! Don't include it!". When you have an argument, why PB should not support object handling, tell us. Than we can discuss about this. But "fred said no" - yes we know. And of course I am trying to change is decision. That he said no is not an argument.
HanPBF
Enthusiast
Enthusiast
Posts: 570
Joined: Fri Feb 19, 2010 3:42 am

Re: Some notes after my first PureBasic experience

Post by HanPBF »

Hello GPI,

I think the main problem is to say simply: "I want OOP in PureBasic".

OOP itself is too much; You gave the example with #PB_Any.
Compare #PB_Any with "OOP". Isn't there a little gap in between both of them?

What Fred and PB team will do is think about the compiler technology itself to maybe include more environments/OSes.

I would compare this we-want-OOP-case with the change from C to C++.
I do not think that C++ was a good deal (we are still talking about small teams or single developers).
Objective-C was far more powerful.

Or look at the best and most powerful language today: Scala.
I like the "9.+(8)" statements or the way binary function can be called as operators "1 my-add 2".
And You have generics and functional programming, too.
But after all the learning curve is so big, You put all efforts in starting to walk.

Before "OOP" comes as a standard into PB, someone should prove the advantages in a precompiler.

But at the moment we even don't have a switch in the compiler to enable EnableExplicit in every module/source.
I don't see how the PB team can handle any kind of language enhancement?

There are so many, many little, little things that the IDE/syntax lacks or is wished to have that the PB-team's todo-list must be a todo-book...
Post Reply