日本ソフトウェア科学会第 41 回大会 (2024 年度) 講演論文集

EmbedFX: New Programming Language forEmbedded Systems with Asynchronous Eﬀects
Danel Batyrbek Yukiyoshi Kameyama
While embedded systems are recognized to be important for the proper functioning of our society, it isextremely diﬃcult to write safe and reliable software because of inherent limitations. Among the ongoing
research of embedded software, several programming languages have been proposed, improving on speciﬁc
aspects of the C programming language. However, those languages continue to occupy a niche of researchlanguages, without mass adoption of the wider community. EmbedFX is a new programming language
speciﬁcally designed for embedded systems. The goal is to make development for embedded systems simpler, without foregoing the beneﬁts of the expressive nature of C. EmbedFX draws inspiration from OCaml
and incorporates asynchronous eﬀects, a variation of traditional eﬀect handlers, to represent the asynchronous nature of embedded software. EmbedFX additionally retains many of OCaml’s powerful features
such as static type checking, expression-oriented syntax, and immutability. The language transpiles to C
and leverages the FreeRTOS API to implement its asynchronous eﬀects.

mutable language that includes built-in support for

1 Introduction

asynchronous eﬀects.

Programming for embedded systems comes withunique challenges, such as limited resources, the ne-

2 Language Features

cessity for real-time responsiveness, and the com-

EmbedAsync incorporates several key features

plexity of handling concurrent operations. Histor-from OCaml, adapted speciﬁcally for the embed-ically, C and C++ have been the go-to languages

ded systems ﬁeld:

for embedded programming because of their abil-

1. Ensures type safety at compile time, minimiz-

ity to directly interface with hardware, though thising runtime errors and improving code reliabil-

often means sacriﬁcing the advantages of high-levelity.

languages. Drawing inspiration from the functional

2. Promotes a concise and expressive coding

programming language OCaml, our goal is to oﬀer astyle, making the development process morehigh-level development experience while producing

straightforward.

eﬃcient code for microcontrollers with EmbedFX

3. Encourages the use of immutable data struc-―a statically typed, expression-oriented, and im-tures to prevent unintended side eﬀects andfoster safer code.

EmbedFX: New Programming Language for Embedded Systems with Asynchronous Eﬀects.
This is an unrefereed paper. Copyrights belong tothe Authors.
Danel Batyrbek, Yukiyoshi Kameyama, 筑波大学 情報理工学位プログラム, Department of Computer Science, University of Tsukuba.

2. 1 Asynchronous Eﬀects
A signiﬁcant innovation in EmbedFX is the integration of asynchronous eﬀects [1], which allow
developers to manage asynchronous operations ina natural and eﬃcient manner. These eﬀects en-

EmbedFX ensures that its asynchronous opera-

able the creation of complex asynchronous control

tions are both eﬃcient and reliable, fully leveraging

ﬂows that are both type-safe and capable of track-

FreeRTOS’s capabilities for task scheduling, syn-ing user-deﬁned operations without compromisingchronization, and inter-task communication.

asynchronicity, oﬀering a streamlined approach tohandling concurrent tasks common in embedded
systems.
Asynchronous eﬀects in EmbedFX are designed

3 Conclusion
EmbedFX seeks to enhance the landscape ofprogramming languages for embedded systems bymerging the expressive power and safety featuresto:• Maintain clear dependencies between asyn-of OCaml with advancements in programming lan-chronous tasks, ensuring proper communica-

guage research. Its goal is to elevate the developertion.

experience beyond that of traditional C. Despite• Utilize non-blocking operations to preserve

this, the ability to transpile to C ensures compati-

system responsiveness, which is crucial for real-bility with existing C codebases, while also simpli-

time embedded applications.

fying the use of the FreeRTOS API in a type-safe• Leverage the language’s static type system toand reliable way.

enforce correct usage of asynchronous eﬀects,reducing the likelihood of errors.

4 Future Work
Future developments for EmbedFX will aim to

2. 2 Transpilation to C and FreeRTOS Integrationoﬀer stronger guarantees and a more ergonomic design, including features like the ability to deﬁne

To maintain compatibility with a broad range

atomic operations and prevention of most race con-of embedded hardware, EmbedFX transpiles to C.

ditions, to ensure a safer and more reliable develop-

This strategy allows developers to take advantage

ment experience for embedded systems. The gen-of the language’s high-level abstractions while gen-erated C code is currently produced conservatively,

erating C code that is well-suited for resource-

so optimizing it for readability is a key area for im-

constrained environments. The transpilation pro-provement. Additionally, while the current imple-

cess is carefully designed to produce C code thatmentation of EmbedFX is tailored for the ESP32,

not only beneﬁts from existing libraries but also

expanding support to other microcontroller families

allows for further modiﬁcation and patching afteris under consideration.

transpilation.
EmbedFX integrates with FreeRTOS, a widelyused real-time operating system for embedded devices, to implement the semantics of its asynchronous eﬀects. By utilizing the FreeRTOS API,参 考 文 献[1] Ahman, D. and Pretnar, M.: Asynchronous effects, Proceedings of the ACM on Programming
Languages, Vol. 5, No. POPL(2021), pp. 1–28.