This thesis explores detecting patterns in the most general interface to computers: source and assembly program code.Because writingcomputer programs correctly is so difficult, there is a large assortment of software engineering techniques devoted to making thisprocess easier and more efficient.Therefore, despite the huge space of possible programs, most programs written by humans will exhibitsome of the same patterns.Project Laika detects the data structures used by guest programs usingunsupervised Bayesian learning.Using these data structures, it candetect viruses with considerably better accuracy than ClamAV, a leading industry solution.Using high-level features makes Laika considerably more resistant to polymorphic worms, because it requires them to preserve their high-level structure through their polymorphic transformations.Project Macho generates Java programs from a combination of natural language, example inputs, and a database of Java code.Unlike past natural language programming systems, which were basically verboseversions of Visual Basic, Macho allows users to specify (small) programs in high-level language and use examples to fill in the details.We were able to generate satisfactory solutions for basic versions of several core utilities, including ls and grep, even whenthe natural language inputs were varied substantially.