JOHANNESBURG, JULY 11 -- The South African Communist Party, unfazed by the collapse of socialism in Eastern Europe, is emerging from 40 years of clandestine existence arguing that history is still on the side of Marxism and that a revised socialism could flourish in a "new South Africa."

For four decades, the Communists and the black nationalist African National Congress have been closely allied. Their leaderships, political strategies and short-term goals have been largely synonymous in the struggle against apartheid.

Now, with unprecedented talks between the government and black nationalist leaders expected to begin soon, the Communist Party's leadership has decided it is time to stake out a place in the political sun and defend a cause largely discredited elsewhere.

On July 29, the party will hold its first public meeting in the nearby sprawling black township of Soweto, where it plans to disclose the names of its internal leadership and rally those who still believe in the cause. Already at ANC rallies, Communist Party flags are second in number only to the black nationalist group's green-black-and-gold banners.

Joe Slovo, the party secretary general who once served as the chief of the ANC's military wing, is a folk hero in the nation's black townships, feted in songs for his unflinching commitment to the black nationalist cause.

After the two top ANC leaders, Oliver Tambo and Nelson Mandela, Slovo, who is white and returned to South Africa in April after nearly 27 years in exile, probably has more name recognition within the black community than any other anti-apartheid leader. He is the most popular speaker after Mandela.

"We have no doubt that our popularity is greater today than it has ever been in our history," Slovo told a recent news conference.

Slovo believes that the Communist Party could become the second-largest group after the ANC in a post-apartheid South Africa. But since the party was declared illegal in 1950, it has remained underground with its leadership and membership of probably only a few thousand kept secret and largely integrated with those of the ANC.

The government, which has long been vehemently anti-Communist, disputes that the party is popular and contends that the party's ideology will fail to survive public scrutiny.

"For 40 years we tried, as it were, to keep the lid on it, to suppress it by legislation. Now we are looking the Communists in the eye and engaging them in debate," said Law and Order Minister Adriaan Vlok. "I can assure you that we are not going to lose the fight. We are determined to kill communism in the hearts of people, and I am convinced we are on the winning side."

Slovo has taken up the challenge with gusto. Since President Frederik W. de Klerk legalized the Communist Party, the ANC and other anti-apartheid groups on Feb. 2, Slovo has been working hard to forge a new image for his party.

The party was once regarded as one of the most slavishly pro-Soviet and Stalinist anywhere in the world, and to some Western intelligence agencies and South African whites, it was akin to a secret society that had taken over the ANC leadership from within.

But by going public with the names of its internal leadership and members, while keeping a reserve underground network secret, Slovo hopes to dispel old notions of the Communist Party's continuing close alliance with the ANC.

It has been 40 years since the party really stood on its own. It grew and stayed close to the ANC after its banning in 1950, the two drawn together by a common enemy and the anti-apartheid struggle.

Slovo quickly became a central figure in ANC politics. He participated in the drafting of the 1955 Freedom Charter, the ANC's first basic statement of principles in which the commitment to multi-racialism rather than the black-power ideology of the rival Pan-Africanist Congress was first adopted.

In exile after 1963, Slovo rose to become for a time a chief ANC military strategist and even chief of staff of its military wing, Spear of the Nation. Other party officials followed his route into the top echelons of the ANC. U.S., British and South African estimates of the number of Communists serving on the ANC's National Executive Committee have varied between one-half and two-thirds of its 30 to 35 members.

Nobody could doubt Slovo's deep personal commitment to the ANC cause after living for decades in lonely exile, particularly after his wife, Ruth First, was killed by a suspected government-sent parcel bomb in Maputo, Mozambique, in 1982.

The Communist Party's greatest impact on the ANC, according to Slovo, was its ideological input, turning the ANC into a "revolutionary nationalist organization" with a strong "working class bias." The ANC has retained Marxist jargon and analysis that continue to flavor its statements and writings.

Slovo's appearance has helped to soften the uncompromising image that his party has had. With his friendly smile and twinkling eyes, Slovo, 64, more resembles a jovial grandfather or sympathetic professor than an orthodox Stalinist.

Neither does he talk like a Stalinist. Slovo has been trying to convince South Africans and Westerners that his party has become an advocate of "democratic socialism," a supporter of a multi-party system with freedom of expression, of religion and of the press.

"You don't have to be a Communist or a Marxist-Leninist in South Africa to believe in the concept of the redistribution of wealth or a more egalitarian economic society, because the blacks here have been deprived of participation at the economic as well as the political level," Slovo said in an interview. "It's a short hop from being a sort of militant nationalist to becoming a Communist in South African conditions."

Historical circumstances, according to Slovo, explain why South Africa is such fertile ground for socialism. In South Africa, "capitalism was built historically on racism. It no longer needs to be, but it was," Slovo said. "The perception of the average black worker is that racism is synonymous with capitalism."

In South Africa today, whites, who number 5 million, control the government and own most of the land and businesses. Under apartheid, the system of racial separation, the nation's 30 million blacks have no vote or representation in parliament, have been forced into squalid townships or divided into tribal "homelands" and given inferior education and the lowest-pay jobs.

"For the average black in South Africa, what has failed is capitalism, not socialism," Slovo said.

Slovo, who was long regarded as one of the chief Stalinists within the party, now exudes ideological flexibility and political pragmatism.

The Communist Party, he said, is not trying to mobilize people with promises of "taking socialist power," and those who are "shouting slogans about socialism are diverting us" from the main task of "the complete destruction of apartheid."

But many white South African liberals remain suspicious of Slovo's latter-day conversion from a Stalinist to an admirer of Soviet President Mikhail Gorbachev, seeing this as a confirmation of his continuing close adherence to the Soviet line of the day.

There are reports that he runs the party with an authoritarian hand and that his January critique of Soviet-style communism -- in a paper entitled "Has Socialism Failed?" -- reflected mostly his personal view rather than the collective thinking of the party's leadership.

Slovo at times comes across more like an advocate of seminal capitalist Adam Smith than of Marx and Friedrich Engels, arguing that it would be "suicide to jettison the private sector" and insisting that the job of the state is to create "stability and a return on investment" for private companies.

"We don't go along with the throwing about of this cliche about nationalization," he said. "You had nationalization in socialist countries of various sectors, and people didn't benefit from it."

Slovo conceded that capitalism was a superior system for generating wealth, but maintained that it was no good at the task of redistribution. Only the state is capable of achieving a more equitable distribution of wealth than now exists in South Africa, he said.

Slovo, however, is vague about what form of state intervention he favors. He refused to cite any socialist example he would hold up as a model for South Africa and insisted that popular participation is a key ingredient for the success of socialism today.

Slovo's concept of the Communist Party in a new democratic South Africa is also vague.

"We are working on a formula of creating a balance between the idea of having a large party, a mass party, and a party of quality and caliber," he told a news conference recently. If the party enrolls 20,000 to 30,000 activists in its first year, he would be satisfied, he said.

One problem for Slovo is the party's relationship with the ANC after 40 years of living and working with its leaders underground and abroad. Questioned about dual membership, he said the issue is "premature."

Given the ANC's standing as the country's most popular movement, Slovo may calculate that the Communists might do better in an electoral alliance than competing alone to gain the maximum number of seats in a post-apartheid parliament.

He predicted that the alliance between the Communists and the ANC will remain intact at least until the anti-apartheid struggle is won. After that, the party might go its own way and field its own candidates, he said.