Meta Platforms (META -0.52%) and Alphabet (GOOG 0.74%) (GOOGL 0.55%) recently wrapped up 2022 by reporting earnings for the fourth quarter and fiscal years. Although these internet companies are different -- one is a social media giant, and the other is known for its search engine -- both companies depend heavily on advertising dollars to make money.

Wall Street was seemingly more excited about Meta's results, given the stock's 27% run over the past five days, compared to just 5% for Alphabet. But did the market get it right? Which stock is the better buy right now and moving forward? I'll show you the important clues to help you make the right decision.

Fourth-quarter results signal broad advertising weakness

Both companies have seen revenue growth decline, and the fourth quarter wasn't any different. Advertising is sensitive to the economy; brands will spend less on ads if they don't think consumers will buy anything. Rapidly rising interest rates have drummed up recession fears throughout this year, so that shouldn't be a surprise.

Meta's revenue declined 4% year over year despite a 23% jump in ad impressions because the average price per ad decreased by 22%. However, Meta did report that its family of apps (Facebook, Instagram, and WhatsApp) grew daily active people by 5% to 2.96 billion. This will help revenue when advertising spending improves, and Meta generates more revenue than Alphabet per impression.

META Revenue (Quarterly YoY Growth) Chart

META Revenue (Quarterly YoY Growth) data by YCharts

It's a similar story for Alphabet; revenue grew just 1% year over year, though growth would have been 7% on a constant-currency basis. Investors shouldn't worry much about Alphabet's positioning; Google and YouTube remain the runaway leaders in global traffic, as recently as December, according to Semrush. Like Meta, Alphabet's ads will perform much better as the ad environment improves. For comparisons between these companies, let's call this a draw since both companies' core assets (their massive audiences) remain intact in the face of industrywide weakness.

Positioning for the future

Big tech companies are officially gunning for dominance in artificial intelligence, though each is going about it differently. On the heels of Microsoft's multibillion-dollar investment in OpenAI, Alphabet has a special event scheduled for Feb. 8 to unveil its vision for AI. Meta has invested heavily in its Reality Labs segment, which encompasses its metaverse efforts, AI research, and other non-app projects.

Getting an edge on the competition could come down to which has the deeper pockets. Meta's ad struggles and heavy investments into Reality Labs have sapped free cash flow in recent quarters, although the company is cutting costs to help rectify that. Management announced a new $40 billion share repurchase program on top of the roughly $11 billion it has left from its previous program. That's great for shareholders, but it could eventually limit Meta's resources to invest for growth over time if cash flow falters.

META Free Cash Flow Chart

META Free Cash Flow data by YCharts

Alphabet loves buying back shares, too; the company has spent more than twice as much as Meta over the past year on share repurchases. However, Alphabet can easily afford it. The company holds $113 billion in cash and equivalents on the books and has generated nearly three times as much cash flow as Meta over the past year. It's hard not to like Alphabet's balance sheet over Meta's.

Investors will know more about Alphabet's AI projects after the company's event. Alphabet must execute any announced plans successfully, but Meta sets a low bar. Early returns on Reality Labs have been disappointing; the segment posted $13.7 billion in operating losses in 2022.

Which is the better buy?

Valuation is an important context to any comparison, and you'll see below that both stocks trade at roughly the same forward price-to-earnings ratio (P/E). Meta has steadily carried a lower valuation until its recent run. With both stocks valued similarly, it boils down to which company's fundamentals you favor moving forward.

Analysts estimate that Meta's earnings per share (EPS) will grow by roughly 10% annually over the next three to five years and estimate Alphabet's growth will average 12%. Those are very similar numbers, but Alphabet seemingly has a slightly more optimistic growth outlook.

META PE Ratio (Forward) Chart

META PE Ratio (Forward) data by YCharts

Both companies are at the top in their respective businesses, and the similar valuation and growth outlook makes them a toss-up if you buy one for short-term potential. Over the long term, some minor details decide a winner.

Alphabet's deeper pockets give it more room for error, especially considering Meta's massive losses thus far in Reality Labs. Alphabet's enormous cash pile can fund aggressive share repurchases and still fund investments for long-term growth. The Google parent seems like a slightly better long-term investment unless it disappoints investors down the road, or Meta can get more from Reality Labs. These minor differences separate two high-quality companies, with Alphabet having the edge.