P, the event driven programming language from Microsoft has been made open source. Microsoft has designed P to give developers a way to write asynchronous event-driven programs. P helps in specifying the system as a collection of interacting state machine, communicating each other using events.
Language’s documentation on GitHub says, “P has been used to implement and validate the USB device driver stack that ships with Microsoft Windows 8 and Windows Phone. P is also suitable for the design and implementation of networked, embedded, and distributed systems.”
Microsoft designed P to provide language primitives to short and precise capture tools that are inherent to communicate among components in asynchronous systems. The state machines run in concurrent with each other, executing event handling loops that removes a message from the input queue, examining the local store, and executing a sequence of operations. Each operation either involved in updating the local store, sending messages to other machines, or creating new machines.
Event handling in P was more reliable and faster. In terms of functionality, the new hub driver is more advanced as compared with the old hub driver. It has become more reliable as crashes and synchronization issues have reduced to a the point where the number of crashes in the new USB driver due to invalid memory accesses and race condition is negligible.
The development of P compiler by Microsoft outputs a Zing model enabling systematic testing. P compiler also generates C codes that can be used for execution in C compiler. Since, P is a domain specific language for implementation of protocols in an asynchronous applications, other parts of applications would be written in a host language such as C. The detailed explanation of foreign code interface used for interoperability in P manual, between P codes and codes written in C.