BlackBerry lives!

The company reported a profit (yes, a profit) that topped Wall Street's forecasts. The news sent the stock soaring.

Shares of BlackBerry (BBRY)rose nearly 15% Thursday after the company posted strong gains in sales of its software and services. Its upbeat outlook helps. The stock has now gained more than 50% this year.

To put that into perspective, BlackBerry stock has done better than Apple and the FANG of four that rule tech -- Facebook, (FB) Amazon, (AMZN)Netflix (NFLX) and Google (GOOG) -- so far in 2017.

BlackBerry is still probably most well-known for its QWERTY keyboard phones that used to be extremely popular on Wall Street and with many business consumers, governments and celebrities. Barack Obama and Kim Kardashian West were known fans.

But BlackBerry struggled to adapt to the smartphone revolution. It lost market share to Apple (AAPL)following the introduction of the iPhone as well as companies that make phones running on Google owner Alphabet (GOOGL)'s Android operating system, such as Samsung.

Losses piled up and the stock plummeted as a result. However, BlackBerry has made a stunning comeback under the leadership of CEO John Chen, who took over the top spot in November 2013.

Chen inherited a company in turmoil amid rampant speculation it would not survive.

Investors worried about the company's declining market share in the smartphone world, plunging sales, an anemic stock price and a rising debt load.

But BlackBerry has cleaned up its balance sheet under Chen. The company now has $2.5 billion in cash and investments and just $739 million in long-term debt.

Chen also pushed BlackBerry out of the hardware business.

It no longer makes its own phones. Blackberry outsources manufacturing.

It also has embraced Android. The BlackBerry Priv, DTEK60 and KeyOne all run on a BlackBerry version of the Android OS. The KeyOne, as the name implies, even has an old-school physical keyboard.

Licensing deals are increasingly important for BlackBerry. They now account for more than 20% of the company's total revenue. But Chen has also pushed BlackBerry into other areas outside of smartphones, such as security products and software for connected cars.

Related: BlackBerry soars after WannaCry attack

Software now makes up more than 40% of BlackBerry's sales. Big malware attacks like the WannaCry bug from earlier this year have helped boost BlackBerry's profile, for example, as more people became interested in their security products.

And the company continues to announce deals in the automotive world for its QNX unit, which makes so-called infotainment software for cars.

Ford (F)is a big customer, and BlackBerry also announced a partnership earlier this month with auto parts maker Delphi (DLPH) to build software for self-driving cars.

Chen said in a telephone call with reporters Thursday that QNX would continue to be a very important part of BlackBerry's future, adding that software for connected cars could be a meaningful part of revenue going forward.

In other words, it's time to get the image of people in the late '90s frantically typing on their CrackBerries out of your head. That's BlackBerry's past. Software and services that BlackBerry makes for other companies is its future. And it looks like a bright one.