What is uSwift?

What is the purpose of it?

Microcontrollers are small, efficient devices that sit somewhere between a traditional electronic circuit and an interfaced physical computing platform. They are characterised by efficiency and restraint. Many modern high level languages are simply too wasteful of resource (wattage, RAM, CPU cycles) to be suitable for MCU native development. A new class of language is emerging to bridge this gap, of which uSwift is one of the front runners?

How close to mainstream Swift is uSwift?

Much of the language, style and features of Swift are present in uSwift and if you have experience of Swift programming you will find uSwift easy to pick up. In particular the syntax, rigorous type system and, most importantly, the defined programming model are all still there.

Many of the memory intensive or CPU intensive parts of the language and standard library have been disabled and replaced with more efficient and simpler functions that fit on restrained programming platforms. And a lot of work has been done to ensure that optimal, fast and efficient code is produced that gives real time performance and predictable timings, essential for MCU function.

Large, complex string processing makes no sense on an MCU and has been completely removed, replaced by simple, memory efficient small buffers for string synthesis and program memory stored constant strings for simple use in debugging and labels.

Array and classes are all disabled and with them huge swathes of unnecessary runtime no longer needs to be linked, reducing program size bloat by one or two orders of magnitude. Likewise, this eliminates reference counted, heap managed RAM, which is notoriously dangerous in constrained RAM devices.

Enumerations, optionals and structs are not currently part of uSwift but are on the roadmap for inclusion in the future, provided they can be done in an efficient way with a lean runtime.

How hard is it to learn or change to uSwift?

If you have a deep experience of micro controller programming in other languages like C and ASM, the style of programming should feel sensible and easy to understand. If you have never programmed on a constrained platform before then some aspects will take a little practice. But we think nothing in uSwift is fundamentally too difficult to learn, it requires more attention on resource use and efficient timing.