4 ms·
I'm disappointed. From the title it sounded like someone had created a language specifically for dynamic programming (https://en.wikipedia.org/wiki/Dynamic_prog
by jejones3141 8y ago
I'm disappointed. From the title it sounded like someone had created a language specifically for dynamic programming (https://en.wikipedia.org/wiki/Dynamic_programming https://en.wikipedia.org/wiki/Dynamic_programming).
- jakeinspace 8y agoPlenty already exist which support dynamic programming "natively." For example, the 'memoize' function in clojure.
- alangpierce 8y agoI bet there are ways a programming language could support dynamic programming better than just having a memoize function in the standard library. Examples: * For a given DP algorithm, you might evaluate it top-down (recursive memoized call) or bottom-up (filling in the table values in topological order). Top-down is easiest to implement, but bottom-up can avoid stack depth limits and I think can be more efficient if implemented well. A language specifically crafted for it might let you write the simpler recursive implementation and efficiently evaluate it bottom-up. * Sometimes you might want to run the same DP algorithm in different contexts, e.g. operating on different data sets (where the data set is constant for a recursion tree). Keeping the data set (or even a pointer to it) in each cache entry is wasteful if your cache has 100 million things in it, and passing it down as a parameter is also not as efficient as it could be. I guess closures may solve the problem, but maybe there are smarter ways that a language could help here.
- basil-rash 8y agoSlap an @memoize decorator on a python function and you're good to go.