TMBASIC is a programming language for writing non-graphical programs. The modern BASIC language is easy for beginners to learn. Experienced programmers will find it familiar and productive after a brief glance at the cheat sheet.
TMBASIC is under development. Stay tuned!
Easy to learn — The BASIC language will feel familiar to anyone with programming experience. New programmers will enjoy a cohesive, batteries-included learning experience. Everything you need to develop and distribute sophisticated apps is included in TMBASIC.
Easy to write — Developing a high-quality modern GUI requires professional-level expertise. Text-based apps have few options for visual effects, and even a novice can produce quality results.
Easy to share — TMBASIC apps are standalone executables that require no external library files. They can be copied and opened without installation. TMBASIC can cross-compile native executables targeting Windows, macOS, and Linux.
dim a as Number dim b as String dim c as Boolean dim d = 1.2345 dim e = "hello world!" dim f = true
Declare variables with dim
, providing either an explicit type or an initial value.
The simple types are:
Number
— 128-bit decimal floating-pointString
— UTF-8 textBoolean
—true
orfalse
dim myList = [1, 2, 3] dim combinedList = myList + [4, 5, 6] + 7
dim myMap as Map from Number to String myMap(123) = "hello" print ContainsKey(myMap, 123) ' true
dim set mySet for i = 1 to 100 step 2 yield i next end dim
The collection types are:
List of T
— An ordered array of values of typeT
. List indices start at zero.Map from T1 to T2
— A dictionary with keys of typeT1
and values of typeT2
.Set of T
— A group of unique values of typeT
.
Use dim list
, dim map
, and dim set
to build collections efficiently.
Each yield
statement adds an element to the collection.
These collection types are generic, but you can't define your own generic types.
dim d = DateFromParts(2021, 3, 12) dim dt = DateTimeFromParts(2021, 3, 12, 4, 30, 0, 0) dim tz = TimeZoneFromName("America/New_York") dim offsets = UtcOffsets(dt, tz) dim dto = DateTimeOffsetFromParts(2021, 3, 12, 4, 30, 0, 0, offsets(0))
The date and time types are:
Date
— A day without a time.DateTime
— A date and local time without any time zone.DateTimeOffset
— A date and local time with the time zone offset from UTC.TimeSpan
— A duration of time.TimeZone
— A time zone defined by the IANA.
type ExampleRecord foo as Number bar as String end type
dim myAnonymousRecord1 as Record (foo as Number, bar as String) dim myAnonymousRecord2 = { foo: 100, bar: "hello" } dim myNamedRecord = myAnonymousRecord2 as ExampleRecord
Both anonymous and named record types are supported.
The literal syntax for anonymous records resembles JavaScript.
Anonymous records can be converted to named records with the as
operator.
dim a = { foo: 1, bar: 2 } dim b = a ' makes a copy b.foo = 999 ' a.foo is still 1
All types, including records and collections, have value semantics. There are no references or pointers. Assigning to a variable or passing to a function always makes a copy of the value.
sub Main() print Squared(5) end sub
function Squared(x as Number) as Number return x * x end function
Programs are broken down into functions and subroutines.
A function returns a value to its caller. A subroutine does not return anything.
Program execution begins in the Main
subroutine.
Windows Vista or newer | 64-bit • 32-bit |
macOS 10.13 or newer | Intel • Apple Silicon |
Linux 2.6.39 or newer | 64-bit • 32-bit • ARM64 • ARM32 |
iOS | iSH Shell (Linux 32-bit) |
Android | Termux (Linux ARM64) |
TMBASIC is open source software that is available free of charge. TMBASIC builds your programs using many open source components. See a list of components here. These components have permissive and commercial-friendly licenses that you must obey when you publish your programs written in TMBASIC. When you build your program, TMBASIC produces a LICENSE.txt
file for your convenience. Include this license file when sharing your TMBASIC apps.