They are unquestionably two of the most powerful companies that the world has ever known. One is the maker of the iPhone, the original smartphone -- the device that fundamentally changed the way we interact with each other. The other has taken all of the world's information and put it at our fingertips.

I'm talking, of course, about Apple (AAPL -0.13%) and Alphabet (GOOG 9.23%) (GOOGL 9.45%), often known by the name of its largest subsidiary: Google. Investors in both companies have experienced enormous gains over the past 15 years. But which is the better stock to buy today?

Businessman trying to decide between two paths

Image source: Getty Images.

I won't pretend I can tell you the answer to this question with 100% certainty. I can't. And neither can anyone else.

But we can evaluate these two on three different continua and see which comes out ahead.

Financial fortitude

I'm a long-term investor. When I buy a stock, I'm thinking about where it could be when I retire...30 years from now. So I've accepted the fact that I'll endure more than my fair share of market swoons and economic recessions.

What I want to know is whether the companies I own can actually benefit from such tough times. How can that be? Well, companies flush with cash can repurchase their own shares when they're on sale, or acquire rivals at a discount -- or simply offer up deals the competition can't match, driving them into bankruptcy. Whatever path such companies take, they emerge from a downturn stronger because of it.

Keep in mind that Alphabet and Apple are roughly the same size, in terms of market capitalization:

Company Cash Debt Free Cash Flow
Apple $245 billion $93 billion $62 billion
Alphabet $119 billion $4 billion $23 billion

Data source: Yahoo! Finance. Cash includes long- and short-term investments. Free cash flow presented on trailing-12-month basis.

Technically speaking, Apple comes out ahead. It has a larger net cash position (cash minus debt), and stronger free cash flow. At the same time, the entire point of this exercise is to gauge whether either company would fare better than the other in a downturn.

Because these are both such strong balance sheets, with such strong free cash flow, I'm willing to call this a tie. Both companies could benefit enormously from an economic downturn. I do actually believe Alphabet would fare better, as Apple's revenue relies on highly discretionary and expensive purchases of iPhones (more on that below).

Winner = Tie.

Valuation

Next we have valuation, which is a fancy way of saying we want to figure out which stock is "cheaper" than the other. And for beginning investors, a stock's price is not an accurate reflection of whether it's cheap.

Rather, measuring a stock's price relative to other metrics -- like its earnings (P/E), free cash flow (P/FCF), or potential for growth (PEG ratio) -- gives us a better picture of what we're paying for. Here's how these two stack up in terms of their price tags:

Company P/E P/FCF PEG Ratio Dividend Yield FCF Payout Ratio
Apple 14 13 1.0 1.8% 23%
Alphabet 28 34 1.6 N/A N/A

Data sources: Yahoo! Finance, E*Trade. P/E = price to earnings, P/FCF = price to free cash flow, PEG = price/earnings to growth. P/E presented using non-GAAP (generally accepted accounting principles) figures when applicable. N/A = not applicable, as no dividend is offered.

Here we have a much clearer winner. Apple is not only cheaper on the basis of earnings and free cash flow, but also cheaper relative to its growth prospects. And as a cherry on top, it even offers a dividend. Because less than one-quarter of free cash flow is used on the dividend, it both is very safe and has lots of room for growth.

Winner = Apple.

Sustainable competitive advantages

Finally, we have far and away the most important -- and difficult -- thing to measure: sustainable competitive advantages -- or "moats," as they're referred to in investing circles. Moats are the forces that keep businesses on top of the world for decades, while the competition tries futilely to grab business away.

In general, there are four different moats businesses can have:

  1. Low-cost production: When one business offers up something of equal or better quality for a consistently lower price, it will be the long-term winner.
  2. High switching costs: Some companies lock customers in by making it painfully difficult to switch away to another provider.
  3. Network effects: With each additional user of a service (or product), that service (or product) becomes incrementally more valuable.
  4. Intangible assets: This includes things like brand loyalty, patents, and regulatory protection.

Let's start with Apple. The company's largest moat comes via its brand power. While iPhones and iMacs may be incrementally better than the competition, consumers are willing to pay a much higher premium than might be warranted to have that silver Apple logo on their device. Forbes backs up that theory, assigning Apple the highest brand value in the world -- with a worth estimated at $183 billion.

But that's not all; Apple has also been keeping customers around via high switching costs. Think about it: If you have an iPhone, an iMac or MacBook, and/or an iPad, and you have them all synced with all of your documents uploaded to the iCloud -- it would be a royal pain in the rear to switch.

While buying an Android phone, for example, may make sense in isolation, the equation changes when you consider all you'd be giving up to do so. This helps explain why many investors are so excited by Apple's booming services revenue -- it's emblematic of a growing moat of high switching costs.

Alphabet, on the other hand, has its own stable of moats. While not quite as strong as Apple's, the company also has a very high brand value. Forbes estimates that Google is the second most valuable brand in the world, worth $132 billion.

The company also benefits from the same high switching costs as Apple -- though, once again, at a smaller scale. If all the pictures you take on your Android phone, and all the documents from your Chromebook, are automatically uploaded to your Google Drive -- and you have these devices synced -- you'd be less likely to buy an Apple device.

But Google's real coup comes in the form of low-cost production. "Production of what?" you might ask. Data -- huge, enormous, monstrous gobs of data. Google has eight different services with over one billion users each: Search, Maps, GMail, Google Play Store, Google Drive, Chrome, Android, and YouTube.

Most of these products are free to use, and that's fine with Google. The company can collect your data, turn around, and sell it to advertisers for the type of laser-focused ads no one else (other than Facebook) could possibly offer. At the end of the day, it's important to remember that Google -- and thus, Alphabet -- is essentially an advertising company. Over 85% of Alphabet's revenue comes from advertising.

Believe it or not, there's one more important moat worth mentioning: YouTube, the world's second-most popular site behind Google itself, benefits from the network effect. People who make videos know that others will see them on YouTube. That draws even more users -- and therefore more producers. It's a virtuous cycle.

While Apple's moat has proven much stronger than I once thought, I believe that Alphabet's is superior over the long run.

Winner = Alphabet.

Check out the latest Alphabet earnings call transcript.

My winner is...

So there you have it. When these two titans go head-to-head, it's a tie. Whenever that's the case, I always give the edge to the company with the widest moat -- in this case, Alphabet. My own personal portfolio backs this conviction: Alphabet makes up over 10% of my family's real-life holdings.

While I have great respect for Apple and for what Steve Jobs and Tim Cook and their teams have accomplished, I think it's much better to invest in services (Alphabet) over hardware (Apple). While an investment in either has proven to be a good move, I believe Alphabet is a better long-term play.