Tech stocks suffered a rough 2022 after seeing strong gains last year. But some tech companies are good investments whether the stock market is in bear or bull territory. Among these are Apple (AAPL 0.64%) and Microsoft (MSFT 1.65%). They were once rivals during the rise of personal computers, but now are following different avenues to success.

The price appreciation of these stocks, even with this-year's downturn, illustrates why Apple and Microsoft are excellent investments. While both hit 52-week lows this year during 2022's tech sell-off, their stocks remain well above prices before the coronavirus pandemic struck in 2020.

MSFT Chart

Data by YCharts.

In an ideal world, investors can own shares of both companies. But if you had to choose between these two tech heavyweights, a look at each reveals that one emerges as the better long-term investment.

Why Apple is an appealing investment

One reason to invest in Apple is its impressive sales growth. Revenue rose an astounding 33% year over year in the company's fiscal 2021 and 6% in 2020, despite the onset of the pandemic forcing store closures amid widespread lockdowns.

This trend is continuing in 2022. In Apple's fiscal third quarter ended June 25, revenue reached $83 billion, a record for Q3 sales. Through nine months of its fiscal 2022, Apple hit net sales of $304.2 billion, compared to $282.5 billion last year, despite challenging macroeconomic headwinds such as inflation and supply chain constraints.

Apple's revenue growth is due to several reasons, with its hallmark hardware products leading the way. The popularity of Apple products reached record levels in Q3 as the company hit an all-time high in the number of adopted devices.

Among Apple's hardware products, the iPhone stands out. iPhone sales accounted for nearly half of Apple's Q3 revenue. But the company is also growing income from its digital offerings, such as its Apple-TV streaming service. These non-hardware products, grouped under the company's services segment, reached record Q3 revenue of $19.6 billion, up from last year's $17.5 billion.

Thanks in part to the company's streak of stock buybacks, Apple appeals to investors such as Warren Buffett, whose Berkshire Hathaway owns nearly 895 million shares of Apple stock. Apple has repurchased shares of its stock for years, including 143 million shares in Q3, up from Q2's 137 million shares repurchased.

The case for Microsoft

Like Apple, Microsoft is riding a wave of success, despite the pandemic and macroeconomic headwinds such as a strong U.S. dollar. The company wrapped up fiscal year 2022, ended June 30, with $198.3 billion in revenue, up 18% over 2021. In fact, Microsoft's year-over-year revenue growth rate has risen in recent years.

Fiscal Year Revenue YOY Growth
2022 $198.3 billion 18%
2021 $168.1 billion 18%
2020 $143.0 billion 14%
2019 $125.8 billion 14%

Data source: Microsoft. YOY = year-over-year.

Microsoft's revenue growth is due to its shift to cloud computing under Satya Nadella, who became CEO in 2014. The company's Microsoft Cloud revenue increased 32% year over year in fiscal 2022.

Microsoft offers an array of cloud-related solutions, from data storage to cloud-based software applications, and has successfully transitioned its ubiquitous Office products to a software-as-a-service (SaaS) subscription model that generates a recurring revenue stream. In fiscal 2022, Office SaaS subscriptions grew 14% among its commercial customers and 15% with consumers.

Microsoft also boasts a strong balance sheet. The company exited its fiscal fourth quarter, ended June 30, with $364.8 billion in total assets, compared to $198.3 billion in total liabilities. Its Q4 cash and equivalents plus short-term investments were an impressive $104.8 billion.

Is Apple or Microsoft the better choice?

While Apple and Microsoft possess many appealing elements, downsides exist. A new tax on stock buybacks could affect both companies' approaches to repurchasing shares.

Apple's reliance on iPhone sales can become a weakness. If the new iPhone 14 fails to maintain the iPhone's popularity with consumers, Apple's revenue will suffer. That's what happened in 2019. When iPhone sales softened that year, total revenue dropped 2% year over year despite sales increases in every other Apple product and service.

Similarly, Microsoft's dominance in the PC market, where its market share is a little over 76%, has become a weak point. As consumers spend more time on mobile devices, the importance of PCs has waned. Microsoft blamed a deteriorating PC market, combined with pandemic-induced production shutdowns in China, for Q4's 2% year-over-year decline in its Windows licensing revenue from PC manufacturers.

But unlike Apple's reliance on the iPhone, Microsoft is a more diversified business. The company's offerings include its expanding Xbox gaming division, which is in the process of acquiring Activision Blizzard, and digital advertising. The latter segment saw a 27% increase in fiscal 2022 revenue and recently acquired Netflix as a customer.

Moreover, Microsoft will benefit from cloud computing industry growth, which is forecast to expand from $706.6 billion last year to $1.3 trillion by 2025. And Microsoft's cloud business isn't a single product line like Apple's iPhone. Cloud computing consists of disparate areas essential to business clients, such as cybersecurity.

As a result, switching costs are high, helping Microsoft retain customers. These factors give Microsoft the edge as the better long-term investment.