PDA

View Full Version : PowerBasic Object Oriented Programming



kryton9
25-09-2011, 08:31
Guys, I haven't updated my PowerBasic 8 because from the little bit I saw about the new OOP, it didn't seem easy or intuitive to me. Now that it has been out for a while and hopefully some of you have been using the new OOP features I would like your honest reviews on these new OOP features.

Perhaps you can give some examples of classes you might have made to show how it all works.

REDEBOLT
25-09-2011, 11:40
Hi kryton9,

Take a look at My first COM object - MATRIX (http://www.powerbasic.com/support/pbforums/showthread.php?t=45876).

If you have questions, please ask.


Regards,

Bob

ErosOlmi
25-09-2011, 12:24
To me every new version of PowerBasic is worth to be bought.
It is the only Basic language I feel comfortable. Maybe it is my limit but maybe it is PB characteristic.

Among many other new features, PB version 9 introduced OOP.
Among many other new features, PB version 10 better organized it and from one side simplified COM programming and from the other simplified general OOP paradigm.

thinBasic is still developed using PB 9.x but very soon I will move to PB version 10.x

John Spikowski
25-09-2011, 17:58
thinBasic is still developed using PB 9.x but very soon I will move to PB version 10.x

If Windows is the only platform you have plans to support with thinBasic, then PB 10 would probably be the best choice for thinBasic 2.0. If you would like to offer a richer experience with thinBasic and offer your language on other platforms in the near future, OxygenBasic is a MUCH better choice. I know you have taken a lot of heat from Zale in the past for creating a Basic language with PB and that's sad. Just imagine if you had the source to the Basic compiler you're using. Wouldn't that open up new opportunities for your users you could never offer staying the PB path?

Josť Roca
26-09-2011, 08:23
PB is not an OOP language. COM (as implemented in PB) and OOP share the use of classes and objects, but that's all. COM does not use OOP thingies such multiple parametized constructors, operator overloading, multiple inheritance or polymorphism. PB 10 has one of the best low-level COM support in any language, but instead of taking advantage of it, most PBer's are trying to do OOP.

"To understand COM (and therefore all COM-based technologies), it is crucial to understand that it is not an object-oriented language but a standard. Nor does COM specify how an application should be structured; language, structure, and implementation details are left to the application developer. Rather, COM specifies an object model and programming requirements that enable COM objects (also called COM components, or sometimes simply objects) to interact with other objects. These objects can be within a single process, in other processes, and can even be on remote computers. They can be written in different languages, and they may be structurally quite dissimilar, which is why COM is referred to as a binary standard; a standard that applies after a program has been translated to binary machine code."

See: http://msdn.microsoft.com/es-es/library/ms694363%28en-us,VS.85%29.aspx

kryton9
27-09-2011, 07:41
Thanks for thoughts and examples guys. Jose's post I guess hit the nail on the head of why I was unable to really grasp it... I never really understood COM either.

Bob it now struck me why you posted "My first COM object - MATRIX." :)

John Spikowski
28-09-2011, 06:12
PB 10 has one of the best low-level COM support in any language ...

any language meaning ALL languages and not just Basic?

Does that statement still hold true without your includes and supporting tools?

My problem with PB is that COM/ActiveX was the thing in 2000. It's taken 12 years to offer usable COM support? (excluding a COM visual container, .NET and most everything else that is currently being use today in Windows) Can you believe 64 bit still isn't on the PB radar screen? PB Linux isn't even being talked about any longer.

Josť Roca
28-09-2011, 20:51
> any language meaning ALL languages and not just Basic?

Yes. Remember that I'm talking of low-level COM, not of Automation. Regarding low-level COM, only C++ is more powerful, although is much more difficult to use.

> Does that statement still hold true without your includes and supporting tools?

Low-level COM does not use type libraries, but interface declarations. Therefore, you need headers. C++ also needs headers. The only difference is that the low-level COM interface declarations for C++ have been written by Microsoft and the ones for PB have been written by me.

> My problem with PB is that COM/ActiveX was the thing in 2000.

ActiveXs don't interest me. They were written to be used by Automation languages such VB6 and for Internet Explorer, but VB6 is now dead and the use in the browser began to be avoided many years ago for security reasons.

But if with "was the thing in 2000" you mean that is no longer useful, you can't be more wrong. It is alive and well. Almost all the new Vista/Windows 7 APIs have been written as low-level COM servers, including the Ribbon framework, that no longer uses the ActiveX technology and therefore doesn't need an OLE container, Direct2D, Direct Write, etc. And the new Windows Runtime, planned for Windows 8, is being written using low-level COM.

> It's taken 12 years to offer usable COM support? (excluding a COM visual container, .NET and most everything else that is currently being use today in Windows)

"Usable" can be only applied to Automation, that was implemented several years ago in PB 7.0. Direct interface calls and native unicode support, as implemented in PB 10, is superb.

I wrote my own OLE container mainly to we able to host the Web Browser control (without having to use ATL.DLL or another external container), that with the use of Dynamic HTML, CCS, HTML5 and javascript offers many possibilities.

Almost nobody still develops ActiveXs today. NET assemblies can be used with PB if you write them properly or if you produce a COM callable wrapper. I have an small class that allows to host any version of the .NET runtime, but I'm not interested in writing assemblies.

> Can you believe 64 bit still isn't on the PB radar screen?

Just as we had a 32-bit compiler when we really needed it, we will have a 64-bit compiler in due time.

> PB Linux isn't even being talked about any longer.

Who cares?

REDEBOLT
29-09-2011, 04:00
Thanks for thoughts and examples guys. Jose's post I guess hit the nail on the head of why I was unable to really grasp it... I never really understood COM either.

Bob it now struck me why you posted "My first COM object - MATRIX." :)

kryton9, I don't really understand COM either.

:oops: :) :D

Bob

John Spikowski
29-09-2011, 04:45
> PB Linux isn't even being talked about any longer.

Who cares?


Obviously no one using PowerBASIC. Silver lining is that PB runs fine under Wine.

Charles Pegge
29-09-2011, 08:40
I would say COM is a very specialised form of OOP.

The underlying objects or processes are not accessible to the caller.

The caller may request an interface to an object, identified by GUIDs.

GUIDs are 16 bytes long, and that is sufficient to uniquely identify every piece of software ever written on this planet.

If the Object GUID and the interface GUID are recognised and if the request is valid, then the COM system will return a pointer to the specified interface.

The interface itself contains a set of method calls and nothing else that the caller is allowed to touch.

(COM interfaces may only inherit methods from one other COM interface.)

This is intentionally restrictive, so that the chances of disrupting major components in a large system is minimised.

Charles