--

Part of the difference is that even though the behind-the-scenes implementation is the same (and the functional version is usually slower!) the functional approach removes some of the boilerplate where errors occur. Some studies suggest huge amounts of errors are caused from trivial mistakes, like improperly counting with a variable in a loop, or changing a variable that was assumed to be immutable. But the functional approach can have notable disadvantages too, including the fact that it makes the code for some simple tasks more complicated to read and mentally parse.

Sometimes it seems like each new programming trend wants to reinvent what came before. In any case, popular hot-take rules like “stop using loops” are complete silliness.

--

--

Matthew MacDonald
Matthew MacDonald

Written by Matthew MacDonald

Teacher, coder, long-ago Microsoft MVP. Author of heavy books. Join Young Coder for a creative take on science and technology. Queries: matthew@prosetech.com

No responses yet