Perspective matters when choosing between stocks to buy. For example, you might think that GlaxoSmithKline (GSK -0.83%) stands head and shoulders above Johnson & Johnson (JNJ 0.67%) based solely on the respective stocks' year-to-date performances. On the other hand, J&J has been by far the bigger winner over the past five- and 10-year periods.

What's really important, though, is what the future opportunities for these two big pharma stocks might be. Here's what you need to know about how Johnson & Johnson and GlaxoSmithKline stack up against each other.

Gloved hands holding two test tubes

Image source: Getty Images.

The outlook for Johnson & Johnson

Based on the headlines for Johnson & Johnson lately, you'd think the outlook for the stock is downright horrible. J&J settled with two Ohio counties over opioid litigation. Retailers are yanking the company's baby powder products from shelves after the U.S. Food and Drug Administration (FDA) found very small traces of asbestos in a bottle of J&J baby powder. And Johnson & Johnson was slapped with a massive penalty of more than $8 billion in a case over alleged side effects of its antipsychotic drug Risperdal.

But to paraphrase Mark Twain, rumors of J&J's demise are greatly exaggerated. The company generated a staggering operating cash flow of nearly $9.5 billion in the first half of 2019. J&J raked in $20.7 billion in revenue in its most recent quarter, with profits topping $4.8 billion. It has a cash stockpile of more than $15 billion. With this kind of financial strength, Johnson & Johnson remains in a very good position, to put it mildly.

J&J's strongest unit, its pharmaceutical segment, claims four blockbuster drugs that achieved double-digit year-over-year revenue increases in the third quarter. Despite headwinds for older drugs such as Remicade and Concerta, the pharmaceutical segment is performing quite well.

Chief Scientific Officer Paul Stoffels stated in July that J&J's pipeline includes 14 candidates that could top $1 billion in sales by 2023. The company also has already-approved new drugs that should have plenty of room to run, notably including immunology drug Tremfya.

A big plus for J&J is its diversification across multiple areas of healthcare. The company's consumer health and medical device segments are both multibillion-dollar businesses that continue to generate operational growth. J&J's acquisitions strategy and selective divestitures have positioned these businesses well for the future.

Any discussion of Johnson & Johnson's prospects should include its dividend. Its dividend currently yields a little under 3%. J&J is a Dividend King -- boosting its dividend for a remarkable 57 years in a row. The company should be able to keep that streak going.

The outlook for GlaxoSmithKline

GlaxoSmithKline offers investors some diversification as well. The company has three business segments: consumer healthcare, pharmaceuticals, and vaccines. As is the case with J&J, GSK's biggest moneymaker is its pharmaceuticals business.

The bad news for GSK's pharmaceuticals segment is that sales are declining for several of its older drugs. That's particularly problematic considering that one of these declining products, Seretide/Advair, still ranks as one of the company's top-selling drugs.

However, GSK has plenty of newer drugs that are delivering solid growth. Its respiratory drugs Trelegy Ellipta and Nucala claim strong sales momentum. New HIV drugs Juluca and Dovato are gaining traction. Sales are soaring for anti-inflammatory drug Benlysta and ovarian cancer drug Zejula, which GSK picked up with its acquisition of Tesaro.

Although GSK makes most of its revenue from pharmaceuticals, the company's vaccine business is generating the strongest sales growth. Shingles vaccine Shingrix is leading the way. GSK also continues to enjoy nice growth for several other vaccines, including meningitis vaccine Bexsero and childhood vaccines Infanrix and Pediarix.

At the end of July, the company combined its consumer healthcare unit with Pfizer's consumer business, with GSK owning 68% of the joint venture. While GSK's consumer unit continues to grow revenue by mid-single-digit percentages, the Pfizer deal could boost growth even more.  

Then there's GSK's dividend yield of 4.25%. That's certainly a juicy yield, but the main downside is that the company doesn't have a lot of wiggle room to increase payouts in the future. GSK also has a sporadic history with dividends, with several dividend cuts in recent years.

Better buy

Despite GSK's decidedly more impressive performance so far this year, I think that Johnson & Johnson is the better pick for long-term investors.

Granted, the company faces some uncertainty right now, with the various controversies in which it's embroiled. However, for top blue-chip stocks like J&J, it's times like these that provide the best opportunities to buy. Investors might have to endure more volatility for a while, but I predict that Johnson & Johnson will be a solid winner over the next 10 years or more.