3 ms·
A helpful oversimplification is to say OO "prefers dumb code and smart data", while FP prefers "smart code and dumb data". This makes a lot of sense, but it se
by amalcon 17y ago
A helpful oversimplification is to say OO "prefers dumb code and smart data", while FP prefers "smart code and dumb data".
This makes a lot of sense, but it seems backwards in a way: FP is as much about the realization that code is data as it is about any specific way of doing things. Your list of functions for "actions a player is allowed to take" certainly seems like "smart data" to me.
- lmkg 17y ago"Code is data" is orthogonal to smart/dumb code vs dumb/smart data, as it's a property of reflective (introspective?) programming languages, not functional ones. You could conceivably use imperative or OOP techniques in JavaScript to construct a string to eval(), but then Dijkstra would shamble out of his grave to give you a very stern glare. An array of functions to invoke is really more like a cute functional way of expressing a complicated switch. "Code is data" refers more to meta-programing, which would be having the language write the functions for you based on a higher-level description.
- amalcon 17y agoI was under the impression that it was neither "macros" nor "first-class functions", but rather something that encompassed both of them: basically, the idea that the programmer shouldn't need to treat one part of the data differently just because the processor does.