Tech stocks faced a tough 2022, with reductions in consumer spending dragging down the shares of some of the world's most valuable companies. According to IDC, in the third quarter of 2022, worldwide PC shipments declined by 15%, and smartphone shipments fell by 9.7% as consumers cut discretionary spending.

Even so, tech stocks remain some of the best investment options for the long term, with now an excellent time to invest. Alphabet (GOOG 9.96%) (GOOGL 10.22%) and Microsoft (MSFT 1.82%) have each experienced double-digit decreases in their shares. However, these supercharged growth stocks have continued to provide long-term gains.  

Here's why Alphabet and Microsoft are two tech stocks to buy without hesitation heading into the new year. 

Alphabet 

Alphabet's predominantly advertising-focused business has dragged its stock down almost 40% year to date as rising inflation has caused many businesses to cut advertising budgets. However, these economic headwinds are temporary and don't dampen Alphabet's position as a promising long-term investment. 

Research from Omdia estimates the digital advertising market was worth $190 billion in 2022 and will almost double to $362 billion by 2027. Alphabet's leading 28% market share in the industry puts it in an excellent position to see long-term gains from the market's development.

Additionally, despite a slowdown in ad spending over the last year, Alphabet's financials have not suffered as much as its stock price would have you believe. In Q3 2022, revenue rose 6% year over year to $69 billion, with operating income reaching $17.1 billion.

Revenue from YouTube ads and Google Network slightly declined, while search, advertising, and services marginally grew between 2.4% and 4.2%. However, the champion of the quarter was Google Cloud, which saw revenue increase 37.6% to $6.8 billion.

There's no doubt Alphabet suffered from a poor economic climate this year, but its continued revenue growth highlights its strength. In fact, since 2018, the company's revenue has risen 88% from $136.8 billion to $257.6 billion in 2021.

Over the last year, the streaming industry has heartily embraced ads as companies such as Walt Disney and Netflix have introduced ad-supported tiers to their platforms. A looming recession in the new year could prompt other online industries to look to digital ads to reduce service costs for consumers. Alphabet's dominating position in advertising could pay off big, with its booming cloud business being the icing on the cake. 

Microsoft 

Microsoft is one of the easiest stocks to recommend, with its diverse business granting it considerable market share in many lucrative industries. As the home to brands such as Windows, Office, Xbox, and Azure, the company has strong positions in operating systems, productivity software, gaming, and cloud computing. 

Moreover, Microsoft's performance amid the sell-off of 2022 has only made it more attractive. While the Nasdaq-100 Technology Sector index has plunged 40% year to date, its shares have fallen a more moderate 28%. Microsoft's business has also shown long-term promise, with some segments relatively unaffected by recent macroeconomic headwinds able to make up for declines in its PC-centered segment. 

For instance, in Q1 of fiscal 2023, Microsoft's revenue rose 11% to $50.1 billion, and operating income increased 6% to $21.5 billion despite revenue slightly declining in its more personal computing segment and operating income falling 15%. 

The growth was primarily thanks to the company's cloud-computing and productivity-processes businesses. Microsoft's intelligent cloud segment, including Azure revenue, grew 20% to $20.3 billion. The tech giant's subscription-based business also experienced stellar growth, with revenue from Office 365 increasing by 11% and LinkedIn revenue rising by 17%. 

However, the biggest reason to invest in Microsoft is its swiftly growing cloud-computing brand, Azure. According to Grand View Research, the booming market was worth $369 billion in 2021 and will see a compound annual growth rate of 15.7% through 2030.Considering Microsoft holds the second-largest market share in the industry at 21%, its intelligent cloud revenue is likely to continue rising for the long term.

Furthermore, Microsoft has plans to build data centers in 11 new regions, with the company incredibly "bullish" about Asia as a growth market.The move will likely grow Azure's market share and boost revenue. 

Microsoft's stock may have tumbled in 2022, but its business is quickly expanding across several industries, making it a no-brainer buy.