Hacker News new | ask | show | jobs
by carlmr 1721 days ago
I agree with you that spacing up everything with well-named let-bindings is a great idea, but most ML-based languages do support that.

>To think that any human, with any amount of training, can parse such code in one pass is a fantasy.

This is exactly what I think about OOP object hierarchies, where one function is distributed over 15 files and you need to keep the state of the object in your mind when thinking about what this function could do.

In contrast when reading F# I often only need a single-pass, because with let bindings and the |> operator I can see how the data goes in, what is done to it one step at a time, and what comes out. It's as simple as it gets. Granted that single pass might be slow, but that's because it is dense and doesn't contain so much extraneous noise, like the boilerplate standard-OOP creates.

If you then work with a team that uses proper railway oriented programming. I.e. not only pure functions but that use the type system to express failure. I.e. a sqrt function that returns Some(sqrt(x)) for x >= 0 and None for x < 0. Then it becomes even more simple and explicit to understand what can go wrong and how that is dealt with. Instead of some sub-sub-sub-function throwing an exception that you never heard about until it happens at runtime.

You can almost never single-pass OOP code, especially if some architecture astronaut that memorized the GoF book had their way with it.