Google (NASDAQ: GOOG) and Facebook (NASDAQ: FB) are two of the top-performing stocks of the last decade. The internet giants have beaten the S&P 500 over the last five and 10 years as they've come to dominate online advertising and other markets. And while both businesses have their nuances, Facebook and Google are quite similar, seeing as they both make money by targeting users with advertisements. But which stock is a better buy over the next five years and beyond? Let's take a look. Image source: Getty Images. Google Google's core business, called Google Services, has grown substantially over the last few years, even when dealing with the law of large numbers and the COVID-19 recession. These assets include but are not limited to: Google search, YouTube, Google Adsense (website advertising), and Google Maps. Last year, Google Services generated $54.6 billion in operating income, up from $43.1 billion two years ago. However, Google's other subsidiaries, Other Bets and Google Cloud, lost $4.5 billion and $5.6 billion, respectively, last year. This brought its overall operating profit to $41.2 billion in 2020, significantly less than what its core business generated. On the surface, these billions in losses from Google's subsidiaries look bad. But it gets better once you take a deeper look. The cloud business, which competes with Amazon's (NASDAQ: AMZN) AWS and Microsoft (NASDAQ: MSFT) Azure, is durable and has high margins at scale. It just takes a lot of upfront spending to get the data centers running. Other Bets is a bit more speculative; however, it houses Waymo, the start-up that is leading the self-driving industry. If Waymo or another one of these moonshots becomes a giant company someday, it will make up for the years of operating losses. At a market cap of $1.45 trillion, Google trades at a price-to-operating-income ratio (P/OI) of 35. If you ex-out Google's net cash and just look at its core business, that P/OI comes down to 24.6. This is a very reasonable valuation for a company of Google's caliber. Facebook Facebook has four core businesses, which comprise of Facebook itself (which we'll call Big Blue), Instagram, WhatsApp, and Messenger. In 2020, Facebook generated $32.6 billion in operating income, up 36% from 2019. Big Blue had 1.84 billion daily active users (DAUs) worldwide at the end of 2020, making it 70% of Facebook's overall DAUs, which sit at 2.6 billion. With these numbers in mind, one can assume that the majority of Facebook's profits still come from Big Blue. However, it looks like the majority of Facebook's growth now comes from Instagram. According to Recode, 65% of Facebook's overall sales growth now comes from Instagram, and it now makes up 30% of its overall revenue. WhatsApp doesn't generate significant revenue right now, but it is launching a payments network similar to Venmo or Cash App in India, where WhatsApp had an estimated 340 million users in 2019. With all these estimates, it should be noted that Facebook does not segment out its subsidiaries very often, so much of this data is from third-party sources and is not guaranteed to be 100% accurate. Facebook, like Google, has a large moonshot/R&D department. Its biggest initiatives are virtual and augmented reality (VR/AR), with nearly 10K employees reportedly working on this division alone. While the fruits from these investments may not come for many years, it is nice to see Facebook making these large bets on the future. Right now, Facebook has a market cap of $900 billion, giving it a P/OI of 27.6. Like Google, this is a very reasonable valuation when you consider Facebook's track record of growth. Verdict Both Facebook and Google seem like durable businesses trading at sensible valuations, but if forced to choose, I think Google is a better buy over the long term. Why? Because Google's assets are at less risk of disruption. Search, Google Maps, and YouTube feel like permanent assets of the internet, while Big Blue and Instagram are at risk from competitors like Snap (NYSE: SNAP), Tik Tok, and Roblox (NYSE: RBLX). For example, according to a survey from Piper Sandler, only 24% of teens chose Instagram as their favorite social platform right now, down 7% from a year ago. And while Facebook's VR/AR incubator looks promising, it will likely face stiff competition from Apple (NASDAQ: AAPL), the king of consumer hardware products. When you consider all these factors, it looks like Google, not Facebook, is the better buy for long-term investors. 10 stocks we like better than FacebookWhen investing geniuses David and Tom Gardner have a stock tip, it can pay to listen. After all, the newsletter they have run for over a decade, Motley Fool Stock Advisor, has tripled the market.* David and Tom just revealed what they believe are the ten best stocks for investors to buy right now... and Facebook wasn't one of them! That's right -- they think these 10 stocks are even better buys. See the 10 stocks *Stock Advisor returns as of February 24, 2021 John Mackey, CEO of Whole Foods Market, an Amazon subsidiary, is a member of The Motley Fool's board of directors. Suzanne Frey, an executive at Alphabet, is a member of The Motley Fool's board of directors. Teresa Kersten, an employee of LinkedIn, a Microsoft subsidiary, is a member of The Motley Fool's board of directors. Randi Zuckerberg, a former director of market development and spokeswoman for Facebook and sister to its CEO, Mark Zuckerberg, is a member of The Motley Fool's board of directors. Brett Schafer has no position in any of the stocks mentioned. The Motley Fool owns shares of and recommends Alphabet (A shares), Alphabet (C shares), Amazon, Apple, Facebook, and Microsoft. The Motley Fool recommends the following options: long January 2022 $1920.0 calls on Amazon, long March 2023 $120.0 calls on Apple, short January 2022 $1940.0 calls on Amazon, and short March 2023 $130.0 calls on Apple. The Motley Fool has a disclosure policy.Source