re: Haskell/Python/Go web scraper comparison completed VIEW POST

re: I find lines to be far less relevant than characters when comparing the lengths of programs written in different languages/styles. Haskell Go ...

You make a good point. I neglected the importance of line length.

I think a lot of the reason my Haskell has such long lines is that the workarounds that purify non-pure things tend to involve a lot of helpers like runReq and defaultHttpConfig, which don't add as much semantic complexity as an equivalent increase in characters would normally suggest.

I'd say one of the reasons I value line count is that it affects how much code (semantically) I can fit on the screen at once, which is a big factor in how easily I can read and maintain it. Counting by characters also makes it seem better to use very short variable names, which can hurt readability as much as verbosity can, whereas if you count by lines, identifier length isn't a factor (unless it makes you wrap).

Though I have to say that for most of the metrics you mention, Haskell would be disadvantaged just because it's difficult to learn and I'm not a master of it yet. Writing the Haskell version took me a couple hours, but a more seasoned Haskeller could surely have written it as fast as I wrote the others. And I of course spent a few hours just struggling with Haskell package management (I do every time I touch Haskell for anything). As far as writing time, the time to find libraries and read documentation on ones I wasn't already familiar with was also a big factor for both Haskell and Go.

Line count (or character count) on the other hand is less dependent on how experienced I am with the language.

As for the last metric, though, I think Haskell would win on that even despite my lesser experience because it encodes the most information into the type system. With Python I'd have to do the most testing, with Go I'd have to worry about nil and pointers and other gotchas, and with Haskell, if it type checks, I can almost be certain it works.

code of conduct - report abuse