This is one of the most interesting "Better Buy" articles I'll ever write. Amazon.com (AMZN -2.56%) is the King of e-commerce, and it occupies (a perhaps unwise) 20% of my real-life holdings. Shopify (SHOP -1.66%) is capitalizing on the exact same trend, but with a different twist: It offers a platform to help small and medium-sized businesses build an e-commerce presence.

Shopify is one of my favorite "up-and-coming" holdings, and it also occupies a significant portion of my portfolio -- currently 3.5% of my holdings. It has also won over an important supporter in Amazon, as the latter endorsed the former as the platform of choice and integrated it into the Amazon experience.

A person making a purchase on a tablet with a credit card.

Image source: Getty Images.

So, which is the better stock to buy today, the next ruler of the e-commerce world, or the newbie that's making a periphery play on the same trend? There's no way to answer that question with 100% certainty -- and I clearly like the prospects at both organizations -- but there are three different lenses through which we can analyze the question.

Sustainable competitive advantages

For long-term, buy-to-hold investors -- which we hope you aspire to be -- there's nothing more important than analyzing a company's sustainable competitive advantages -- often referred to as a "moat." In its simplest sense, this is the thing that keeps customers coming back again and again, while keeping the competition at bay for decades.

Amazon has a number of advantages, but there are two distinct forces in its favor. The first is its scale. The company has an estimated 105 multimillion-dollar fulfillment centers domestically and another 97 internationally . This network allows the company to deliver products with a speed that's unmatched. It would be prohibitively expensive for competitor to try and match this scale -- incurring years of losses before ever seeing profitability from the move.

The second advantage, which plays off of the first, is the company's network effect. As Amazon has become the e-commerce store, more and more third-party merchants are joining the network to gain access to the growing list of clients on Amazon Prime. Over the past two years, shipping revenue -- which is fed primarily through third-party vendors using Fulfillment by Amazon -- has doubled . As more vendors go on Amazon, it draw even more customers -- a virtuous cycle.

Not to be outdone, Shopify also has a very strong moat around it in the form of high switching costs. If the fact that Amazon decided to abandon its Webstore efforts in favor of Shopify wasn't enough, just consider what migrating an entire e-commerce platform would involve: downtime for your business, massive headaches, and hiring expensive specialists to try and get it done. No one wants that, and it forms a strong barrier around the business.

Normally, I would give the nod here to Amazon -- as it has more than one moat and it is a giant. But I'm going to call this a draw. Shopify's greatest threat comes from big players designing their own platforms. With Amazon ceding to Shopify, I believe this one is as good as a tie.

Winner = Tie 

Financial fortitude

Both of these companies are still in hyper-growth mode. That means money isn't being returned to shareholders in the form of dividends, and profitability can be meager -- if existent at all. That's a good long-term move to grab market share.

At the same time, though, it's important for these companies to have cash to fall back on. Every organization will experience difficult economic times; the ones that enter such periods with cash on hand have options. They can buy back stock, purchase rivals, or -- most importantly -- spend lesser rivals into oblivion. Those with lots of debt are in the opposite boat, forced to cede long-term market share for staying afloat.

Here's how these two stack up in terms of financial fortitude, keeping in mind that Amazon is valued at over 50 times the size of Shopify.

Company

Cash

Debt

Net Income

Free Cash Flow

Amazon

$22 billion

$8 billion

$2.6 billion

$9.5 billion

Shopify

$396 million

$0

($39 million)

($6.4 million)

Data source: SEC filings, Yahoo! Finance. Cash includes long and short-term investments. Net income and free cash flow presented on trailing-12-month basis. 

Both companies have very healthy balance sheets. Even though I've actually written about how I don't want to see Shopify be profitable for a while, I have to give Amazon the nod, here, as the company is producing positive and significant free cash flow.

Winner = Amazon

Valuation

Normally, this is a pretty straightforward section. We look at the various valuation metrics between two companies and compare them. But Amazon and Shopify are very difficult to value -- especially since Shopify is not profitable, nor does it have positive free cash flow.

Amazon, on the other hand, trades for around 50 times free cash flow, which gives us a fair estimate for what we're paying for when we buy shares. Absent any type of valuation marker with Shopify, I'm going to give Amazon the (very slight) nod here as well.

Winner = Amazon

And my winner is...

So, there you have it: Amazon comes out ahead based -- almost entirely -- on its positive free cash flow. But don't be mistaken, I think both of these companies are extremely promising and have very bright futures. I think every investor should at least consider buying shares of both for their own portfolios, especially if they have a decades-long time horizon.