Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm assuming a lot of people click on it to see what the word Idempotence means. From the article:

"Idempotence is the property of a software that when run 1 or more times, it only has the effect of being run once."

And the example is, instead of a chron job just running a process once a month or on some other schedule, it runs more frequently but checks if the change has already been made.

(From the latin Idem which means "same" and potence is of course power/potent, so it has the same power/effect however many times you run it)



One of my first jobs was at an investment bank. They had a lot of programs that ran overnight, in a batch fashion. Everything had to be done before the markets opened the next morning. The term they used for idempotency was "free rerun." Being able to rerun any program with no special setup work was a high priority.

The value in programs being a "free rerun" was that every so often the program would barf on a bad bit of data in a record.

The programming environemnt was interpreted BASIC, so if an error occurred the program would print a message on the console and drop to an interactive prompt.

The operators running the batch schedule would see this and call the programmer on call for that night. You'd log in (over dial up at this time) and attach to the process, look at the error, figure out what went wrong, either correct the data or (more likely) skip the record and deal with it the next day. It was more important to have the programs finish on time; individual issues could be dealt with later.

Often you could just start up the program from where it left off, but if things were more screwed up it was important to be able to re-run it without any negative consequence.

Edit: this was ~30 years ago, so my point is that it's not any kind of new idea or something that wasn't recognized long ago.


I hope this example makes it evident that one of the primary innovations of the last 30 years is defaulting to Latin terms so that they are taken more seriously in business and technology circles to acquire ... you know... gravitas.


I used to be an operator in night shift in my twenties and the job was exactly how you said. Good memories. Lots of sleeping at work and some days of panic when shit broke.

And a lot of "secret" scripts that automated a big part of our job.


> And the example is, instead of a chron job just running a process once a month or on some other schedule, it runs more frequently but checks if the change has already been made.

As a property, I think it's even nicer if a script can literally fully run twice and for the outcome to be the same if it only ran once (so skipping the 'did I run before?' check).

Even though this check is useful in general, if you can define your data in such a way if it did somehow run, that this is not destructive / creates incorrect data, it makes the system more robust.

Of course this is not always possible though. For example, if the process results in an email being sent, you need an explicit check to not do that twice.


In situations like these, it's a legitimate goal to implement an idempotent, or "functional" core.

So the goal of your functional core is to fully construct the email, and return it to the caller, who then has the choice to send the email, print it, write it to disk, etc.

The program you deploy looks like this

EmailSender().send_email(construct_email(args))

You can test by implementing a "safe" EmailSender interface, so that you're executing the same code that's in prod.

In general, if a job/function is mutating state deep in the syntax tree (i.e. sending emails in the middle of a batch job), I personally see that as a violation of the Single Responsibility Principle.


Mathematically, it's x^2 = x, which implies x^n = x for all positive integers n.

Nilpotence (x^2 = 0) is also very helpful some times: it's a process which is self-reversing. Like the discrete Fourier transform (if you set up the constants properly).


self-reversing is not nilpotence.

In mathematics, a self-reversing function is called an involution, and it's f^2 (or f(f) ) = Id, the identity function.

Nilpotence is very different. It says that if you apply your function a certain number of times, you end up with zero no matter what the input is. For example, projection on x axis + 90 ° rotation of a vector is nilpotent.


X^2 is a weird way to describe it. A function f is idempotent if f(f(x)) = f(x).


It is quite common in some fields. Operator application is written without parentheses, and functions are a kind of operator. Therefore:

f(x) = f(f(x)) = f f x = f^2 x = f x

And leaving out the x, because it is just a placeholder anyways:

f f = f^2 = f

And of course this means that

f^n = f because f^n-1 f = f^n-1 by induction.


Depends on if you think of functional notation or matrix operators and linear algebra first. There's also dirac bra-ket notation from QM. I tend to reach for the latter two more than the former.

Particularly in this case O^2 = O makes more sense to me than f(f(x)) = f(x). And I just naturally think about A B - B A = 0 rather than f(g(x)) - g(f(x)) = 0 for commutativity.


It's not that weird. People often write iterated composition as f^k, and this is especially true with matrices, where composition and multiplication mean the same thing.


Careful, for nilpotence the power doesn't have to be 2.

Also you may be confusing it with x^n = 1 (which I'm not sure how to name, 'root of unity' perhaps). This would be the case for the Fourier transform (with n=4).

If x^2 = 0 then applying the Fourier transform twice would null your function, which isn't the case.


No, you are confusing with involution. 1/x is an involution. Symetries are often involutions.

Squaring a upper triangular matrix with 0 on the diagonal is nilpotent. Derivatiting a polynomial of degree N is nilpotent after N iteration.


When writing a Jupyter notebook, always try to make your cells idempotent. You’ll save yourself a lot of headache down the line.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: