Should DFT of cosine function be infinite at its frequency?

The Fourier transform of the cosine function is an infinite spike (Dirac delta function) at the frequency of the cosine wave. But it seems most DFT programs give a finite spike corresponding to the amplitude of the cosine function. For example, if the amplitude of the cosine function is 3, you will get a spike of magnitude 3 at the frequency of the cosine function, and zero elsewhere. So what is the explanation for the the finite spike?

If a signal has a continuous range of frequencies, I think the DFT would give the same basic curve as would be calculated from an analytical Fourier transform. But seems there is an anomaly when the Dirac delta function is involved (?). What am I missing? Thanks!