In computing, "to bail out" is "to exit early", for any reason, such as in your example. "To back out" generally has the meaning "to undo" changes, think ROLLBACK
in SQL. ROLLBACK
undoes and discards all current changes that have not yet been permanently committed (saved) to the database, returning it to its previous (stable) state.
Backing out should leave the program in a clean state, bailing out can leave the program in either a clean or an unstable state. Backing out is normally done carefully, bailing out is normally done quickly. For example, it might be desirable to restore the value of a changed variable on an error. Backing out will take care to do so, bailing out will exit as quickly as possible, potentially leaving a bad or invalid value in the variable.
Think of a plane on fire as a function about to crash the program. The program survives by bailing out with a parachute, but the function goes down in flames with the plane. (Actually, the function's run time and memory would be cleaned up and made inaccessible, equivalent to the plane being erased from existence before it has the chance to crash.)
Unfortunately, I can't find even bad references for either of these computing meanings, only blogs and the like showing them being used. If you'll forgive the original research:
By Dan Gookin
For recursion to work, the function must have a bailout condition, just like a loop. Therefore, either the value passed to the recursive function or its return value must be tested. Here’s a better example of a recursive function:
void recursion(int x)
{
if(x==0)
return;
else
{
puts("Boop!");
recursion(--x);
}
}
The recursion() function accepts the value x. If x is equal to zero, the function bails. Otherwise, the function is called again, but the value of x is reduced. The decrement prefix operator is used so that the value of x is reduced before the call is made.
(emphasis mine)
The meanings are very close to the standard English meanings:
- to jump out of an aircraft with a parachute because the aircraft is going to have an accident
- to stop doing or being involved with something
- to decide not to do something that you had said you would do
- to refuse to do something you earlier had agreed to do
In my mind, they mean different but similar things in computing too. I could be wrong about their meanings not being interchangeable. Perhaps "to back out" of a function is acceptable technical English. If one of my colleagues wrote one where I thought they meant the other, I would certainly ask them to clarify it since clarity is one of the most important things in computing. However, others may differ from my viewpoint.