Is Functional purity clean?

After building several projects in Rust, which I consider a half-way functional language, I realized that many of my programming idioms could be significantly be improved. Improved, by C++ style stuff. That feels weird to say.

For example, I really like FRP for UI stuff. When a language supports lazy evaluation it can make UI code look really clean. However, in rust, being strongly encouraged to use a more procedural style, due to ownership, I found that this style can be equally legible. State machines and message passing are actually a great alternative to FRP. The catch here, I would say, is that the procedural style has a tendency to lead into spaghetti code with everything connected to everything else.

This is usually where greybeards will preach about good coding practices and standards conformance. The reality though, is that day to day it is hard to maintain perfect consistency across a codebase vs changelog. Then, once the standards start to fade, the whole mess snowballs out of control and leads almost inevitably to noodles.

However, the Rust own/borrow framework forces a separation of machine from messaging. This is the first time that I was actually thankful for the borrow checking. (Yes multithreading sounds nice, but I haven’t used it extensively, so that’s moot). This insight goes deep into the question of what makes a feature desirable. There are open RFCs for Rust with this exact subject: “What do noobs need to know about ownership?”

For me, it took me about three months working with Rust for it to really click. It is not like I have thrown out all of the functional idioms that I think are nice. Rust could definitely improve in legibility by cleaning up some of the thinking behind the borrow. Though, libraries and tooling can probably stand in for much of this pain. With a Turing-complete type checker there is plenty of room to just abstract away the dullness of, for example, making an extra function signature for a borrowed vs owned parameter.

Some ownership issues I would really like to just ignore, but keeping the message passing fence seems like a good kernel of positive influence to fuel the concept.

All around I am still very optimistic about the language’s trajectory. I do hope to one day see move-less closures, and widely quantified traits for things like equality. If we could even get some namespace metaprogramming, that would be amazing. Here’s to hoping.