Tibbo BASIC and Tibbo C

Top  Previous  Next

C_and_BASIC_gears

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

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).

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 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:

Tibbo C:

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

unsigned char ctr;
 
void on_button_pressed(){
  ctr++;
}