Shanty Town: +2 Actions, Reveal your hand. If you have no Action cards in hand, +2 Cards
Village: +1 Card, +2 Actions
Occasionally I've had games where both of these are in the kingdom set and I don't really know which one to choose. Village is a sure thing, but Shanty Town offers the potential of getting 2 cards with the downside of sometimes getting none. I tend to prefer Village because you usually only want +2 Action cards in a deck running a fair amount of actions, and if you have a fair amount of actions you'll probably draw one with the Shanty Town and lose the +2 card bonus. In an action-thin deck Shanty Town could be more useful as you'd get the +2 cards more often, but often it would just degrade into a Moat because you don't have many actions to draw with those +2 cards to use the actions it gives you.
When should I take Shanty Town instead of Village? Is my analysis mostly correct? When should I chose to buy/gain a Shanty Town in general if its 2 effects (one being good in action decks, the other other being very bad) seem to have no synergy at all?