Question: When it comes to programming, I don't hold strong opinions about feature x vs feature y. I think all have their appropriate uses.

And I'm always reading everything I can about as many programming languages I can get my hands on so that I can pull the best ideas out and compare them all (from Haskell to Lisp to C to Erlang).

But there is something that's been bothering me a little bit, and basically it's that when I've read about comparisons between static and dynamic typing, one downside for dynamic typing is that "bugs" come in because the compiler isn't able to check the type of the variable.

Now, I have plenty of bugs when I program, but I have *never* had a bug due to something like this, and I'm actually having a hard time visualizing what an example of such a bug would be. Like maybe forgetting you used an integer instead of a string somewhere? This seems so contrived though...

I program for a hobby, not a living, so perhaps these types of bugs only come in when people with different ways of thinking about things get together. I'm really just looking for some real-world examples.

Answer: 
An example would be when you change a variable from one type to another:

```
setType(String type)

```

Then later you decide to change the type to a more efficient enum:

```
setType(SomeEnum type)

```

When you do that in a strongly typed language, you will get errors wherever `setType` is called. That allows you to fix them quickly and to make sure you didn't miss any. In a dynamic typed language, you won't get such errors and will have to look for these instances by yourself.

Strongly typed languages are also generally faster since they can store data in more efficient structures (since the type is known at compile-type). An example are C arrays versus PHP arrays. C arrays are compact but PHP arrays have a rather big overhead to manage the dynamic data they contain.
@Laurent has answered your question very nicely. I would just like to add that, for example, there's a testing/dynamic-bug-finding tool for JavaScript (a dynamically typed language) called [TypedJS](http://typedjs.com/). It is just designed to prevent bugs that occur due to dynamic programming.

An example bug that TypedJS tries to prevent can be seen in this screenshot:

![TypedJS](https://i.stack.imgur.com/GPe8V.png)