It's hard to imagine, but just over twenty years ago neither Facebook (META 0.18%) nor Google -- now Alphabet (GOOG 9.93%) (GOOGL 10.22%) -- existed.  Combined, these behemoths are worth over $1.2 trillion. That's more than the GDP of all but 14 countries in the world -- a truly staggering figure.

In less than a generation, they have gone from nothing to being two of the most important companies in the world. Much of the information we get and the virtual interactions we have with friends now flow through Google and Facebook, respectively.

People sitting on a couch, using their laptops and smartphones.

Image source: Getty Images

So it should be no surprise that both have been great stocks to hold over the past few years. The real question on investors' minds, however, is: which is the better stock to buy now?

There's no (small f) fool-proof way to answer that question. But there are three different lenses through which we can evaluate these companies, and those should go a long way in helping us to determine which we are more comfortable with.

Sustainable competitive advantages

If you're a long-term, buy-to-hold investor, there's nothing more important than investigating a company's sustainable competitive advantages. Often referred to as a moat, this represents that special something that separates one company from the hoards of competitors.

A number of different factors contribute to Google's moat. First, the company's brand is very valuable -- the word itself has become a verb ("Just google it!"). Forbes estimates that the brand is worth just over $100 billion, good enough for second-place globally. 

Since Google's primary business is selling advertising space, Google's enormous hoard of data is its most valuable asset. With over seven products that have a billion-plus users -- Search, Maps, GMail, Play Store, Chrome, You Tube, and Android -- the company has a very low fixed cost to produce this data for advertisers.

Not to be outdone, Facebook also has a very wide moat. The brand is worth $74 billion -- good for fourth in the world -- and it also has similar data-collecting capabilities thanks to all of the information shared via Facebook, Instagram, and WhatsApp. 

Truth be told, these are two of the widest moat businesses in tech right now. But if forced to choose, I would go with Facebook. It has the added benefit of the network effect: as one user joins the platform, it further incentivizes other users to join, creating a virtuous cycle for the company -- one that is still going strong 13 years after the company was founded.

Winner = Facebook

Financial fortitude

If you're considering buying shares in either of these companies, you realize that dividends aren't on the table. So you'd probably want to see each company either reinvesting extra cash into growth opportunities or returning it to shareholders through repurchasing programs.

But there's something to be said for holding a big pile of cash on the sidelines. Every company, at one point or another, is going to face difficult economic times. Those that have lots of cash -- and not too much debt -- can actually emerge stronger by buying shares back on the cheap, outspending rivals to gain market share, or acquiring the competition.

Here's how these two stack up in terms of financial fortitude.

Company

Cash

Debt

Net Income

Free Cash Flow

Facebook

$38 billion

$0

$16 billion

$17 billion

Alphabet

$107 billion

$4 billion

$21 billion

$24 billion

Data source: Yahoo! Finance, SEC filings. Net income and free cash flow presented on trailing twelve month basis.

Both companies have very strong net income and free cash flow. And debt isn't an issue, either. While this is nit-picky, I'll give the advantage to Alphabet thanks to the company's larger war chest.

Winner = Alphabet

Valuation

Finally, we have valuation. This isn't an exact science: there's no one number that can tell you how cheap or expensive a stock really is. The best we can do is reference a number of different data points to help us get a more holistic picture.

Company

P/E

P/FCF

PEG Ratio

Facebook

34

30

1.2

Alphabet

33

30

1.5

Data source: Yahoo! Finance, E*Trade. P/E is presented on non-GAAP basis if applicable.

On this facet, I truly don't think there's a meaningful difference. Both stocks are expensive on a historical basis, but are probably fairly valued given the overall market's eight-year bull run.

Winner = Tie

My winner is...

So there you have it. These two are extremely closely matched and both very strong companies. Whenever there's a tie, I always give the nod to the company with the stronger moat. In this case, that means Facebook.

But don't be misled, I don't think you can really go wrong owning either of these stocks. And I speak with conviction: they are my second and third-largest holdings, accounting for 28% of my real-life holdings. I think you'd be wise to make time to investigate owning both!