Functional programming from a theorist’s perspective by Rhea Moutafis

September 23, 2021

In the Functional programming from a theorist’s perspective presentation by Rhea Moutafis, she shares her academic background in physics and her transition into functional programming due to its mathematical foundations and focus on manipulating data as functions. Rhea discusses the benefits of functional programming for large-scale projects, such as preventing technical debt and enabling efficient handling of vast amounts of data. She compares functional programming to object-oriented programming using the example of a school and its students, highlighting the differences in focusing on manipulating data and making objects interact. Rhea also discusses the challenges and benefits of learning functional programming, including the steep learning curve and the growing demand for functional programming skills in the industry. Throughout the presentation, she shares her personal experiences and achievements in functional programming, from her bachelor thesis to her current work with machine learning algorithms.

Functional programming from a theorist’s perspective: A comprehensive overview

Rhea Moutafis comes from an academic and mathematical background. Currently pursuing her PhD in particle physics in Paris, Rhea shared her unique insights into functional programming, its conceptual foundations, and practical applications.

 

Transitioning from physics to Functional Programming

Rhea began her presentation by sharing her journey from physics to functional programming. With a strong mathematical background, she found herself drawn to the mathematical proofs and data manipulation aspects of functional programming. She emphasized how functional programming allows for mathematically provable software, ensuring correctness without extensive testing. This is achieved by separating theory (functions) from data, leading to better testing and potential mathematical proofs, although these proofs are rarely used in practice.

 

Advantages of Functional Programming in large-scale projects

Functional programming (FP) shines in large-scale projects due to its ability to prevent technical debt. In other paradigms, adding new features can often damage or interfere with existing code. Rhea noted that major companies like Microsoft, Twitter, and Facebook have adopted FP languages such as F#, Scala, and Haskell, respectively. Despite its advantages, FP remains a niche area within the programming community, with a smaller percentage of questions on Stack Overflow compared to object-oriented programming (OOP). However, the demand for functional programming skills is growing, making it a valuable skill in the industry.

 

Conceptual differences between OOP and FP

Rhea used the analogy of a school and its students to highlight the differences between object-oriented programming (OOP) and functional programming. In OOP, the focus is on defining objects and their attributes, whereas in FP, the focus shifts to manipulating and making these objects interact. Functions in FP are pure, deterministic, and immutable, meaning they always produce the same output for the same input and cannot change the data they operate on. This separation makes it easier to manage and find data within the code, with key advantages being locality and immutability.

 

Theoretical foundations and practical benefits

Rhea delved into the theoretical foundations of FP, rooted in the theory of lambda calculus, which determines what can be computed and what cannot. This theory forms the basis of FP and can simulate any Turing machine. FP eliminates side effects, making functions pure and the building blocks of a program. By passing data as an argument instead of relying on external states, FP creates more structured and tidy code. Higher-order functions and the mapreduce technique, where functions are applied to each element in a list to produce a new list, are notable features of FP.

 

Efficiency in handling large data sets

An interesting segment of Rhea’s talk focused on the efficient implementation of functions like squaring and filtering large lists of integers using FP techniques such as map, filter, and reduce. She cited Google’s search engine as an example of FP’s efficiency in handling vast amounts of data. Google’s success is partly due to its use of FP, which avoids forward loops and relies on recursion. This approach is crucial for efficiently managing large-scale data processing tasks.

 

Functional Programming in various languages

Rhea provided an overview of languages suitable for functional programming. She noted that while Java and Objective-C are not ideal due to their impure nature, languages like JavaScript, PHP, Ruby, and Python support FP to varying extents. JavaScript, in particular, is well-suited for FP due to its immutable data types and functional features. Scala, Rust, and Erlang were mentioned as notable FP languages, though they might not be beginner-friendly. Rhea also discussed the limitations of FP, such as difficulties with user-generated input and random output due to immutability, and the memory-intensive nature of recursion.

 

Learning curve and industry demand

Rhea acknowledged the steep learning curve associated with FP due to its mathematical foundations and its difference from conventional programming paradigms taught in schools. Despite this, she emphasized the intellectual payoff and the growing industry demand for functional programming skills, which often lead to higher average salaries. She also highlighted the smaller, more personal community size of FP, which she finds advantageous for learning and collaboration.

 

Personal journey and research achievements

Towards the end of her talk, Rhea shared her personal experience with functional programming. Her introduction to FP came through her bachelor thesis and research papers, where she had to handle large data sets that Excel couldn’t manage. Transitioning from imperative to functional programming was challenging, particularly moving from loops to recursion. Rhea recounted a significant achievement in her research project: automating the recognition and calculation of uncertainties in particle collider data. This accomplishment marked a turning point in her career and led her to explore machine learning algorithms, ultimately improving her problem-solving abilities and program efficiency by more than 30%.

 

Conclusion

Rhea Moutafis’ presentation on Functional Programming from a Theorist’s Perspective offered a deep dive into the conceptual and practical aspects of FP. Her unique background in academia and mathematics provided valuable insights into the benefits, features, and limitations of functional programming. As FP continues to gain traction in the industry, Rhea’s talk highlighted the importance of understanding its theoretical foundations and practical applications, making it an essential skill for modern programmers.

 

Additional resources

Check out more from the MeetUp Func Prog Sweden. Func Prog Sweden is the community for anyone interested in functional programming. At the MeetUps the community explore different functional languages like Erlang, Elixir, Haskell, Scala, Clojure, OCaml, F# and more.