Question: I've been wondering about this for a while, but cannot find any articles on it. When your website contains a dead link to a resource that is either not there any more, or was never there to begin with, do you get penalized? As I see it, there are some different use cases, and I doubt they'll all be dealt with equally.

* Linking to other web pages
* Linking to resources (images, JS, CSS etc.)
* Dead links to use in JS (e.g. faulty Ajax calls)
* Dynamically added links to dead resources (e.g. when an Ajax call is made, and the content contains a link that is dead)

How do search engines deal with these issues? Are they neglected, and simply *not followed* or does the containing website get a penalty?

Answer: 
Google (tries to) think as a user. So imagine you're a user and click a link, expecting a result, but it turns out to be a dead link. Bummer.  

Now translate that to a system useful for a bot: Some penalty if a dead link is found.

Now there are two options that can occur: 

* Hard end; file not there, default server/apache message showing file not found with sloppy headers. This will give you the most penalty as it is also user unfriendly.
* Soft end; there is no file, but you configured your server in a way that you now display a page made by you, offering the user a better message with some options to continue (e.g.: /Home)
Having a 404 that the SE finds is not going to hurt you, it will eventually remove it from its index, but if you have a broken link pointing to a 404 then yes, it hurts seo.

If you have external links pointing to the missing links, you should 301 then to a relevant page.