To explain my background, I’m a college student studying computer science who has been programming in Java for most of my programming career (~5 years). In the last two years, Elixir has become my preferred language for the projects that I do outside of school since I mostly do web applications. To be honest, Phoenix, not Elixir itself and functional programming, drew me to this ecosystem. I wanted to learn a web framework which was productive, up and coming, real-time, and interesting, and Phoenix was exactly that for me. I’ve started to enjoy Elixir as a language more and more as I’ve used it over the past two years, to the point I am at now where I’m very comfortable programming in it.
Because of this progression, I tend to write all my web applications in Elixir and some other things also in Elixir. However, for highly structural projects, I find that I think better in OO so I sometimes use Java for those purposes. Java has its ups and downs but having done it for so long I’m most comfortable with it and OOP as a language and way of structuring programs.
Recently, I started taking an algorithms class in school. I find algorithms very interesting, and I know a decent amount about them from. However, one of the first algorithms I was introduced to was the Gale-Shapely algorithm for solving the stable marriage problem. Initially, I spent about 20 minutes trying to implement the algorithm in Elixir before I gave up. I really despise admitting to this because it makes me feel like there is a ceiling which I have reached with functional programming as a paradigm in general and by extension Elixir but when designing or implementing an algorithm, my brain thinks in OOP, and its nearly impossible for me to translate that to functional programming in practice. This is very difficult for me to come to terms with because outside of this I love Elixir/Phoenix a lot and I want to be able to use it for everything that I need to program.
From using Elixir (and some Scala) I’ve been able to get much better at thinking in functional, implementing solutions functionally, using functional paradigms, and using functional programming in practice. However, the fact remains that when I theorize about programming (and especially algorithms), it is much more intuitive, natural, and easy for me to do so in an OOP paradigm. I feel like I’m pushing myself to try and do all of these things functionally in Elixir, when I could do them 3x faster in Java. I don’t like that feeling. Functional programming feels like a chore because I have to “translate” from natural programming/OOP design first.
I think algorithms in general are a serious pain point for functional programming because almost all of them are designed for languages like Java/Python and not functional languages like Elixir. Does anyone else feel this way? I can’t imagine I’m alone here. Also, does anyone have any resources that they recommend for trying to get into the mindset of thinking functionally in particular in reference to algorithms? I don’t have much trouble writing most practical things functionally but when it comes to algorithms, I just get lost. That’s why I don’t think introductory “think functionally” material would help me here, I need functional algorithms material.
Sorry for what looks like a long ramble but this subject has been on my mind for a while and it has festered enough that I want to get my difficulty out there and see if others have suggestions/resources to help me.
Thanks for reading