Welcome, Guest. Please login or register.

Author Topic: Which is better? OS 4 or Morph OS . . .  (Read 11236 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline itix

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 2380
    • Show all replies
Re: Which is better? OS 4 or Morph OS . . .
« on: October 08, 2005, 07:41:51 PM »
@SamuraiCrow

I think you are little confused here. I'm not sure what you mean by POSIX-style shared libraries but for example MorpHOS has SDL (main, image, mixer, ttf, net) libraries as a shared library quite long time now. In addition I've ported ODE/OPCODE, lcms and newlib as a shared library to MorphOS.
My Amigas: A500, Mac Mini and PowerBook
 

Offline itix

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 2380
    • Show all replies
Re: Which is better? OS 4 or Morph OS . . .
« Reply #1 on: October 09, 2005, 01:28:33 AM »
Quote

1) An interface defines a namespace. This allows me to create my own interfaces that have function names that would otherwise clash with the OS ones. IKarl->AllocVec() is totally different from IExec->AllocVec(). Both can happily coexist in the same source.


This doesnt work for libraries which are ported from link libraries. For example I cant imagine you edit every single SDL port to call SDLIFace->SetVideoMode() instead of SetVideoMode() ?

Quote

As a more tangible example, consider MUI/Reaction etc. The BOOPSI calling mechanism is just awful. Reimplementing them using interfaces would likely give more compact code that could run a hell of a lot faster. I am sure a button->DoLayout() is an order of magnitude faster than a DoMethod() call via the boopsi dispatcher


How inheritance would work? For example if you subclass root class and ad your own methods -- how root class is supposed to handle them?

On the other hand you need a class pointer to call super class. On the other hand you must access your local object data somehow. In practise you are trying to create a class from library base.

If you look into OS4 documentation you will find out interface has
a) function table at positive offset
b) data at negative offset
 
AmigaOS 3 library base has
a) function table at negative offset
b) data at positive offset
 
That is major difference between them.
 
My Amigas: A500, Mac Mini and PowerBook
 

Offline itix

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 2380
    • Show all replies
Re: Which is better? OS 4 or Morph OS . . .
« Reply #2 on: October 10, 2005, 02:11:29 PM »
Quote

Remember, a parent class never does have any knowledge of any of any of its childrens' unique methods or properties. Consider an actual C++ class heirarchy. If your parent class is HouseholdPet, and you have sublcasses of GoldFish, Cat, Dog, Budgie, etc, *only* the interface defined by HouseholdPet is common to all. Each implements the HouseholdPet interface and adds some unique methodst too. Dog might add a method chasePostman() to the existing set of methods it inherited from HouseholdPet.


I'm not sure: would every class have its own interface structure or would subclasses inherit its parent interface structure and extend it. If so, how?

Quote

In this regard, interfaces are no different to classes. I can't realistically call a method of a sub interface via a handle to the parent that the parent does not already advertise.


In BOOPSI you can. It is just ignored by super class. Either way interface (as in struct Interface) cant replace Intuition objects at all.

Quote

The second issue is polymorphism. Customising methods of the parent interface to suit the specific child so that different instances of an interface might perform the same method call differently. This is perfectly doable. Remember, the methods are really just embedded function pointers within the interface structure and can be changed. If I cloned an instance of IKarlDevice, I can provide my own function to handle the Initialize() method specifically for that one instance (similar to SetFunction() on a library).


That could be an advantage sometimes.

Quote

If you prefer doing this type of thing with 3.x style library bases and the 3.x source compatible ways of calling their code, that is entirely up to you. I personally find it much less cumbersome to accomplish this type of thing with the interface syntax.


In my opinion 3.x style is just fine. I've used it so many years already :-O
My Amigas: A500, Mac Mini and PowerBook
 

Offline itix

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 2380
    • Show all replies
Re: Which is better? OS 4 or Morph OS . . .
« Reply #3 on: October 10, 2005, 07:28:01 PM »
Quote

It can, however easily replace boopsi as a fondation. I've already experimented a little in this area, a simple inteface definition with event handler / render methods implemented as one of three simple objects (this was a direct adaptation of my C++ framwork's unfinished guilib idea).


But would it give a significant performance boost compared to BOOPSI? Calling a method in BOOPSI is not very expensive after all. There is some extra overhead in dispatchers but I think current BOOPSI is quite good.

Surely interfaces have some flexibility to be used like this. And I know few cases where I could take an advantage of interfaces.

Quote

Entirely your choice. Have you tried any of the types of OO construct design discussed here using only 3.x style and library bases? I have and it is quite frustrating compared to the interface approach.


I have used only C++ and Java but there I dont have to care about low level details.

Btw it seems in Windows you have interfaces too (in COM objects, I guess).
My Amigas: A500, Mac Mini and PowerBook