the Japanese planes. Couldn't those gunners see where the planes were going and lead fire? In the movies they seem very incompetent.
In today's terms, there is something called "Virtual Attrition". It comes down to the difference between "defeating" the enemy, and "destroying" him.
The purpose of most of the AA guns on ships is self-defense. I.e., to make sure that the ship survives the attack with limited damage. (I'll leave the area defense weapons for a bit). To do this, it is not necessary to destroy the enemy, just to either drive him away or make him miss.
Pretty much anything smaller than a 40mm (and most of those, at the beginning of the war) would be fired under local control. That means that each gun has one or two people responsible for all aspects of aiming and shooting, as you would spect a gunner to be doing. That includes range estimation, lead estimation and so on. As you can imagine, this is not an easy task to do. Try it next time you see an airplane, estimate speed and range. It is unsurprising that most rounds will miss, and of those that don't, it usually will take a hit to something vital like the pilot in order to cause the airplane to fall from the sky in the immediate aftermath. You can imagine, however, that being in an airplane with tons of tracer coming at you, and maybe the odd pinging of impacts, is likely to be rather disturbing, and could well put you off your game enough that you will either miss, or turn away. In either case, job done for the AA gunner.
The bigger stuff, such as the 3" and 5" guns could often be found under director control. In this, there is an individual at a separate station whose function it is (and he's equipped with tools to help him) to estimate range and lead, and he will "direct" a mount or mounts onto the target. In such a case, the gunners are usually following instruments, not aiming at the target itself. These tend to be more accurate, and more likely to destroy the target, but fewer in number compared to the smaller guns.