Do they just sit there unconfirmed (e.g. when you be evil and don't pay a tx fee) forever? Or do they get deleted after a few days?
Most clients on the network have a transaction pool in their memory. The same basically applies to miners: they just dump the top 500KB (or some other value) transactions into a block, sorted by transaction fee (descending, of course). When there aren't many transactions, maybe because of a series of block in a short amount of time, it will be confirmed anyway.
But to answer your actual question: yes, transactions (sort of) expire. When you send a transaction, it sends a
tx frame to all connected peers. These peers store the transaction in their memory pools and tell all their connections that they have a new transaction. When those connections don't have it yet, they ask for it, and that's how a transaction spreads over the network.
At some point every node in the network will have the transaction in their memory pool, and at that point it will no longer be sent over the network. Now when a user restarts their client, the memory pool is wiped, and the transaction is deleted from that computer. (Plus a few other ways to delete transactions from the pool)
Because of that it's very unlikely for the transaction to be gone from the entire network, but in case it does happen: the reference client will automatically re-send the transaction every x hours(/minutes?) when it's still not confirmed.
Oh, and I forgot the most important part: transactions on Bitcoin (
tx frames in the protocol) don't have a 'time' field, which means that transaction expiration can't be a feature of Bitcoin.
To summarize: yes, the transaction can expire, but that is really unlikely.
I recently sent 0.03 BTC to Satoshi Dice without a tx fee from a blockchain.info wallet. It stayed for about 3 days without being confirmed and it finally expired. At some moments while the tx was unconfirmed the network propagation was dropping to 2 nodes and then going back up to about 50 nodes. After it expired the sum of the transaction was added back to my balance. Any details of the transaction disappeared from my wallet and from the block explorer... Several hours after the expiry a new transaction has been issued automatically with the same amount to the same Satoshi Dice address.