Hacker News new | past | comments | ask | show | jobs | submit login
Toothpaste Null-Terminator (dunkels.com)
92 points by userm0d 38 days ago | hide | past | favorite | 76 comments



I use an even simpler and more reliable system to avoid running out of toothpaste: brushing with plain water. Evidence suggests that brushing with toothpaste (called "dentifrice" in scientific papers) does not remove any more plaque than brushing without it. Here's a systematic review from 2016:

>Does dentifrice use help to remove plaque? A systematic review

https://pubmed.ncbi.nlm.nih.gov/27513809/

"The cumulative evidence for this systematic review demonstrates that there is moderate certainty that toothbrushing with a dentifrice does not provide an added effect for the mechanical removal of dental plaque."

However, plaque removal is not the only purported function of toothpaste. It can also serve as a fluoride delivery system, and fluoride has strong evidence for strengthening teeth. I personally drink a lot of tea, which is a fluoride hyper-accumulator, so I'm more concerned with avoiding fluoride, but if you don't drink tea this might influence your decision to use toothpaste.

There are also some toothpastes with antimicrobial ingredients. Those also have strong evidence for actually doing something, although I'm personally skeptical that messing with your mouth's microbiome like that is a good idea.

Additionally, I believe that toothbrush wear is an underestimated factor in cleaning efficacy. Toothbrush bristles are manufactured with microscopic texturing that helps remove plaque. I can feel the difference when changing from a worn to a new toothbrush. Ben Krasnow of Applied Science has a video on Youtube with electron micrographs showing the difference:

https://www.youtube.com/watch?v=cwN983PnJoA


Huh, interesting. Not exactly conclusive, though. https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3841993/


More precisely, there's nothing in that review that even speculates that drinking tea might be an adequate substitute for using a fluoride toothpaste, let alone demonstrates it.


I don't mean to imply it is, I'm simply explaining the reasoning behind my own decision. Fluoride might influence your choice even if you do drink tea.


The idea that a "minty fresh" mouth (or the idea that "mint" implies "fresh" at all) was the product of an ad campaign in the 1930s. It's not some sort of human universal.


It's way more fresh than lots of other scents.

Much human effort has been spent eliminating unpleasant odors.


But the association could just as well be to cinnamon, or spearmint, or blueberry. US toothpaste aisles have little variation, especially when compared to other countries without the mint obsession.

Then again the flavor choices in US potato chips is extremely constrained too. Never seen the notorious "hedgehog flavoured" in the US!


Practically any other flavor could be used, but mint in general - and peppermint in particular - "drowns out" other scents. So if your breath is just not-so-fresh, rather than downright vile, it's a better choice.

If you have to work around noxious smells, a bottle of peppermint oil gently daubed onto a bandanna or mask helps a lot.


> I use an even simpler and more reliable system to avoid running out of toothpaste: brushing with plain water

Breath though. Wouldn't fly with my wife. I not only brush with toothpaste, I then use some Hexetidine. And then I take a little Fisherman's Friend or something similar.

I like the feeling of freshness. I don't care much about the actual effect: I just care about feeling fresh.


If you have proper dental hygiene there should be no smell from your mouth besides after spicy foods/ onions/ garlic etc. until you brush of the plaque. Or if you are sick (that goes mostly from the bacterial disbalance, the stomach etc.)

Of course, the minty freshness is nice to have but that is just a bonus. Most people rely on this to cover up bad hygiene but a proper dental hygienist will of course see the problems either way.

If you search my comments, I have written about dental hygiene at length. Source: my fiance is a DH, see neighbouring threads.


Yeah.... I don't care if other people have plaque on their teeth, I can't see it anyway. But if they reek, that's nasty.


I use an electric toothbrush, and it leaves no sign of plaque (highly recommended over non-electric ones, by the way). When I start feeling plaque over my teeth, I know it's time to change the brush, that happens maybe every three months.


That assumes you use a suitable electric toothbrush and technique. If you search my comments I have written about dental hygiene before at length.

I use Philips Sonicare, heard good things about Oral-B iO from a dental hygienist who has patients using both.

Of course, flossing using a super floss (OralB makes those) and interdental brushes by Curaprox/ TP of correct sizes is important to also clean the space between your teeth and significantly lower the likelihood of gingivitis and almost eliminates the progression to periodontitis.


I'm a lazy procrastinator and have never checked if my water if fluoridated, so I brush with fluoride toothpaste.


Not that lazy if you brush your teeth, imo.


Wow! Thanks for sharing.

So do you change your toothbrush every quarter?


And the interdental brushes hopefully more often. Or, of course, you floss in that case you have a harder and more time consuming way of staying on top dental hygiene.

(Source: My fiance is a dental hygienist in Prague, Czechia specializing in periodontology and treatment of advanced periodontitis.)


Yes. I buy moderately cheap ones, which I find work just as well as expensive ones.


I don’t understand how this works with systems like toothpaste? I get if you somehow stored your toothpaste in some queue-like structure where you only see 1 at a time, then yes, reaching the last would be helpful. But surely they are in a cupboard or drawer or something?

To know to start the sentinel toothpaste he must search around and prove it’s the only one left - by doing this he doesn’t need the sentinel anyway, as the searching process with yield only one, sentinel or not?

If it doesn’t need a search, e.g. they are in a line/all on easy view - then it’s obvious it’s the last even without a sentinel?


It helps if you are forgetful in a certain way. If you can remember to buy new toothpaste when you get the last tube out of the drawer, you don;t need a sentinel. But if you forget that the tube you just brought out is your last 5 minutes after you took it out, the sentinel reminds you.

Similarly with the emoji list. If can reliably remember which emoji is last, then each is equally as good as a sentinel. But if you can't, having one which is "special" will help remind you.


I assume OP's solution has thread-safety requirements. The toothpaste may be retrieved from long-term storage by another thread, and that thread may not be configured to check for termination conditions.


Children act more like separate processes than threads - it would be a miracle if we could read their minds or put them to sleep for a bit.


The benefit imo here is not that you realize you need more toothpaste only while you search for the last one, it's that while you're using it there's a clear signal to get more.


Buy two tubes, while true, when you finish a tube, add one toothpaste tube to the shopping list, done.

Works great for an average person who usually visits the store. Adjust the initial putchase if you visit the store twice a year.

Also works great for many suplies like coffee, pasta, legumes...


I just put my running-out items on the entryway table.


Me too! If I must take out some forgettable item, it sits blocking the door.


Blocking the door is my go-to way of making sure I don't forget something when leaving the house.


Exactly how (and why) I try buy things. Not exactly "bulk" buying but more "at least 2" buying.


This is a much simpler way. Now only to remember to do it next time I get groceries.


yes, having a shopping list is good, but have to remember to put it on the shopping list, so same logic applies.

i.e. when taking out last tube, you have to remember to do it them, but you are about to brush your teeth, so probably not going to do it then, will get to it afterwards, but you're a forgetful person, so you forget, and now you've forgotten its the last tube.

But with the sentinel tube, every time you use it you will remember its the sentinel and you'll be like "did I add it the shopping list?" Eventually one time you'll remember to check the storage / shopping list to see if it needs to be added.

TLDR: the point is for forgetful people who can't do the action required right away.


> When I find that the only tube of toothpaste left is that special, sentinel toothpaste, then I know it is time to buy more toothpaste. And then I have ample time to do so.

I might suggest phrasing this a little differently. Obviously, when you find that any tube is the only tube left, you know it’s time to buy more toothpaste. The problem is that you realize this early in the morning or right before bed, and so you’re likely to forget. The advantage of the “sentinel toothpaste” is that it continues to remind you after that moment, so that you’ll actually remember when you have time to do something about it.

And I think that captures the key thing about a sentinel value: it captures state in a place where you’re already storing state, without requiring you to wrap the state in some external structure, e.g. putting a sticky note on your mirror or storing a string’s length in a separate field.


My under sink cabinet is a mess. For me, I have no idea if someone is my last tube or just that another one is hiding. This way at least if the different tube is the only one I've found within a reasonable time, there is a high probability that it's the last one. Similar to the classic probability example of marbles in bags.


Neat, but I prefer my own method:

1. Have two toothpastes (actually two of everything) 2. When one gets used up, remove the checkmark from my shopping list (just a simple checkmark list on my phone in Google notes) 3. When in the store, buy everything that's not checked on the shopping list

Works all the time, except during the CoVID toilet paper crisis, which made me increase my prepper level to 3 of everything.


My toilet paper routine, which started even before covid, is to buy about 400 rolls of toilet paper from Costco, and then I never even think about buying toilet paper ever again for a couple of years. And then one day it runs out and I realise the infinite toilet paper stash was in fact finite after all. As if that isn't bad enough on its own, I then discover that while inflation has been running at 9% a year for everything else, it was more like 100% a year for toilet roll.

A different class of problem with this technique is when I bought 150 old-style lightbulbs just before they got banned in the UK. At the time, I really hated LED lights because they flickered, and so I could use them in areas I just passed through, but nowhere I sat and spent any time. I still have about 120 of them left because, of course, LED bulb tech has got better and I now only have 2 lights in the house that still use the old bulbs. They don't get much use, one is in the loft and one is in a cupboard.


Just a simple 2-queue. I love this, since it's low friction and your essentials are persistent. No more brain-wracking to remember what the grocery list is missing.


> When I find that the only tube of toothpaste left is that special, sentinel toothpaste, then I know it is time to buy more toothpaste.

I buy more $CONSUMABLE whenever I take the last unit of $CONSUMABLE out of storage. If I don’t order online or add it to the grocery list right away, I put the old empty (second-to last) container in a place where it is likely to prompt me to resupply in a timely manner, which is often different from the place where $CONSUMABLE is consumed. Otherwise there’s the risk that the “special sentinel” is always encountered at a place or time where resupplying is inconvenient, and so it might run empty before you get around to it, despite its “special” nature. This approach also has the benefit that you don’t have to switch from your favorite variety of $CONSUMABLE.


My day to day shopping list is literally the leftmost foot or so of my desk—which is large enough to accommodate the extra space, and that space positioned right by the door leading outside.

I put anything needing resupply, empty or approaching empty depending on the item, right there on that part of my desk. Unless I’m rushed or preoccupied, checking that space before I leave for the store is usually pretty effective for my defective executive function.

Remembering to clean up the queue afterward is a bit more challenging. But that’s just a mild inconvenience compared to prior years of consistently failing to stock essential items on a routine basis.


I believe neurotypical and neurodivergent people have very different understanding of this article.


Why is that?


For a neurodivergent person remembering to buy a toothpaste or just anything maybe quite challenging. https://www.additudemag.com/adhd-dad-lost-in-the-supermarket...


That's a good read. Thanks for sharing.


The original application of the sentinel technique makes linear search faster.

Looking for 42 in a table of integers? Put 42 after the last element (obviously you need n+1 elements allocated) and your loop does not need to check array bounds, only checking for a[i]==42 is now guaranteed to stop and not read past the array bounds.

(obviously it doesn't work if multiple threads search the same table for different values)


> In programming, a sentinel value is a simple way to keep track of the end of a list of items.

A type of sentinels that are cute are "poison pills": when you have a queue and know at some points that no more items are coming, and several consumers, you can simplify the logic by putting as many poison pills at the end of queue as there are consuming threads.

When a consumer finds a poison pill, he stops removing/processing items for the queue.

As there are the same number of poison pills as there are consumers, all consuming threads shall eventually stop.

I probably learned about poison pills back in the days either in Effective Java or in Java Concurrency in practice.


I think the point kind of swooshed me (I notice taking out the last tube as suggested by another comment).

Adam is obviously massively competent and known etc, but as an avid SO poster I have to point out the potential accidental footgun discharge:

In C abs() returns int, you must use fabs(). Not sure about other C-like languages and the article doesn't specify language but still.


Am I the only one that has no trouble buying toothpaste when I have to squeeze the tube extra hard?


Many years ago I learned from some Japanese TV show that you can use centrifugal force to get the very last bit of toothpaste out of the tube even if you can’t squeeze out any more. Something similar to this: https://m.youtube.com/watch?v=u-4MKefJqbc


By that point, I think it's easier just to cut the tube open.


I only buy new toothpaste after the squeeze returns nul.


Not at all. A tube of toothpaste lasts me a long time, and pre-covid I would usually only own one tube a a time.

Post covid I like to keep at least a month stash of anything cheap and durable as toothpaste.


> Post covid I like to keep at least a month stash of anything cheap and durable as toothpaste.

We are a family of 3, and teeth are brushed at least twice a day. 5 tubes of toothpaste would last 6 month. That’s a lot of toothpaste.


I treat the hard to access part as an emergency supply for when I forget to buy more in time. So normally I will throw it in the trash.


sense... this comment makes none.


Inline signaling is often flawed. Nevertheless the real life analog would be more akin to kanban not sentinal value


I had a roommate that kept a can of "King Oskar" brand fish balls. When that was visible on the shelf, he went to the grocery store.


Just use kanban. Put one backup toothpaste in a drawer and when you get it out add it to the shopping list right away. Works for anything non perishable which you can stock up on, like toilet paper or cleaning supplies.


It must also be implememted in toilet paper packs. Last roll should be of different color.


I have seen some brands that do essentially this, e.g.: https://m.media-amazon.com/images/I/61wjeonOCdL._AC_SL1500_....

Personally I just keep a few rolls of single-ply Scott on hand for backup if my stock gets too low.


When I worked in retail the till roll (i.e. for the cash register to print receipts) had a red streak on the last metre or so.


Kleenex tissues have this feature where the last several tissues are of a different color.


Buying a different toothpaste seems very odd, you need to ensure ordering to make this work so all the extra toothpastes are going to be in one spot. When you grab the last one then you order more or add it to your shopping list. Personally I don't let myself pick up or use the last item until I've ordered more to prevent "I'll remember to do that later", at worst I'll set a recurring hour reminder to buy more so I don't forget.

I just have rows of everything I use that's consumable in my pantry or bathroom closet (depending on the item) in rows. If the row is getting too deep then I need to skip/limit my subscribe and save (or skip buying more when it's on sale if it's not automatic), if it's down to the last item or two then I might order more.


I do this but for something I think is even more critical: Toilet paper! (Running fully out is much worse.)

The "last" roll of last resort is cheap 1-ply, and it serves as an unavoidable reminder to restock and replace it.


I just keep a 2-package buffer minimum. Only 2 unopened packages (of like 6 rolls)? You're out, order more or add it to the shopping list. Packages opened are effectively empty and don't count. Honestly I use this for most consumables, having that buffer is so nice.


In the old* days, "control break" programming assumed sorted inputs, and used any difference between the group of this record and the group of the next as an implicit terminator.

* cards through mainframes, so roughly 1910s-1960s?


Brushing teeth is a good example of activity where you use almost zero cognitive effort, because the daily routine is so automated. That's why it's so easy to forget to buy more toothpaste - you just don't think about it at all. I completely get the sentinel idea as a trigger that turns your brain back on. It's probably not just the different packaging, but also the different taste, that keeps reminding about it until you buy more of the usual stuff.


If, as I do, you buy Who Gives a Crap?[0] toilet paper, they send you some of them in a gold paper wrap to let you know you're almost out.

[0] https://whogivesacrap.org


I use consumables like toothpaste as top-up items to get past the minimum threshold to qualify for free shipping at Amazon and Walmart. This implicitly triggers a mental check to see if I'm running low on anything.


Right, so you’re using toothpaste as padding to align your shopping basket struct.


Exactly!


> When I find that the only tube of toothpaste left is that special, sentinel toothpaste, then I know it is time to buy more toothpaste.

I don’t get it. If there’s one tube left, what does it matter what kind it is


I want to say something smart and clever but it’s just some person talking about a fun little comparison they make between mundane life tasks and programming concepts… it’s dumb and fun, yay


Sounds a lot like the anecdotes from the early 2000s of soldiers being given tracer rounds to put near the end of their magazines to indicate they’re nearly out.


This wouldn't work in a situation where not everyone agrees to abide by the arbitrary rule of using toothpaste (or whatever) in as specific order. In a computer's memory, or storage media, the ordering is intrinsic, but in your bathroom cupboard it is not, and would have to be enforced by convention or some other contrivance. If someone decided they wanted to open the "special" one because they prefer it, or don't care about your weird toothpaste order kink, it all breaks down.

Not all things we do on computers translate well to meatspace.


"Playing well with others" is very common in computers, and it translates well to meatspace too.

There are lots of programming languages that are built on coventions (for example in Python, private variables are not actually protected in any way). We rely on other programmers to know the rules and respect them. Same goes with toothpaste management system, or with deciding what should happen even you finish communal ketchup bottle.


Don’t you get, like, two weeks out of the end of a tube of toothpaste? That’s plenty of time to put it on your shopping list.


Hahaha, why not just check if the toothpaste you're grabbing is the last one?


Because it's too easy to not bother checking that, whereas you can't avoid noticing that you got the "sentinel" tube. You might still not bother exhaustively checking the cupboard but that's fine - it just means you order more toothpaste slightly too early rather than slightly too late, which would be much worse.

Still I think this is a stretched analogy. Decent strategy in real life, but programming is not the same and in my experience in-band signalling like this generally leads to fragile code. I mean nobody would recommend null terminated strings as a sane design today...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: