Zhijia Zhao, an associate professor of computer science and engineering in UC Riverside’s Marlan and Rosemary Bourns College of Engineering, has received a $600,000 grant from the National Science Foundation, or NSF, to improve event-based programming for computers and mobile devices. The project is a collaboration with Iulian Neamtiu at the New Jersey Institute of Technology, who received an NSF grant for the same amount.
“Taking Android as an example, if a user edited her profile in an app and clicked the ‘save’ button, the system would generate an event and trigger a piece of code to process this event. In this case, this piece of code should implement the logic to save a changed user profile,” explained Zhao. “To achieve this, Android provides a programming interface, called event handlers, for developers to implement such functionalities. In this way, when the events of interest occur, they would be automatically processed by their corresponding event handlers.”
Despite their popularity, event-based systems are poorly understood and prone to errors because the events that trigger actions must be organized in the correct order. Yet, it is difficult for programmers to know beforehand what that order should be. The programs are relatively easy to write but hard to get right. These difficulties have wide-ranging consequences such as losing users' work in mobile apps, silent errors or downtime in Web services, and unexpected IoT device behavior, such as a smart lock locking a user out of their own home.
“You can write a 10-line program that accomplishes a lot. Soon though it becomes a nightmare because the programmer has no control over ordering and makes a ton of assumptions: ‘trust me I know I’ll get the events in this order that I like, not the order they actually come in’, and all sorts of bad things happen,” said Neamtiu.