I like multitasking and my attention being divided, so during Craft Conference sessions (being very cool and useful anyway), I’ve spent some time to improve my Swift programming skills working on my laptop.
As I keep hearing nowadays that functional programming is fantastic, functional programming is awesome, and functional programming is the great extra feature in each established or new OOP / imperative language, I thought I would give it a try (again, having crossed each other unsuccessfully a couple of times earlier). So I read a very good tutorial about functional programming in Swift: https://www.raywenderlich.com/82599/swift-functional-programming-tutorial, and then I tried to apply it to a very simple piece of code written by one of the members of my team, replacing a for loop iterating over a collection with using the reduce construct.
The details don’t matter too much so I don’t share the code here, and actually it may be my code that is somehow wrong, but it’s not the point. What disappointed me was to face this compiler error message when creating my very first and quite simple (just one step more complex than the “hello world” type of example in the tutorial) functional construct: “Expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions”.
Luckily enough, soon after this, I’ve met an experienced iOS developer, who helped me fix the issue, so my first frustrated reaction disappeared. However, if we want to promote a new concept to developers, I could very easily imagine the compiler providing better support to make the first steps, and provide more descriptive error messages, or even hints on alternatives that work.