For a large part of the 2010s and beyond, software was "eating the world," as Marc Andreessen famously said. But in 2022 these stocks that dominated the previous decade started to suffer from indigestion. As inflation soared and interest rates spiked, investors had less appetite for companies with richly valued stocks that would only be profitable far out into the future.

With that said, many of these are still great businesses with stellar margins and strong subscription revenue. There are still plenty of software stocks that investors can buy now and hold for the next decade. Here are two of the best.

A smiling woman using a tablet at the office.

Image source: Getty Images

1. ServiceNow 

Investors are worried about investing in enterprise software companies at a time when businesses are slashing their budgets and trimming their workforces. Cue ServiceNow (NOW -3.41%), the cloud-based digital workflow service provider. ServiceNow focuses on providing workflow automation and other productivity solutions, which are as crucial as ever at a time when many businesses find themselves at one extreme or the other -- reducing their headcount or having trouble finding workers to fill the job openings that they have. ServiceNow is well-positioned to serve both of these types of businesses because it provides the types of solutions that they need to bridge the gap. In fact, the market for this type of workflow management system software is only going to grow going further, with Grand View Research predicting that this market will grow at a 30.6% CAGR from 2021 through 2028

ServiceNow has 7,400 enterprise customers and it counts 80% of the Fortune 500 among its customers. The number of customers spending over $1 million annually and $10 million annually is growing -- the company now has 1,530 customers with spending of $1 million annually (good for 22% growth year over year), and while it doesn't break out the specific number of customers spending over $10 million, it says this number grew by 60% year over year. 

ServiceNow boasts exemplary gross margins of 77%, indicating that the company has strong pricing power. As of the most recent quarter, ServiceNow had a renewal rate of 98%, illustrating that customers value its product and want to keep using it.

ServiceNow trades at about 40 times forward earnings, which is admittedly expensive, but the stock has grown diluted earnings per share at a CAGR of 77% over the past three years. If it continues to grow earnings at this trajectory, the price-to-earnings multiple should take care of itself over time. 

Looking at price to sales, which is a metric commonly used to evaluate software stocks, shares currently trade at about 11 times sales. That isn't cheap, but it is reasonable for a fast-growing, asset-light software business with strong recurring revenue. I've always operated under the premise that you can buy fast-growing software stocks for between 10 and 15 times sales, and ServiceNow currently fits into that framework.

This is one of the great growth stories of the past decade. From 2012 through 2022, ServiceNow has increased revenue from just $243.7 million to $6.91 billion. But this monster growth stock could just be getting started -- the company has a goal of generating $16 billion in annual revenue by 2026. If it hits this target, it would look cheap based on today's valuation, and the stock could be worth considerably more than it is today. 

2. Salesforce  

Like ServiceNow, Salesforce (CRM -1.97%) has been a top growth stock over the past decades, and one that has seen its stock price fall markedly over the past year. Shares of Salesforce are now down 38% from their 52-week high, and negative stories seem to surround the stock right now, whether it's co-CEO (and at one time heir apparent to the CEO job) Brett Taylor leaving the company or Salesforce's announcement that it would be laying off 10% of its workforce. 

But beyond the negative headlines, there is reason for optimism here. Like ServiceNow, Salesforce is the type of software solution that companies will likely be loath to cut, even in a downturn. Products like Sales Cloud increase the productivity of companies' sales teams and thus drive revenue, making this something that companies can ill afford to cut in a recessionary environment. Starboard Value CEO Jeff Smith, who recently took a large stake in the company, says that "Salesforce is ingrained in the fabric of so many companies and has become so important in the way they operate and conduct businesses." 

Starboard Value is a renowned activist investor perhaps best known for helping to turn around Darden Restaurants International (NYSE: DRI). The activist investor is on board with Salesforce's ambitious target of hitting $50 billion in revenue by fiscal 2026, but thinks Salesforce can use its scale to improve margins on the way to getting there. Starboard feels Salesforce's goal of 42% combined growth plus operating margins as too low, pointing out that smaller peers like ServiceNow and Workday (NASDAQ: WDAY) are achieving better combined growth and operating margins, and that Salesforce should be able to use its scale to catch up with them. (The "rule of 40" is a popular threshold used to evaluate software stocks.) If Salesforce is on board with Starboard's vision, it should be a boon to shareholders as it progresses toward $50 billion in revenue while achieving greater profitability. 

Even Taylor leaving has some silver lining, as it shows the appeal of the co-CEO model; Salesforce can keep chugging along with founder Marc Benioff in sole command, as opposed to having to stop dead in its tracks to find a new CEO who may or may not pan out. 

Furthermore, Salesforce is cheaper than ServiceNow on a price-to-earnings basis with a forward price-to-earnings multiple of 26, and Salesforce looks attractive from a price-to-sales basis as well, trading at just under 5 times sales. If Salesforce can keep growing toward its goal of $50 billion in revenue while improving margins, the company could eventually be worth significantly more than it is today. 

Software stocks may have lost some of the aura of invincibility that they enjoyed over the past decade, but these are still strong, sticky businesses with great margins and recurring subscription revenue. For long-term investors who can handle the volatility of the next few quarters, stocks like Salesforce and ServiceNow continue to look like long-term winners trading at relatively attractive entry points.