BOSTON — THE United States, the world leader in computer software, is looking over its shoulder with increasing concern.Other countries aim to close the software gap. The main contender is Japan. "In the long term, I think it's very foolish to count Japan out as a software powerhouse," says Wes Patterson, chief operating officer of Xilinx Inc., a San Jose, Calif., supplier of software intensive integrated circuits. "Ten or 15 years from now they're going to be competing with us aggressively in the software arena." To the autoworker in Detroit or the computer-chip fabricator in Silicon Valley, the spread of Japanese competition to software might appear inevitable. To some in the software community, the idea seems almost laughable. The US has a critical mass of advanced programmers, research institutions, and entrepreneurs. Its software companies churn out a vast array of off-the-shelf products that are big sellers in Europe and Japan as well as in the US. Supposedly, American culture is more creative, more individualistic, and somehow better suited than Japan to create software. Typical was the reaction of American programmers at Voice Processing Corporation when a delegation of Japanese visited their Cambridge, Mass., headquarters recently. The programmers were amazed at how far behind Japan lagged in voice-recognition technology. "These guys can't code their way out of a paper bag," summed up Dana Lashway, a Voice Processing engineer. Yet a number of US industry observers are concerned Japan will close the software gap. "US computer systems firms are still the dominant producers in world equipment and software markets, but US leadership is under assault," the Council on Competitiveness warned earlier this year in a report. "The Japanese believe they can apply quality as a differentiator just as they did in hardware," concludes a recent Ernst & Young survey of 550 US electronics companies. "Roundtable participants believe there is growing cause for concern about the state of software quality in the US." Some critics even contend that America's supposed cultural advantage in building software is actually a detriment. "We have a cultural disadvantage when it comes to software development," says Shmuel Halevi, vice president of Technology Research Group in Boston. The Japanese "are much better in thinking first and executing later. And I believe that that's the way software will be written." The emerging debate over software is much broader than which country will get the lion's share of the market. It involves fundamental questions about the nature of software and how it will be built. Is software a thing, like a car or a boat, that can be assembled, factory-like? Or is it a creation, like a novel, that requires inspiration and creativity? It's clear where the major Japanese computer companies stand on the issue. They're applying their mastery of process to the creation of software. In other words, major companies such as Fujitsu, Hitachi, and NEC are building software factories. Several US observers worry that the software from these factories is equal to or better than what's coming from the US. "The evidence suggests strongly that at least these firms ... are now at least comparable and possibly superior to US firms in productivity, defect control, and reusability," writes Michael Cusumano, author of a new book called "Japan's Software Factories." Although comparisons are difficult, Mr. Cusumano estimates the best Japanese companies produce software that's 33 to 50 percent more bug-free than the average US firm with programmers who are 50 to 70 percent more productive. The Japanese continue to systematize the development process, looking for ways to reuse portions of software programs for new projects. They also benefit because their computer hardware is much more homogenous than the systems in the US, Cusumano says. On this side of the Pacific, the whole idea of a software factory flies in the face of established practice. While a few firms have experimented with the idea - most notably System Development Corporation, which ran a software factory for three years in the mid-1970s before letting it wither away - most software companies are much more free-wheeling. The software race is not likely to be decided soon. Nor are Japanese companies poised to flood the US with better spreadsheet and database software, says Paul Nesdore, an International Data Corporation analyst. The language barrier, as well as distribution and competitive challenges facing any would-be Japanese developer are formidable. But what is clear, Mr. Nesdore adds, is that the days of US software dominance in foreign markets are numbered.