Robert Heinlein is often remembered as being far to the right of his fellow members of the Big Three, Asimov and Clarke. How accurate is it to portray Heinlein as an anticommunist?
It's somewhat of an oversimplification to say that Heinlein was a one-dimensional Cold War hawk. He was a socialist in his youth, and probably formed his first political opinions before Stalinism existed. (Stalin came to power when Heinlein was 17.) He was active in Upton Sinclair's socialist End Poverty in California (EPIC) movement, and campaigned for Sinclair in the 1934 California gubernatorial race. The Molotov–Ribbentrop Pact happened in 1939, when Heinlein was 32; for many people of his generation this was the big moment of disillusionment with socialism. Asimov recalled Heinlein as having made a rapid swing to the right politically at about the same time when he married Ginny (1948). Although by the 1950's Heinlein was ardently anticommunist, he has positive things to say about Latin American socialism in his travelogue Tramp Royale, from the same period.
Heinlein's post-1950 opinions on Soviet communism were however very clear. He referred to the Soviets as the "Butchers of Budapest." He defends the McCarthy hearings in Tramp Royale. He had a falling out with Arthur Clarke over SDI.
The anticommunist message was strong in Heinlein's fiction, especially in the 1950's. He wrote Starship Troopers as his response to what he saw as the West's insufficient response to Soviet aggression. In The Puppet Masters, he states an explicit analogy between the mind-controlling slugs and Soviet communism. (See How exactly are the slugs analogous to communists? .) In Farnham's Freehold, Hugh Farnham makes macho boasts about his determination to kill as many (hypothetical) invading Russian soldiers as he can before they kill him.
I would point out that there is a large difference between Communism/Socialism and Stalinism. Heinlein appears to have favored a number of socialized social programs when he was younger, but was vehemently opposed to Stalinism.
After he and Ginny got back from a tour of Russia, he wrote an article (found in Expanding Universe as memory serves) where he describes his hatred of the Soviet system and the very concept of Pravda.
In his later work (Cat who Walked through Walls, I believe) there is implication (that is, the main character is Bob and the main female is Ginny) in his disgust with socialized healthcare, and by extension socialized programs. That said, my interpretation might be confused. Another reasonable interpretation would be that he didn't object to socialized medicine. Rather, he objected to people who expected it as their fair due, and refused to even try to better themselves and society. To restate: someone who is out of work through no fault of their own could have access to it and be grateful. Someone who sits and expects the riches of the world to be dumped on their head for the asking was another thing.
If we go by some of the family units he seemed to prop up, he may well have felt that a large community-style family who worked hard would have the means to take care of their own, without the necessity of government intervention.
One might also argue that his taste of Soviet Russia tainted his view towards social programs, perhaps with the dear that such programs would be cracking open the door to allow the more extreme parts of Soviet ideology to enter. As he pointed out, a society which requires its citizens to carry ID on them at all times is one on the verge of collapse, and it's time to get out.
And, of course, his opinion may well have changed as he got older.
I'm going to stop writing this now, because it started as a comment, and the more I think about it, the longer it gets.
Comment/additions to great answer by 2490. Few extra things:
He does address socialism (rather permissively) in For Us The Living. Not advocating it per se, but saying it was fine, but Americans needed something more their style. Beyond this Horizon also shows a few echoes of this Huxley-ish view of a socialist world government.
I think he was strongly influenced by Welles, who was an early socialist. Also, somewhat by Owen Johnson and Will Durant, both very liberal. (Upton Sinclair already mentioned.) Of course there are strong influences from popular liberal writers 20s/30s writers like Steinbeck and Sinclair Lewis and Margaret Mead and Huxley, that you can pick up in RAH's writing.
I think RAH drifted to the right as did many US Democrats after WW2 and Korea. He still had attended the 1940 Democratic convention. I do think the Roosevelt rivalry and win over Upton Sinclair, somewhat affected Heinlein in pushing him out of the party and out of a greater role in WW2. I agree that the wife also had an influence.
I corresponded with Bruce Franklin, who wrote a book length Marxist critique of RAH. RAH entertained him at his house for interviews and was engaging with him, even debating some socialist minutia. Franklin was unaware of the (very left wing) Upton Sinclair background, until I corresponded with him...RAH did not mention it when they talked and Franklin did not adequately research it either. [Franklin had moved on to other work, when we corresponded, so he had no urge to update his RAH analysis.] Of note, Ginny (good gurl!) wanted no part of Franklin and avoided him.
My understanding is that even in the 70s, 80s, RAH was not adamant about libertarian capitalism and was somewhat tolerant of some social welfare like in medicine or minimum income. But he was a complicated guy.
P.s. My father met him in the 40s in California, but no insights on his politics. Just said he was bright. "You could see the wheels turning." (People sometimes say that in a derogatory manner, but my father meant it positively...to say you could see the guy being thoughtful when an idea was floated.)
In Farah Mendlesohn's The Pleasant Profession of Robert A. Heinlein, she quotes Heinlein's non-fiction work "How to Be A Politician" to show that at one point Heinlein felt that acceptance of communism in any locality was a sign of serious societal problems that should be corrected, thus eliminating its momentary appeal:
Heinlein saw communism and communists as a fifth column within American socialism. Their danger was not as opposition: in How to Be a Politician he notes that communists act as an early warning system, warning the nation of injustices that need rectifying.4 ‘Any real local success on their part is a sure sign that some group of Americans are in such dire straits as to need emergency help – not punitive action!’ (p. 207) and ‘we are more prone to ignore the sick spots thus disclosed and content ourselves with calling out more cops.’