I feel that the memoization is an important and distinct method and I favor having a tag, rather than grouping it into an umbrella tag.

I think that the subject of memoization, either in direct question or as a best answer comes up fairly often. The subject of caching on the other hand seems to be more limited, often about internal Mathematica behavior and not programming methods.

I think it will be beneficial to have a tag that closely relates to other questions with that tag.

Should we have a tag?

As a point of reference, I believe there should be a separation between questions about memoization and this one which is implicitly about caching:

FE`symbols that remain in notebook internals even after removing them and SaveDefinitions->True issue

| |
  • Some thoughts: what if we add caching-internal or internal-caching to refer to Mathematica caching issues? Would this be sufficient differentiation between user set up caching and mma caching? – rcollyer Feb 1 '12 at 17:28
  • @rcollyer I suppose so, but I expect a fair amount of retagging caching <===> internal-caching. – Mr.Wizard Feb 1 '12 at 17:34
  • I've updated my answer with my concession to the point. – rcollyer Feb 3 '12 at 19:35

Right now we have several questions (1, 2, 3, and 4) asking in various ways: how do I store part of my calculation for later reuse?* Memoization is a valuable technique, but I am not sure it warrants its own tag for three reasons:

  1. it is straightforward to implement,
  2. it is not the only method for reusing prior calculations,
  3. and from a user perspective, caching and persistence** are the more well known terms.

From my point of view, it is because of the last reason that I must disagree.

* While only two of those questions are tagged with , that is more due to an oversight, and lack of consistency because we are still early in this process.

**Of course, with regards to vs. , we have to come sort of agreement on which one to use.

Edit: Due to the potential for confusion with regards to user controlled caching (such as memoization) versus the effects of Mathematica's internal caches, I must concede the point in favor of having refer to user controlled caching and refer to Mathematica's internal systems. Here's the relevant chat discussion.

| |
  • Thanks for explaining this. – Mr.Wizard Feb 1 '12 at 3:42
  • @Spartacus, you're welcome. Of course, broadly interpreting point two, you'd have to include Import/Export, also, as they are persistence functions. But, I think we can agree that they may be abusing the definition a little. :) – rcollyer Feb 1 '12 at 3:46
  • 1
    Of those two options, I would vote for "caching". However, I'm inclined to consider memoization as just one dynamic programming technique, and so would consider "dynamic-programming" as a better tag--assuming that it's not considered too broad, and that everyone can be expected to know what it means. – Oleksandr R. Feb 1 '12 at 4:33
  • 1
    The distinction between persistence and caching seems quite clear to me. Persistence is usually used in the context of objects (de)serialization, saving state on disk or to databases. I think that caching is a relevant term for keeping some results in-memory for later reuse. – Leonid Shifrin Feb 1 '12 at 8:30
  • @LeonidShifrin are there other methods of caching, per your distinction, available to the user? – rcollyer Feb 1 '12 at 14:23
  • @OleksandrR. I like dynamic-programming, but I do think it is to broad, and unfortunately there is a balance that has to be found between overly broad and too narrow. – rcollyer Feb 1 '12 at 14:24
  • @rcollyer I wrote once a package called Cache, which, while is based on what we know as memoization in mma, is different in that it allows you to limit the number of values cached at any given time, and is indeed closer to the standard meaning of the cache mechanism. This may become useful when one wants to stay within certain memory constraints regarding the accumulation of memoized values. The package lives here: mathprogramming-intro.org/additional_resources.html. Note: although I used it without problems for some time, I started having some doubts about its correctness recently. – Leonid Shifrin Feb 1 '12 at 14:53
  • @rcollyer Another useful mechanism is to keep data in memory in compressed form, using Compress - Uncompress. I have developed a few meta-programming - based techiques using this, for some examples of practical use of them see these answers: stackoverflow.com/questions/8247005/…, mathematica.stackexchange.com/questions/36/…. – Leonid Shifrin Feb 1 '12 at 14:57
  • @rcollyer Yet other approaches (although more on the persistence side) can be found in this very useful answer by WReach: Another very relevant answer: stackoverflow.com/questions/5287817/… . – Leonid Shifrin Feb 1 '12 at 14:58

I think memoization does warrant its own tag. Strictly speaking, it is a subconcept of "caching," but memoization is not necessarily what people think of when they hear the word "caching." Plus, the fact that Mathematica makes memoization so easy means that it is very common in Mma programming, but there are enough subtleties that one can still ask many meaningful questions about it.

When considering whether a tag is appropriate, one thing to keep in mind is how often people will want to search for questions relevant to the tag's concept. Memoization seems like a useful tag in that sense because I can easily imagine someone coming to this site with a question of the form "This memoization code is not working; what might be wrong with it?" Searching the tag will point them to the most common pitfalls to check.

If the Mathematica documentation has its own technical term for the practice of memoization, then I suppose we should use that. But otherwise, I'm not convinced by the arguments against having this tag. In particular, neither "caching" or "persistence" seems like an appropriate substitute IMO.

| |
  • I'm not sure there are enough subtleties to memoization to warrant more than a couple of questions. Also, it was only after becoming involved with SO that I learned the term: memoization, yet I knew the term caching before then. However, if we use Leonid's definition of caching as in memory only: what other methods of caching are available to the user? If you can convince me there are none, then I'll concede the point. – rcollyer Feb 1 '12 at 14:23
  • @rcollyer To be sure, memoization (or, better, dynamic programming) can be a lot more sophisticated in mma than just memoization of specific sets of values which is commonly known. For a relatively simple but non-trivial example, see this answer of mine: mathematica.stackexchange.com/questions/53/…. There can be a lot more sophisticated schemes of making up new and/or manipulating existing definitions at run-time. If we call all those dynamic programming, I think it sure warrants a separate tag. – Leonid Shifrin Feb 1 '12 at 15:04
  • @rcollyer I am now ready to add one more example of less trivial use of memoization: mathematica.stackexchange.com/questions/1119/…, to those I mentioned already. – Leonid Shifrin Feb 2 '12 at 0:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .