Online advertising is expected to surpass television advertising this year if it hasn't already. The growth in digital ad spend over the last decade is nothing short of astounding, with growth accelerating as smartphones became ubiquitous starting at the beginning of the decade.

Twitter (TWTR), with its mobile-first product, appears well positioned to capitalize on the trend of growing mobile internet use. But its user and active advertiser growth stalled over the last few years, and it's just starting to reaccelerate now. Meanwhile, Google, a stalwart of the old web 1.0, is managing to dominate the growth in digital advertising. Despite its massive size, the Alphabet (GOOG -1.10%) (GOOGL -1.23%) subsidiary is still managing to grow steadily year after year.

As an investor, which stock is a better buy? Shares of Twitter are depressed but could be poised for a comeback. Comparatively, Alphabet shares are trading near an all-time high.

Clockwise from top left: "@" carved in wood, bird logo made from recycled California license plates, "#" carved in wood, bird logo carved from California license plates.

Image source: Twitter, Copyright Troy Holden (@troy) for Twitter, Inc.

Twitter's future is uncertain

Twitter is in the midst of a change of focus from real-time information sharing to live video. COO Anthony Noto says he wants Twitter to show live video 24/7 from news, to sports, to entertainment. Last quarter, Twitter delivered over 800 hours of live video, attracting 45 million unique viewers. It broadcast those statistics on the first page of its quarterly letter to shareholders.

Twitter's push for more video content coincides with its decision to de-emphasize its non-video advertising products. As a result, Twitter has experienced a decline in ad revenue in each of the last two quarters. Overall, revenue declined 8% last quarter, and management's outlook for the second quarter indicates another decline.

Premium live video is a much riskier business than Twitter had been focused on. User-generated content is free, whereas Twitter has to pay for its live video content. The payoff could come from an increase in digital video advertising, which typically carries a premium price over the static display and direct-response advertisements that make up much of Twitter's revenue.

If Twitter's bet pays off, it could result in a return to revenue growth, breaking through the ceiling it hit last year even as user growth and engagement remain relatively low.

Google workers wearing different colored shirts to recreate the Google logo.

Image source: Google.

Now you can Google from anywhere

Have you ever been in the middle of a conversation with friends and a question comes up that no one knows the answer to? Of course you have, and inevitably, someone whips out their phone and "Googles" the answer.

That tick of human nature has been a huge boon to Google over the last decade. Google has so many more opportunities to show users advertisements now thanks to mobile. Last year, paid ad clicks on Google's owned properties increased 40% on top of a 33% gain in 2015.

Most of that increase in clicks stems from more mobile users, and mobile advertisements generally don't produce the same level of return as their desktop counterparts. Nonetheless, the trend has enabled Google to steadily increase revenue year after year. Revenue increased about 20% last year, and it nearly doubled from 2012 to 2016.

The price isn't always right

Twitter isn't profitable yet, so it's best to compare Alphabet and Twitter's stock prices based on sales or cash flow. To that end, Twitter trades at a modest discount to Alphabet shares. Even on a forward-looking basis, Twitter shares trade for just 5.2 times analysts' revenue estimates for 2017, while Alphabet (Class A shares) trades for 6.2 times. That's noteworthy considering the expected decline in revenue at Twitter.

But if you invest in Twitter, you're buying a struggling company and hoping for a turnaround. That's something Twitter's management hasn't yet shown the ability to do despite more than two years of trying. While its focus on live video is interesting, it faces a lot of competition in the space from companies with deep pockets -- one of which is Google.

Google has proven capable of navigating the growth of mobile, even thriving as more and more competitors enter the market. It's hard to see its advantages in search and video eroding anytime soon, if ever, which ought to generate continued steady revenue growth for years to come. Another factor worth mentioning is the 1% of Alphabet that's tied up in "other bets," which have a small chance of turning into big businesses. In that way, investors can get some modest exposure to high-risk, high-reward businesses.

Alphabet shares are worth paying a slight premium over Twitter shares for most investors.