Tibbo BASIC and Tibbo C


Tibbo BASIC and Tibbo C are our versions of the classic BASIC and C languages that have been around for decades. BASIC spawned hundreds of variants, and no standards exist (or are remembered) that document its features. C — or, more specifically, ANSI C — is rather rigidly defined. The 1978 classic book The C Programming Language by Brian W. Kernighan and Dennis M. Ritchie is still available on Amazon and can teach you all you need to know about 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 event-based execution.

Tibbo BASIC and C use the static memory model: all RAM is allocated at compile time, and there is no heap. This means that there will be no "out of memory" situations — ever. There is no need for garbage collection, nor is there associated overhead. However, this also means no dynamic sizing of memory structures, no dynamic object creation and destruction, and no recursion or reentrant calls.

Tibbo BASIC and C are "pure" in that they contain no I/O facilities of any kind (no PRINT, INPUT, etc.). Instead, all I/O is handled by objects.

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

Tibbo BASIC and C can be intermixed within a single project. For example, you can write an application in Tibbo C that calls on a library written in Tibbo BASIC. The only limitation in this scenario is that 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. Additionally, C has pointers, which are not a part of the BASIC language.

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

Here are two minimalist programs written in Tibbo BASIC and C to give you a taste of what such 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(){