Shares of BlackBerry developer Research in Motion (Nasdaq: RIMM) surged more than 16 percent in Friday trading after the company reported smaller-than-expected second-quarter losses and higher revenue.

Shares of RIM, of Waterloo, Ontario, rose as high as $8.20 in early trading before easing back to close at $7.50, up 36 cents, or 5 percent. Still, RIM’s overall value is only about $4 billion, 64 percent  below its year-ago value, as its share of the smartphone market has fallen below 5 percent from about 12 percent, market researchers estimate.

Another surprise was that RIM's subscriber base rose to 80 million in the quarter, up 2 million. Analysts had expected its first-ever decline. The company had leaked that news on Tuesday.

Still, CEO Thorsten Heins predicted RIM will report another loss in the third quarter and didn’t announce a date for shipment of the new BlackBerry 10 model.

Still, RIM sold 7.4 million phones in the second quarter, about 500,000 more than predicted, and boosted its cash and investments by $100 million, to $2.3 billion.

Overall, the BlackBerry company reported a second quarter net loss of $235 million, or 45 cents a share, compared with prior-year net income of $329 million, or 63 cents a shate. Adjusting for charges related to firing employees and closing facilties, RIM's net loss was $142 million, or 27 cents a share.

The company's revenue rose a surprising 2 percent to $2.87 billion from the first quarter, although it was down from $4.17 billion a year ago.

The smaller loss and higher revenue, as well as the boost in number of subscribers, surprised analysts and led to the share jump on Thursday and during Friday trading.

Peter Misek, of Jefferies, said he was "surprised" by the execution of Heins and his staff but wondered if "excessive promotions" may have led to subscriber gains in emerging markets such as Indonesia and Venezuela, where BlackBerrys work well on immature networks.

Despite the gains, Misek said, RIM still lost share to the iPhone from Apple Inc. (Nasdaq: AAPL) and Android phones using the OS from Google (Nasdaq: GOOG). Apple's successful launch of the iPhone 5 will only accelerate the problem.

"RIM is a subscale handset maker that is losing share in all major geographies going forward," Misek said. He continued to rate RIM shares "underperform" with a price target of only $5.

At Sterne Agee, analyst Shaw Wu maintained a "neutral" rating on the shares because of competition. As well, he wondered if RIM will have sufficient cash flow to tide it over until BlackBerry 10 is ready.

The good news for BlackBerry 10 is that RIM has already gotten 40 mobile carriers in 16 countries to support it, Wu said.

Canadian analyst Gus Papageorgiu at Scotia Capital said he was so impressed that he boosted his opinion on RIM shares to "sector perform" from "sector underperform," although he noted the improvement may simply make the company more attractive to a buyer.

Meanwhile, brands expert Clive Chajet, who created the logo for AT&T Co. (NYSE: T) and worked with many companies, said management ought to battle the advertising onslaught by Apple and Samsung with its own campaign, especially because of its grip in the executive market.

"Any company that has 80 million customers is a strong brand," Chajet said. "They're not a fly-by-night company."

RIM, which largely invented the market for e-mail on-the-go, "needs to continue to invest in the brand," even if it doesn't have a new product yet, Chajet said.

"RIM needs to leverage its historical success," said Chajet, who doesn't own a BlackBerry and hasn't consulted for the company.