Tibbo BASIC and Tibbo C


Tibbo BASIC and Tibbo C are our versions of classical BASIC and C languages that's been around for decades (more on language standards).

BASIC spawned hundreds of variants and no standards exist (or remembered) that document its features. C or, more specifically, ANSI C is rather rigidly defined. A classical 1978 book by Kernighan and Ritchie titled "The C Programming Language" is still available on Amazon and will teach you all you need to know about the ANSI C.  

Tibbo BASIC and C applications are event-driven — all code is executed in event handlers, which are invoked in response to events. This is known as the event-based execution.

Tibbo BASIC and C use the static memory model — all RAM is allocated at compile time and there is no heap (Implications.

PROs: no "out of memory" situations — ever! No need for garbage collection and no associated overhead.

CONs: No dynamic sizing of memory structures. No dynamic object creation/destruction. No recursion or reentrant calls.

Tibbo BASIC and C are "pure" in that they contain no input/output facilities of any kind (no PRINT, INPUT,...). Instead, all input and output are handled by objects (the subject of my next topic).

Tibbo BASIC and C are equals. BASIC is not simpler. C isn't faster. Choosing one over another is largely a matter of personal preference and habit. The only exception is pointer arithmetic — if you need pointers you have to go with C.

Tibbo BASIC and C can be intermixed within a single project. For example, you can write an application in C that calls on a library written in BASIC (one limitation.

Tibbo BASIC and C can only exchange data through simple variable types (bytes, words, etc.). Although both BASIC and C support arrays and structures, their implementations are different between these two languages. Additionally, C has pointers, which are not a part of the BASIC language.    

Tibbo BASIC and Tibbo C both support strings, and these strings are "safe" — TiOS makes sure that there are no overflows (attempts to store more data than the string can contain). While common in BASIC, strings are not a standard part of the ANSI C. Trust me, you will find strings extremely useful!

Here are two minimalist programs written in Tibbo BASIC and Tibbo C.

I am showing them here just to give you a taste of what Tibbo BASIC and Tibbo C code looks like.

These two simple programs increment the value of variable ctr every time you press the MD button on your programmable Tibbo device:

** Tibbo Basic **

dim ctr as byte         'this is the declaration for a global variable

sub on_button_pressed   'this is the event handler for the ON_BUTTON_PRESSED event
   ctr=ctr+1            'this is how the ctr variable gets incremented
end sub 

** Tibbo C **

unsigned char ctr;

void on_button_pressed(){