This Is AuburnElectronic Theses and Dissertations

Optimization of List-Based Functional Pipelines




Soehnlin, Timothy

Type of Degree

Master's Thesis


Computer Science and Software Engineering


There has always been a disconnect between how humans organize computer code, and how computers execute it. Functional programming is a paradigm that increases code maintainability and testability, but generally results in poorer resource utilization by the computer. The increased resource cost versus code quality is usually an acceptable cost. However, code that is executed many times over, would benefit from optimization as the cost of the introduced abstractions are amplified. Specifically list-based functional pipelines (map, reduce, filter, etc.) are extremely sensitive to this overhead as the functional overhead is paid for each element in the list. In this paper we provide a JavaScript optimization algorithm that trans- forms list-based functional pipelines (e.g. => x * 2).filter(x => x > 2) ) into for loops by combining source-level analysis and runtime evaluation to construct and compile optimized code at runtime. This optimization algorithm allows us to dynamically translate common list-based functional pipelines into a form that is optimized for computer execution, without modifying the original source code. This hybrid ultimately provides the best of both worlds, allowing the human to write and manage code in a manner that is familiar and more understandable, and for the final output to be in a form that executes with higher efficiency.