b6b follows five design principles:
- Everything is an object
- Every object is a string
- Every object is a procedure
- Every statement is a procedure call
- Transparent parallelism
b6b is especially useful as:
- A more powerful, yet simple alternative to shell scripting
- A thin layer above C and system calls, which provides exceptions, garbage collection, easy parallelism and a dynamic type system
- An embedded interpreter in a big software project
- An extremely lightweight scripting language, for rapid development of fault-tolerant embedded software
b6b is implemented as a library, libb6b. This library exposes a rich API that allows applications to embed b6b. For example, b6b also includes an interactive interpreter application built on top of libb6b.
Each b6b interpreter uses two threads:
- The "interpreter thread", the thread which calls the libb6b API to create an interpreter instance and run a script through it
- The "offloading thread", spawned during the initialization of the interpreter
b6b implements multi-threading using fibers (or, green threads) while a simple, round-robin scheduler relies on voluntary preemption to prevent starvation. All these threads run on a single native thread: the interpreter thread.
Therefore, b6b's implementation of multi-threading does not benefit from SMP, but it is lock-free, lightweight, safe (for example, safe for embedding in heavily multi-threaded applications) and simple, which are far more important design considerations for the uses cases b6b shines at.
As many system calls are non-blocking by nature, most operations in b6b are non-blocking as well. However, under multi-threaded scenarios, the interpreter thread delegates blocking or slow operations (such as compression or file creation) to the offloading thread, while the interpreter thread continues to run other fibers.
Since multiple script threads may perform blocking operations at the same time, this offloading mechanism is mostly useful in situations such as an event-based server, where the only blocking operation is waiting for more events, while previous events are dealt with in coroutines.
b6b is free and unencumbered software released under the terms of the Apache License Version 2.0; see COPYING for the license text.
For a list of its authors and contributors, see AUTHORS.