Legacy in Functional Programming With Eric Normand
Apr 19, 2021
auto_awesome
Eric Normand, an experienced functional programmer, discusses legacy code, abstract data transformations, and the importance of immutability and invariance in functional programming. He explores the differences in reasoning and control between functional and object-oriented programming and shares his experiences working with old computers and transitioning to PCs.
Refactoring legacy code by breaking down large actions into smaller actions and calculations, implementing immutability, and creating invariants improves maintainability and reliability.
Legacy code bases with functional programming present challenges such as the presence of mutable and global variables, but also offer benefits like improved modularity and the ability to create domain-specific languages within the programming language.
Deep dives
The Importance of Refactoring Legacy Code
Legacy code is often associated with outdated technology and old systems, but it represents a significant part of the software landscape. Refactoring legacy code is crucial to modernizing and maintaining software systems. In the podcast episode, the speaker highlights the importance of viewing legacy code in a different light. Legacy code is the result of past developers' work and represents their legacy. The episode emphasizes the need to refactor large actions into smaller actions and calculations, implementing immutability, and creating invariants. By doing so, developers can improve the maintainability and reliability of legacy code.
Challenges in Legacy Code Bases with Functional Programming
Legacy code bases that utilize functional programming or functional programming languages present unique challenges. In the episode, the guest discusses some common issues found in legacy code bases with functional programming. These challenges include the presence of mutable variables and a significant amount of global variables due to efficiency concerns at the time of their writing. Additionally, the abstract nature of data transformations in functional programming can make it difficult for new developers to understand the purpose and logic behind certain code segments. However, the use of functional programming in legacy code can also offer benefits such as improved modularity and the ability to create domain-specific languages within the programming language.
The Benefits of Functional Programming in Legacy Code
Functional programming brings its own set of benefits when applied to legacy code. The episode dives into the advantages of functional programming, highlighting how it can simplify code and make it more readable. By embracing pure functions and calculations, functional programmers emphasize the importance of testability. Pure functions, which have no side effects and always return the same output for the same input, are easier to test with predictable results. This approach also promotes the idea of breaking down complex actions in legacy code into smaller and more manageable components. Additionally, functional programming allows for better handling of time and the creation of invariants, ensuring that software systems work consistently across different timelines and actions.
Grokking Simplicity: A Practical Guide to Functional Programming
The guest mentions his book, Grokking Simplicity, which serves as a practical guide to functional programming. The book aims to present functional programming concepts in a practical and accessible manner, rather than taking an overly academic approach. It covers topics such as actions, calculations, and data. The book delves into refactoring techniques for large actions, implementation of immutability, and strategies for analyzing and solving problems related to time and invariants. It also explores the use of first-class functions and functional programming tools, such as map, filter, and reduce. Interested readers can find more information about the book on the author's website.
Common Lisp was written in the 80s as a kind of an amalgam of the existing Lisps at the time. To make sure the Common Lisp would stay relevant, it was made backward compatible so that existing legacy systems could run on it. One thing in common to these big old systems like Lisp is a lot more mutation, and the cool thing about this legacy is that it has a baked experience – it learns and it has learned.
Today we talk to Eric Normand, an experienced functional programmer, trainer, speaker, and consultant on all things functional programming. He started writing Lisp in 2000 and is now a Clojure expert, producing the most comprehensive suite of Clojure training material at purelyfunctional.tv. He also consults with companies to use functional programming to better serve business objectives.
We talk about problems in legacy code basis utilizing functional programming, the abstract nature of programs, the wisdom of Lisp, and more.
When you’re done listening to the episode, make sure to check out Eric’s Clojure training and his podcast, as well as connect with him on LinkedIn.