Frequently Asked Questions


    What are the differences between B# and C/C++/Java/C#?

    B# is a very stripped down version of C# (often described itself as a hybrid of C++ and Java) dedicated for embedded programming systems.

    Embedded system developers are averse to any kind of overhead.
    Why use a virtual machine for embedded systems?

    Until recently, a virtual machine (VM) was simply too cumbersome and too slow for most microcontrollers. Today, however, modern microcontrollers are sufficiently powerful to support a VM (interpreter) for many embedded systems applications. Although the C programming language will always generate faster native code (no emulation) and will still be required for speed critical embedded applications, a VM does simplify the code writing process. Also, more generic code can be produced and ported across different microcontrollers by hiding specific microcontroller-dependent features within the VM.

    Why is the language called B#?

    B# is a reincarnation of C, a "sharper", object-oriented language dedicated specifically for the development of small footprint embedded applications.

    Is it possible to fit a class-based, object-oriented system into a few kilobytes of memory?

    Yes, because the B# compiler generates highly optimized and compact code. This code is designed to be executed by a virtual machine whose instruction set is mapped closely to the high-level, object-oriented features of B#. For example, the 'callv' instruction of the VM exactly emulates the invocation of a virtual method using only two bytes. The equivalent instruction in native (real) processor code would have taken many more bytes of memory. Another important implication of having very compact code is that it will execute faster, even if new target microcontrollers and devices offer a megabyte or more of memory, such as cellphones and PDAs.

    How does the get|set properties of B# help the portability of device drivers which is otherwise hard to achieve in C and other languages without being dedicated to specific vendor compiler features?

    The isolation of input/output device registers, the access of interrupt vectors, and the enabling and disabling of interrupts are typical embedded systems requirements. Oddly, these features are not standard in programming languages like C, C++, Embedded C++, and Java. In these languages, conditional compilations are often used to interlace code in order to support several target devices. Others have difficulty hiding hardware details; they rely on inlining or require explicit pointer dereferencing, both of which are normally hard to maintain. B# hides these hardware differences within the virtual machine using hardware abstract layers (HALs). The end result is one piece of generic code for all target platforms. For example, the B# ioreg feature is an abstraction somewhere between a pointer, a constant, and a property. As it turns out, it makes for an amazingly clean syntax for writing to a fixed device address. It is short, sweet, and dead-simple to optimize.

    ioreg portA = 0x01234567 { get; set; }

    int i = portA; // read
    portA = 0xFF; // write