Re: is OO any use?

David McNab <[email protected]>
Newsgroups gmane.comp.hardware.microcontrollers.gnupic
Message-ID <[email protected]>
David P Harris wrote:
> David-
> Is this written up somewhere?  Sounds interesting.  Being able to choose
> between early and late binding is very useful, and let's you tune your
> application. David

It's fairly thoroughly documented in the original (slow but compact)
pic18forth - http://pic18forth.sourceforge.net/doc/oo.html

Features and syntax will be the same in the new fast-but-bloaty version.

Cheers
David

> 
> David McNab wrote:
> 
>> Thanks all for comments.
>>
>> As it happens, I've just migrated over the OO layer from my slow/compact
>> forth to the new fast/bloaty forth.
>>
>> The OO uses a vtable at the start of each object's data area, to 'tag'
>> what class the object is, and facilitate late binding.
>>
>> Method and attribute accesses get compiled to code which passes a 2-byte
>> hash of the method/attribute name, for faster comparison during the
>> search.
>>
>> Even with this optimisation, the cpu usage for late-binding method
>> lookup is weighing in at 218 cycles minimum. that's 43.6us for an 18f
>> running at 20MHz. This will grow further for methods further down the
>> vtable, and grow even more harshly for methods higher in the class'
>> ancestry. Eek.
>>
>> Fortunately, the OO also supports early binding, which cuts this down to
>> 2 cycles - the cost of a CALL. The syntax is uglier though, and needs
>> the user to know the object's class ancestry.
>>
>> Anyway, what the hell, it's done. I might find a use for it, or I may
>> not. But I'd better warn users in the doco that accessing objects using
>> late binding cops a cruel speed penalty.
>>
>> Cheers
>> David
>>
>>
>> David Santo Orcero wrote:
>>  
>>
>>> Hello, David!
>>>
>>>
>>>   
>>>
>>>> This is not a troll, so please forgive me if it comes across as such.
>>>>     
>>>
>>> I don think so. :-)
>>>
>>>
>>>   
>>>
>>>> What I'm asking here is - is there any real practical value to be
>>>> gained
>>>>     
>>>> from supporting OOP in a PIC runtime environment?
>>>
>>>
>>>
>>> Let's divide the question in two parts:
>>>
>>> OOP as a design metodology: so far you are confortable with OOP
>>> design, I don't feel any problem with using it. If it allows you to a
>>> better design, and a cleaner organization, you will have a code more
>>> easy to understand and maintain. And if you use assembler -and most
>>> of us use it-, you will need that kind of code. There are tricks well
>>> known to obtain good non-OOP code for a OOP design, so don't be
>>> afraid to mix OOP design with final assembler code.
>>>
>>> OOP programming languages: teorically, it is possible; but I don't
>>> know any OO language compiler for PICs. Anyway, I strongly doubt that
>>> it is usefull. There are some issues related with dynamic linking and
>>> function calling that are heavier in a OO languaje due to polymorfism
>>> and inherance that could make the call of a function too heavy for
>>> obtaining good performance for a PIC. More powerfull microcontrolers
>>> -and I think here in something like a picojava core and higher- would
>>> allow an OO languaje, but the energy needs will be higher, and the
>>> cost of the components and the development time of the hardware will
>>> also increase.
>>>
>>> Yours:
>>>
>>> David
>>>
>>> ---------------------------
>>>    David Santo Orcero
>>> http://www.orcero.org/irbis
>>> ---------------------------
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>>
>>>   
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>>
>>  
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.