Investing in tech companies can be risky, partly because change in technology tends to be revolutionary, not evolutionary. That makes it even more important to pick your tech stocks wisely. Finding companies that demonstrate a continued ability to innovate and maintain leadership in their respective markets is a good start. It also helps if you can find stocks that are likely to be around for at least a decade.

Apple (AAPL 0.73%), Alphabet (GOOG -4.94%) (GOOGL -4.71%), and Facebook (META -15.12%) fit that description. What's more, each of these companies is profitable and generates substantial amounts of cash flow every quarter. 

A Facebook employee wearing a Facebook shirt while coding on a computer.

Image source: Facebook.

Apple 

One tech stock you can add to your shopping cart is Apple. The company continues to innovate and demonstrate it's a heavy hitter in the tech space. Spurred by the recent launch of a new generation of iPhones, sales of the device increased by 17.2% in the most recent quarter compared to the same time last year.

Supplementing its growth in hardware is Apple's services segment, which includes AppleCare, the App Store, and Apple TV+ and comes with a gross profit margin that nearly doubles that of its hardware. In the first quarter of 2021, the services segment made up 14% of overall sales while increasing its revenue by 24% from the prior year. The segment is growing faster than the overall company, which means higher-margin services will become a larger part of Apple over time.

Through a combination of share repurchases and increasing profits, earnings per share grew at a compound annual rate of 19.7% over the last decade. And the company shows little reason to expect anything less than excellent returns over the next 10 years.

Facebook 

The social media company is known for connecting people through its popular apps, but it's also known for connecting shareholders to profits. Over the last 10 years, Facebook has increased earnings per share at a compound annual rate of 50.4%.

And despite its massive size, it is still able to add new users to its family of apps. Monthly active users among all of its apps (Facebook, Instagram, and WhatsApp) increased by over 300 million in 2020 to reach 3.3 billion. That's an increase almost the size of the entire U.S. population.

Facebook is trading at a substantial discount to its peers Pinterest, Twitter, and Snap when measured by its forward price-to-earnings ratio (see the chart below). That means you can buy this tech stock with excellent prospects at a bargain price.

A chart comparing Facebook to other social media companies on an important financial metric.

Data source: YCharts.

Alphabet 

Alphabet is another tech stock that could deliver robust returns over the next decade. One estimate suggests its Google search engine has a global market share upward of 91.9%, leadership that will generate healthy profits for several years.

Its Google Cloud segment is still a relatively small part of the overall company but growing rapidly. In 2019 and 2020, revenue in the segment grew by 53% and 46%, respectively. Google Cloud is not profitable just yet, but it might only be a matter of time with that kind of growth.

Over the last decade, Alphabet increased revenue at a compound annual rate of 20% and simultaneously sustained an operating profit margin of at least 20%. With such a dominating position in its core business, investors can expect similar performance in the future.