Microsoft is positioning its P language as a solution for asynchrony in a world where this capability is becoming increasingly vital for the cloud, artificial intelligence, and embedded systems.
Geared to asynchronous event-driven programming, the open source P unifies modeling and programming into a single activity. “Today’s software uses cloud resources, is often embedded in devices in the physical world and employs artificial intelligence techniques,” said Shaz Qadeer, a principal researcher at Microsoft. Such applications feature asynchrony, leading to issues with race conditions and “heisenbugs” (named after the Heisenberg Uncertainty Principle), which are timing-related bugs that often disappear during an investigation of it. P was was built to address the challenges.
In P, the protocol and specification are written at a high level. P features a programming model based on concurrently executing state machines communicating via events; each event is accompanied by a typed payload value. It also provides safe memory management and data-free concurrent execution, similar to what the Rust language offers.
The P compiler provides automated testing for concurrency-related race conditions and executable code for running the protocol, Qadeer said. P supports modeling of concurrency, specifying safety and live-ness properties, and checking that the program satisfies its specification using systematic search, he said. Also, P programs can be compiled into executable C code, bridging the gap between high- and low-level implementation and help programmers accept its formal model and specification, he said.
The language lets engineers model asynchronous interfaces among components in a large Azure service. It also can be used to debug problems on PCs that might otherwise take months or years to manifest after the service is deployed.
P was first used internally by Microsoft for USB 3.0 drivers in Windows 8.1 and Windows Phone, and is now extensively used for driver development in Windows, Qadeer said.