The US Navy spent $500 million to try to build a real one, according to Popular Mechanics, "using electricity and magnetism instead of gunpowder and chemical energy to accelerate a projectile down a pair of rails".
However it looks like funding for the railgun has run out without having sent a single weapon to sea, while pushing technology derived from the programme into existing weapons.
The move is part of the Navy's direction toward faster, longer-range weapons that are capable of striking ships and land targets in a major war. The Navy's budget request includes no funding for the railgun in 2022.
Railguns are theoretically safer than conventional guns, since they reduce the amount of volatile powder a ship stores. The projectiles are faster. However the Navy has abandoned development of the railgun after 16 years of work for some really interesting reasons.
There are currently only three ships the Navy could conceivably fit the railgun, as warship size has dropped. The railgun concept itself is also out of step with the Navy's reorientation toward great power conflict, particularly a possible war with China or Russia.
The railgun's range of 50 to 100 miles is relatively short, placing a railgun-equipped ship within range of longer-range weapons, including China's DF-21D anti-ship ballistic missile.
The railgun can be used to shoot down incoming aircraft, missiles, and drones, but the Navy already has plenty of existing missiles and guns which can already do that.