|
|
|
|
|
by EvilTerran
5101 days ago
|
|
Actually, it says to me "functional languages are unfamiliar, therefore they're bad". Particularly the crux of the essay: Any halfway decent programmer can quickly glean the general intent of most imperative code — even in a language he or she has never seen. While you can certainly figure out what functional routines do by looking at them, it may not be possible in a glance. Unlike imperative code, functional code doesn’t map to simple language constructs. Rather, it maps to mathematical constructs. What's actually the case is: any decent imperative programmer can quickly glean the general intent of most imperative code; equally, any decent functional programmer can quickly glean the general intent of most functional code. Furthermore, anyone with a decent grounding in merely algebra can quickly glean the general intent of well-written functional code. The same cannot be said of imperative code. As for ugly syntax... well, I don't know Erlang, but that Haskell is incredibly badly mangled. Haskell can be beautiful -- substantially more so than most languages, I'd say. The same code, reformatted: -- file: ch05/Prettify.hs
pretty width x = best 0 [x] where
best col [] = ""
best col (d:ds) = case d of
Empty -> best col ds
Char c -> c : best (col + 1) ds
Text s -> s ++ best (col + length s) ds
Line -> '\n' : best 0 ds
a `Concat` b -> best col (a:b:ds)
a `Union` b -> nicest col (best col (a:ds)) (best col (b:ds))
nicest col a b | (width - least) `fits` a = a
| otherwise = b
where least = min width col
There. Lovely. |
|