|
|
|
|
|
by glassx
5101 days ago
|
|
> How many ways can a reasonable programmer write the factorial function imperatively This page is a terrible example. Most of these are not not what a "reasonable programmer" would do. An unreasonable programmer would be able to screw up on any paradigm. You'd probably have even more ways to screw up like this with an OO language, creating classes for recursive functions, trampolines, a pattern matching class, implement an language interpreter inside your factorial implementation, etc. |
|
My example was about imperative languages. You assertion on how many ways one could screw up on OO is irrelevant and besides, you'd really need a good understanding of OO to even try implementing those.
I didn't mean to use to imply any of those methods were bad. I have revised my post so people can't miss the point.
That is
> It is unfortunate when your ability to program functionally is directly proportional to how much of the standard library you have memorised. This makes functional programming much harder to learn.
Now, addressing your concerns.
> This page is a terrible example. Most of these are not not what a "reasonable programmer" would do.
All of the examples except for few particularly egregious ones seems reasonable to me.
For example
Six fairly distinctive ways. I'm sure there's more that's as elegant if not more elegant ways to do the same thing.