NAGYMAROS, Hungary— You know immediately when you arrive in Hungary from Austria that you have crossed more than a national frontier. You have also crossed from one historical zone, one domain of experience, into another.

First there is the ritual, now absent when you travel between European Union countries, that makes entering Hungary seem a bit like an old World War II movie -- the posse of uniformed police officers with guns who solemnly check passports.

This entry from Austria to Hungary was by train, and a group of customs officials in T-shirts spent a good deal of time with flashlights inspecting the spaces above the lavatories for contraband.

All of that will disappear on this particular border next May when Hungary and nine other countries, most of them former members of the East bloc, join the European Union.

What will disappear less slowly is the scene outside the window on the Hungarian side of the border. A few yards from Austria concrete, Stalin-era housing complexes remain, stained and battered but still in use.

On this side it is shabbier, rustier, weedier, even now 14 years since Communism disappeared from this country and the Iron Curtain from Europe. But if Hungary seems unkempt compared with its opulent upriver neighbors, it also hums with a kind of ardor, an avidity for new prospects that one seldom feels in the take-everything-for-granted countries farther west.

''The difference is less than when I was in kindergarten,'' said Laszlo Csaba, a professor of economics and European studies at the Central European University in Budapest. ''But it is greater than when my grandparents were in kindergarten.'' He was referring to the difference between Hungary and Austria, and between the former East Europe and the former West.

''In 1938, it took two hours to go by train from Budapest to Vienna,'' Mr. Csaba said. ''Now it takes two and a half to two and three-quarter hours, depending on the train. That's it, history in a nutshell.''

In fact, other people in Hungary question the accuracy of Mr. Csaba's particular example about the train, but few would dispute the overall point. History for Hungary means the country's slippage from full European status into mass murder, dictatorship, enforced poverty and isolation from the rest of the world, a slippage that has left most people less well off than people in their grandparents' and great-grandparents' time.

Hungary, after all, is the place where a little more than a century ago, Gustav Mahler directed the state opera. Later, it was where Bela Bartok lived and worked, and the home of such others as the photographer Robert Capa, the writer Arthur Koestler and several great figures in 20th-century nuclear physics, including Leo Szilard, Edward Teller and John von Neumann.

It is also the country where 60 years ago, Hitler was welcomed by a collaborationist government, which then looked the other way as some 550,000 of Hungary's 700,000 Jews were deported to Auschwitz.

Having had the worst of World War II, in which it was on the wrong side, Hungary then got 45 years of Soviet domination, including the events of 1956, when the Soviet Union crushed a popular nationalist uprising in Hungary and executed Imre Nagy, the Communist leader who dared to speak out against Moscow.

Hungary is the kind of place where every little village lost on the shores of the Danube has its part in the 20th-century tragedy and, in some instances, in the late-century recovery.

This modest place on the north bank of the river just opposite the imposing ruins of the castle at Visegrad, built by the first Hungarian kings in the 13th century, is where a dam, planned in the 1980's by the Communist government, was never built -- and in not being built changed not the course of the river, but the course of recent history.

''The harmony of nature would have been harmed by the dam,'' Mihaly Zoltay, a former mayor of Nagymaros, said, showing visitors the broad, verdant spot on the river where the dam would have been.

''When I was a kid, I used to swim in the Danube here,'' he said, ''but after the dam was built nobody would have come here. This is one of the sacred spots in Hungary, and the dam would have harmed the view.''

The question of the dam is not entirely over, even though after huge popular protests throughout Hungary the government abandoned its plans to build it here.

More recently, neighboring Slovakia, which as part of Czechoslovakia in those days was a partner in the original project, diverted the river near Bratislava, the Slovakian capital, and built two dams upriver from Hungary, a move that has been sharply criticized by environmentalists in Hungary and elsewhere.

But more important, the dam came for many Hungarians to symbolize what Krisztian Szabados, a director of a new and successful policy research and consulting firm in Budapest, called ''the real meaning of Communism.''

''There were two ways to protest in Hungary in the 1980's,'' he said in his tastefully sleek office. ''One was protesting the dam; the other was to deface one of those big statues of Communist heroes that used to be all over the place.''