Consider it as the work dichotomy.

There is a shortage in the millions for skilled labor jobs in the United States. The country is desperate for men and women who drive trucks, operate machines, weld, wield hammers — or can fill skilled jobs in dozens of categories from bulldozer operator to utility lineman.

Bill Hillman, chief executive officer of the National Utility Contractors Association, the organization that represents contractors (people who do everything, from replacing electricity poles to working down manholes to operating heavy equipment), says getting help is a major problem for his members. So they are setting up training programs and working with schools and community colleges.

But these also are some of the people who could be jobless due to artificial intelligence (AI) in the near future. Thomas Kochan, co-director of the MIT Sloan Institute for Work and Employment Research, told me this “middle of the labor market” is coming under attack by AI deployment.

John Savage, professor of computer science at Brown University, foresees a need for major retraining of workers with the spread of AI. But he told me he is “optimistic”: He sees major displacements but new opportunities.

Displacement is a worry for workers, but so is job quality deterioration in the so-named gig economy or freelance economy: a volatile labor pool where the employer holds most of the cards.

Gig workers are spread among diverse occupation groups: arts and design, computer and information technology, media and communication, transportation and material moving, construction and extraction. They are working here and there without permanence, medical insurance or pension provisions, like employer 401(k) contributions.

That is for starters and it is happening now. Then comes the apocalypse when millions of workers find themselves displaced by thinking machines. Think of what happened to elevator operators in cities when elevators were automated.

The first to go might be taxi drivers, some truck drivers, airline pilots and others in transportation. Already in Phoenix, you can ride in a robot taxi operated by Waymo, the Google self-driving car project. Truck makers, stirred on by potential competition from new entrants, like Tesla, are hard at perfecting autonomous intercity trucks.

To my mind, the issue is not whether but when. There are more than 3 million truck drivers on U.S. roads. Not all will be displaced by AI, but if 1 million go, there will be considerable downward pressure on wages.

Traditionally, and Savage points this out, automation has led to a surge in new, different jobs. Ned Ludd, who with his followers destroyed mechanical weaving machines in England in the early 1800s, was wrong. Mechanized weaving added far more related jobs than those lost.

But this time it could be different, warns John Raymont, chief strategy officer of Kurion, an advanced technology nuclear company. He says the difference is that automation heretofore has led to more products, and therefore more jobs. Artificial intelligence threatens to take away jobs without producing new products, which themselves produced new jobs.

Take the automobile production line: It led to more people being able to afford cars and more jobs maintaining and fueling those cars. It enhanced America’s growing prosperity.

So far, AI appears to be aimed directly at employment. In the way that cheap labor in Asia sucked manufacturing jobs out of the United States, so machines may take over skilled jobs from airline pilots to Uber drivers, Raymont says. Other jobs may still be safe, including plumbers, he says.

And it will not be just manual workers who will have their jobs taken over by wily computers. Accounting, tax preparing and auditing, money lending, loading and unloading ships and trucks will be done by machines guided by artificial intelligence. A ship, it is theorized, will be able to leave a U.S. port without the aid of seamen or dock workers and sail to Singapore, dock and unload autonomously.

Job displacement may have this opportunity: More leisure time in which people can play golf on greens maintained by thinking mowers, aerifiers and fertilizer spreaders. After they play, a machine may make them an extra dry martini at the club bar.