There is no hard guarantee you will become rich investing in the stock market, but your best chance at doing so is the old-fashioned way: Buy great companies, and hold them for decades to let compounded interest do its thing. The first challenge is, of course, identifying those great companies. These aren't companies that just have a good run in them for a few years, these are the companies that have the kind of competitive advantages that last for decades.

We asked three of our contributors to each highlight a stock they see as one an investor can hang on to for the next 30 years. Here's a quick run-down on their selections: IBM (IBM -0.89%), Moody's (MCO -0.22%), and Waste Management (WM -0.52%).

Researching long term investments

Image source: Getty Images.

It starts with a foundation

Tim Brugger (IBM): Big Blue may not be the first name that comes to mind when considering a long-term portfolio. But like any building, it all begins with a solid foundation, and in that regard, IBM fits the bill perfectly.

That IBM stock is up 29% in the past year is good news; the reason its shares have finally caught the attention of investors is even better news. CEO Ginni Rometty laid out a plan a couple of years ago coined "strategic imperatives." These represented an entirely new direction for IBM, setting legacy businesses such as hardware aside and focusing on up-and-coming markets including the cloud, Internet of Things (IoT), data security, analytics, and mobile solutions. And it's paying off.

The objective was to grow strategic imperative sales to 40% of revenue by 2018. IBM ended its 2016 fiscal year with $32.8 billion in strategic imperatives revenue, equal to 41% of its $79.9 billion in total sales. IBM's cognitive computing wonder, Watson, is the leading artificial intelligence (AI) driven analytics solution in the market, and with the proliferation of IoT and cloud-hosted data centers skyrocketing, data is where the opportunities lie. One study suggests analytics will generate $187 billion in revenue in two years, and IBM is leading the charge.

IBM's cloud revenue of $13.7 billion -- good for a 35% jump year over year -- puts it at the head of the class in yet another market expected to soar in the coming years. Toss in its 3.1% dividend yield, and IBM stock is the ideal foundation to build upon.

A toll road on corporate debt

Jordan Wathen (Moody's): Tax schemes will change, and so will interest rates, but corporate debt is forever. I like Moody's as a way to profit from the permanence of corporate debt issuance, and the necessity of ratings companies.

Moody's makes money by charging a small fee to ascribe a letter-grade rating to bonds issued by public borrowers. Companies that issue bonds have every reason to pay Moody's its due since getting a bond rated can save the issuer 0.30 percentage points per year in interest costs. In effect, bond issuers pay $1 to Moody's to save $3 (or more) in interest expense every single year.

Although they may have gotten a bad reputation from the financial crisis, bond ratings are an integral part of the financial system, and I believe they always will be. The truth is that while ratings agencies have made mistakes on individual bonds, ratings do what they are supposed to. A lower-rated bond is much more likely to default than a higher-rated bond. For this reason, bond ratings will retain their utility.

Given that the ratings business is effectively a duopoly in the United States (S&P Global (SPGI 0.31%) and Moody's control greater than 80% of the industry), the ratings agencies will be able to extract their fair share for a very long time to come.

Doing the dirty work

Tyler Crowe (Waste Management): For an investment to last multiple decades, it needs to be something that can't be interrupted rather easily. In many instances, the things that tend to not get disrupted much are the things no one actually wants to do. Say, treat and handle solid waste. That's the beauty of waste handler Waste Management: It's business model hasn't changed in years, and chances are, it isn't going to be changing any time soon. That's fine in my book, because that business model churns out high rates of return and gobs of free cash flow to be used on share repurchases and dividend increases.

WM Return on Equity (TTM) Chart

WM Return on Equity (TTM) data by YCharts.

Aside from the inherent advantages Waste Management has in its industry -- a capital-intense business, a complex regulatory environment, and geographic advantages -- what really makes the company stand out is its fixation on lowering costs and using innovative ways to lower those costs. The most notable one has been converting its fleet of waste collection vehicles to run on natural gas and, in certain cases, capturing methane emissions from its own landfills to run its own trucks.

It goes further than that, though. One of its new initiatives is on service delivery optimization. Basically, Waste Management is looking to optimize its collection routes and maintenance schedules to reduce fuel consumption and overall maintenance costs. It's continuous and incremental improvements like this that have enabled Waste Management to maintain its lead in the industry in terms of market share and returns on invested capital, something all investors can appreciate.

You won't get rich tomorrow buying Waste Management shares today. But if you want a stock that will continue to churn out fantastic rates of returns for decades, then Waste Management needs to be on your radar.