Tuesday, April 18, 2006

Object Orientation and LB5

In a recent thread in the Conforums (http://libertybasic.conforums.com) someone asked the question of whether QBasic style types would be supported, and I elaborated and posted an example of what I was thinking about this for LB5. This prompted a reaction about what was perceived as a move toward object oriented programming.

Here is part of my reply:

Liberty BASIC 5 will not be an object oriented language. LBers will not be expected to learn OO programming.

There have been objects (the UI controls) in Liberty BASIC from the beginning, but I tried to avoid treating them like objects. I'm convinced this was a mistake. Since we have been using objects in our non-OO version of BASIC, we might as well fix the syntax to make it easy to do. The new syntax for programming UI controls is designed to treat them more appropriately.

Instead of printing to a button for example, it makes more sense to call a function on it like so:

#myButton enable(1)

Types and objects are very similar things. Therefore it makes some sense to try and cover them with a unified syntax, and not try to support two different syntax extensions. It makes sense to me to implement types as a sort of lightweight object. This makes even more sense because it will act as a conceptual bridge towards the new BASIC which will actually have a useful OO programming mechanism. This will be the simplest OO feature set I can get away with, and I hesitate to call the new language an OO language.