4 ms·
I have to say, having stared in to the abyss of large Haskell code bases, they're not necessarily easier to read than a large Java code base. Reading bad funct
by marcusf 14y ago
I have to say, having stared in to the abyss of large Haskell code bases, they're not necessarily easier to read than a large Java code base.
Reading bad functional code can be just as painful as bad OO code -- trying to untangle a mess of fold's that an overzealous developer who just learned of catamorphisms wrote can be painful. Even more so if that young developer is you, five months ago.
Sure, the language doesn't impose as much discipline in Python/Java/… as in Haskell(+), so it might require more of you as a developer to write clear, readable code (note: not saying that it requires more of you as a developer in general, just that it's easier to fall in to lazy anti-patterns). But if you work in a decent code base most of the pitfalls in the post are basically straw men. A well designed OO system will generally not be riddled with singletons and arbitrarily mutable state.
(+) I'm using Haskell here cause that's the only purely functional language I have any experience with. Substitute as you please.
- batista 14y ago>I have to say, having stared in to the abyss of large Haskell code bases, they're not necessarily easier to read than a large Java code base. Actually a Haskell oneliner can be more challenging that a large Java code base.
- EvilTerran 14y agoAnd a single Java class can be more challenging than a large Haskell code base. So what?
- batista 14y agoSo the first tends to happen far more often than the second. If anything, Java code is boring and boilerplate like, not difficult to comprehend. Haskell code on the other hand, not so.
- EvilTerran 14y agoI think we're arguing over subjectivities here -- comprehensibility is entirely dependent on the people involved as much as the language in question. If you're better at Java than Haskell, you'll find it easier to follow, and vice-versa; I know people in each category. And you can write clearly or obfuscate in either language; I've seen all the combinations. Personally, I tend to find Haskell easier to follow. I suspect that's mostly because I've used a lot more Haskell than Java of late, but it'll also be a matter of personal taste. As you say, Java can be very boilerplate-heavy -- some may find the redundancy makes it easier to follow, as it can remind you what's what "as you go"; others may feel like they're scrolling up and down hunting for meaningful code, and find all that boilerplate a distracting waste of space. I will admit that, on average, I'll have to spend a bit longer looking at a line of Haskell than a line of Java before I know exactly what it does -- but then again, you rarely need anywhere near as many lines of Haskell as Java to solve the same problem, so it feels like a net gain to me.
- batista 14y ago>I think we're arguing over subjectivities here -- comprehensibility is entirely dependent on the people involved as much as the language in question. If you're better at Java than Haskell, you'll find it easier to follow, and vice-versa; I know people in each category. I maybe arguing over subjectivities, but subjectivities turn into objectivities with the tool of statistics. And I think that in general (statistically), people find Haskell more difficult than Java.