Two industry stalwarts: One is the world's largest construction- and mining-equipment manufacturer, and the other the world's largest farm-equipment company. Both are battling strong end-market headwinds and have struggled to grow profits in recent years. Regardless, both stocks are flying through the roof on one bumper quarterly earnings report.

That pretty much sums up the stories of Caterpillar Inc. (NYSE:CAT) and Deere & Company (NYSE:DE) so far this year. Both heavyweight stocks are currently trading at their 52-week highs, with Caterpillar piling on 9% since announcing its first-quarter numbers mid-April and Deere gaining exactly as much since releasing its second-quarter numbers (Deere's financial year runs from November to October) on May 19.

The big question for investors is: Is this the turnaround we've been waiting for? And if so, is Caterpillar or Deere the better buy today?

The common link

On the face of it, Caterpillar and Deere operate in two different industries, with Caterpillar catering to construction, mining, and oil and gas customers while Deere serves agricultural farms. However, Deere also makes construction equipment, which is why the two stocks are commonly pitted against each other.

Heavy machinery

Image source: Getty Images.

In fact, construction equipment is an important business for Deere, with almost 21% of its total machinery sales coming from its construction and forestry division in fiscal 2016. Moreover, Deere might've ended the year on a much stronger note -- it reported 21% lower net income -- if not for the sharp 66% slump in operating profit from its construction business. Lower sales volumes were largely to blame.

Investors were in a for a huge surprise when Deere recently reported 7% higher sales from its construction and forestry division for Q2 and projected full-year segment sales to jump 13%. (I admit I didn't see it coming either and was rather cautious about Deere.) What wasn't surprising was that Caterpillar shares bumped up too after Deere's numbers, just as Deere stock had when Caterpillar announced its own set of strong Q1 numbers in April.

Now that you know what Caterpillar and Deere have in common, let's get back to examining which stock is a better buy today.

Why Caterpillar isn't making much money

Construction equipment might be Caterpillar's bread-and-butter business, having accounted for a little more than 40% of its total machinery sales last year, but the company's fortunes are tied just as closely to the mining and oil and gas sectors.

What this means is that strong construction markets aren't enough to get Caterpillar back on the growth track. Right now, several pockets of weakness could continue to dent Caterpillar's prospects, including low capital spending by miners and oil and gas companies, as well as weak rail, marine, and power markets. These factors, combined with swelling restructuring costs as Caterpillar strives to maintain margins, explain why the company expects earnings of only about $2.10 per share this year, which looks like a dramatic improvement over last year's impairment- and restructuring-driven loss of $0.11 per share but is just a fraction of what it earned during its heyday.

In fact, heavy exposure to volatile sectors like mining and oil and gas can largely be blamed for Caterpillar's struggles in recent years. Mind you, Deere's farm-equipment business can also be very volatile as it is subject to the vagaries of climate conditions, farm income, and crop prices. But farm fundamentals didn't deteriorate as much as mining, or oil and gas more recently.

So while Deere's earnings have also come under tremendous pressure in recent years, the slump hasn't been half as bad as that of Caterpillar. And when you look at the trend in cash flows for the past five years, Deere clearly outshines Caterpillar.

CAT Net Income (TTM) Chart

CAT Net Income (TTM) data by YCharts.

Headed in different directions

Despite all the excitement, 2017 could still be among Caterpillar's worst years in terms of profits. The scene at Deere is just the reverse, with the company now projecting 8% and 13% growth in its agricultural and construction and forestry sales, respectively, for fiscal 2017. As for profits, Deere might end the year with nearly $2 billion in net income, or a huge 30% jump over 2016.

I think that's a remarkable turnaround, and Deere stock certainly deserves all the attention it's getting. I'm not sure if I can say the same for Caterpillar, though, simply because the stock has run way too high despite the company's weak operating performance. The thing is, Caterpillar investors are betting on a potential turnaround backed largely by an anticipated uptick in infrastructure spending under President Donald Trump. But it largely remains a speculative bet. Investors in Deere, on the other hand, are betting on a visible turnaround, which makes far more sense.

Interestingly, Deere is also trading cheaper than Caterpillar on a trailing-earnings basis. Even if I give Caterpillar some leeway and consider its adjusted 2016 EPS of $3.42, it is still costlier than Deere at around 31 times trailing adjusted earnings.

CAT PE Ratio (TTM) Chart

CAT PE Ratio (TTM) data by YCharts.

So based on past performance, projected profits, end-market prospects, or valuation, Deere, in my opinion, is a better and safer pick than Caterpillar right now. 

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.