The calories in calories out idea doesn't help in understanding weight loss. Before you object, here's a hypothetical example, that should make you realize, that while true, the law of thermodynamics is actually irrelevant to weight loss, and that all calories are not equivalent.
Let's say I gave you a pill to eat every morning. This pill contained only four calories. However, this pill affects your hormonal balance, and it makes you ravenously hungry all the time, and also quite lethargic. Perhaps it's related to your thyroid, but that doesn't matter for this example. What matters is that it makes you hungry and sedentary.
As a result, you are probably going to gain weight. The pill is only a few calories, but you have gained weight because it has made you to eat a lot more food and move around less.
Has the "calories in/calories out" thermodynamic law been violated? No, because, as a result of your extra eating, you have taken in a lot more calories, and expended fewer. But because of the nature of these calories that you've eaten, namely those four calories in the pill that affects your metabolism, you have gained weight. If you were to stop taking that four-calorie pill, you'd lose weight.
In other words, calories in/calories out is true, but not helpful in understanding weight gain or loss. Whether or not such a pill exists, the example should show you why Calories In/Calories Out is too simplistic for explaining weight loss. If you had eaten 4 calories of pizza each morning, the results would not have been the same.
In a similar way, eating lots of carbohydrates may force your body to store energy in fat cells, which in turn makes you more likely to eat more and expend less.
How I interpret the twinkie diet is that the guy had the willpower and motivation to keep calories low, and therefore lost weight. I'll bet that he could not stay on that diet for years.