Generally speaking, retail can be a difficult industry to operate in. There's a lot of competition, margins are tight, and the barriers to entry are low. However, there are outliers -- companies that successfully built competitive advantages over time. And those moats make them more compelling as potential investment ideas. 

Tractor Supply Company (TSCO -0.00%) and Lowe's (LOW 1.24%) are two companies that have stood the test of time and have been market-beating investments for shareholders. Both would be fine choices for investors to add to their portfolios today. But which is the better buy?

Tractor Supply Company

Depending on where you live, you may not have ever seen a Tractor Supply store. The company is deliberate when selecting store locations, picking more rural areas rather than urban settings.

It aims to serve recreational farmers, ranchers, and anyone looking to live what they call the "rural lifestyle." The company might sell a tractor to a farmer, but also might sell chicken feed to a young couple raising chickens in their backyard.

The historical results of this business strategy have been impressive, with Tractor Supply's stock beating the S&P 500's returns over the last 3-year, 5-year, and 10-year time frames. However, investors need to make decisions based on what is to come, not what has already happened. The good news is there's reason to believe this market-beating performance can continue.

Over the last five years, Tractor Supply has grown its revenue, earnings per share, and free cash flow at an impressive rate.

TSCO Revenue (TTM) Chart

TSCO Revenue (TTM) data by YCharts.

Over that same period, the company repurchased its own stock at an impressive rate, reducing shares outstanding by 11%. Shareholders can't ask for much more than a company that grows its top and bottom lines while simultaneously reducing its share count.

An important part of Tractor Supply's growth story is its expanding store count. As of the end of the second quarter, Tractor Supply had approximately 2,300 stores, including the 17 it opened during the quarter. Management has raised its long-term target to 3,000 stores, up from 2,800 previously. This shows that Tractor Supply is still in growth mode, and has not come near to saturating its market. It also shows the company is able to generate cash and profits while spending money to expand its business, which is always a good sign for investors.

Lowe's

As half of a near-duopoly in home improvement with rival Home Depot, Lowe's has become a household name. For both homeowners and professional contractors, Lowe's serves as a one-stop shop for all things related to maintaining and improving the inside and outside of homes. 

While Lowe's stock lagged the market over the past three years, it's been a market-beater over longer periods. Additionally, its 5-year results for revenue, earnings per share, and free cash flow have been impressive.

LOW Revenue (TTM) Chart

LOW Revenue (TTM) data by YCharts.

It's worth pointing out that the biggest difference between these two companies' results is how much stronger Lowe's earnings-per-share growth has been than Tractor Supply's, considering their similar revenue growth rates. This was due to the significantly faster rate at which Lowe's has repurchased its stock, reducing shares outstanding by nearly 30%.

As of the end of Q2, Lowe's had approximately 1,742 stores, down by more than 200 compared to a year prior. However, in what could be a threat to Tractor Supply, in 300 of its stores in rural locations, Lowe's is expanding its selection of farm and ranch offerings such as pet and livestock supplies, fencing, and utility vehicles.

It remains to be seen how this plays out in their respective financial results, but it suggests Lowe's sees an opportunity to capitalize on its name and reach to encroach on Tractor Supply's core markets.

Which is the better buy?

These two companies have delivered similar results and returns, which makes choosing between them difficult. Tractor Supply has cornered a niche market and seems to have established itself as the leader in the rural lifestyle space. That said, Lowe's is one of two major players in the home improvement space, which caters to a broader audience.

Turning to valuation metrics doesn't really offer much to distinguish between the companies either. Both have price-to-earnings ratios of 23, and both are currently trading slightly below their 10-year average ratios. 

Considering its store count growth projections, I might be more inclined to buy Tractor Supply. The fact that management sees that much potential for new stores, combined with the company's track record of financial success, suggests there might be more upside in Tractor Supply.