1. A method for creating a distributed application flow from a set of rules, wherein the method comprises: creating a control-flow graph for each rule from the set of rules and creating one or more dependency links between two or more rules from the set of rules, wherein the set of rules comprises at least one of stateless rules and stateful rules; partitioning a resulting graph, wherein the resulting graph comprises one or more control-flow graphs and one or more dependency links, into one or more operators by determining an optimal set of one or more cuts through the resulting graph such that a cost function is minimized; and generating stream processing flow code from the partitioned graph.