They say hindsight is 20/20, and while it's easy to look back and recognize ways you could've done better, it can be far more helpful to learn from other people's mistakes. In a recent TD Ameritrade survey, participants aged 40 to 79 were asked what piece of financial and retirement advice they wished they could give to their younger selves. Here's what made the most lists.

1. Start saving earlier in life

A good 68% of middle-aged to older Americans agree: Saving for retirement from as early an age as possible is a crucial step on the road to long-term financial security. The sooner you begin building your nest egg, the more you'll benefit from the power of compound growth. Wait too long, and you put yourself at far greater risk of falling short on funds later in life.

Older man pointing to laptop while younger man sits at it

IMAGE SOURCE: GETTY IMAGES.

Imagine you're able to start contributing money to an IRA or 401(k) at the age of 30, and that you retire 37 years later. If you contribute $300 a month, you'll wind up putting $133,200 of your own money into that account. But if your investments generate an average annual 7% return, which is entirely reasonable with a stock-heavy asset allocation, you'll actually end up with roughly $577,200 in your portfolio by the time your career wraps up. The difference? Compounded returns. And that's why it's important to give yourself as long a savings and investment window as you can manage.

2. Start investing earlier in life

In a related point, just saving money for the future is not enough. Inflation erodes the value of dollars that just sit in a bank long term, so whether you do so in a retirement account or a traditional brokerage account, you need to invest your money if you want it to grow. That no doubt explains why 60% of respondents said they wished they could go back and tell themselves to start doing so at a younger age. Though investing does carry some risk, "playing it safe" only guarantees you'll earn minimal returns on that cash.

For example, in the section above, we saw that investing $300 a month in stocks over 37 years could turn $133,200 in contributions into $577,200, representing a $444,000 gain. But what if you left that money in savings accounts or certificates of deposit instead? Based on the rates we've seen over the past 10 years, you're looking at an average annual return of 2%, more or less. The resulting total after 37 years would then be about $194,500. That's only a $61,300 gain.

3. Pay off your debt as soon as possible

The longer you carry debt, the more it will cost you -- it's that simple. Six out of 10 middle-aged and older Americans have figured out that it's best to pay off most debts quickly. So if you're sitting on non-mortgage debt, come up with a plan to get rid of it. Generally, the best course is to knock out your costliest debt (that with the highest interest rate) first, and then move on to lower-interest debts like personal loans or student loans.

The money you'll avoid spending on interest can be redirected into your retirement savings, and given the previous point that setting money aside for that from a young age is critical, that alone should help motivate you to redouble your efforts to get out of debt. You'll probably need to cut back on spending, or perhaps get a second job temporarily. But it can be a worthwhile sacrifice if it means being debt-free sooner.

4. Always have an emergency fund

Some money we save is for the long term. Some is not. You never know when a large unplanned expense might wreak havoc on your finances, which is why 57% of those surveyed advocate having an emergency fund. Without one, you're likely to start racking up high-interest debt when problems arise -- which, as we just covered, is a bad idea.

That's why you should always aim to have enough money on hand to cover three to six months of essential living expenses. But don't invest that money. Keep it in the bank so it's accessible at all times, and so your principal is protected. The aforementioned advice on investing applies to long-term savings only; it doesn't apply to the cash you need on hand for a rainy day. That said, some banks -- particularly online-only institutions -- offer significantly better interest rates on savings accounts. That may only amount to 1.5% to 2% or so, but that beats the near-zero percent you'll get from an average account. It can be worth your time to hunt up the best deal you can find for a place to stash your emergency fund.

When we can, it's good to learn from our elders. In this case, avoiding some of the mistakes they may have made can help put you on a path to a secure retirement -- one you get to enjoy to the fullest.