Is it possible to use a transistor with AC? if you put a diode in there so no current flowed through it when the current reversed, but what could I do about the difference between the base and collector?
Yes, there are several ways to build an "AC switch" entirely out of transistors.
two diodes and two transistors
You can put a diode in series with the collector of one (nFET or npn) transistor that conducts when the "hot" line of the mains is positive relative to "neutral", so when the CPU turns on that transistor, the transistor turns on the light bulb during the positive half-cycles. (zero electrons flow through this diode+transistor connection when the transistor is off, or during the negative half-cycles).
You can put a diode in series with the collector of another (pFET or pnp) transistor that conducts when the "hot" line of the mains is negative relative to "neutral", so when the CPU turns on that transistor, the transistor turns on the light bulb during the negative half-cycles. (zero electrons flow through this diode+transistor connection when the transistor is off, or during the positive half-cycles).
Normally the CPU would either turn both transistors on, or both transistors off.
The "neutral" line and the emitter of each transistor are all connected, and the CPU power supply and the gate of each transistor stay within a few volts of neutral.
This approach may be simplest to understand, but in practice other AC switches have lower net cost.
two transistors and a bunch of diodes
You can put a pnp and a npn transistor together so the combination acts identical to a SCR. (See the Wikipedia SCR schematic).
Then you can use a bunch of diodes to steer the current so the SCR can turn on and off both the positive and negative half-cycles. (See the Wikipedia SCR dimmer schematic).
You'll need to use transistors that can handle voltages higher than your average mains voltage and also currents higher than your average load current. Your favorite supplier should be able to hook you up with several kinds of transistors that meet that criteria. You might also look at a triac or IGBT or a solid-state relay -- they have (in effect) several transistors combined into a convenient package.
Timing the off-to-on transition or the on-to-off transition to occur close to the zero-crossing (when the voltage across the transistors is close to zero) puts less stress on the transistors, so they stay cooler.
Much like the acronym LASER has become an ordinary word "laser", the acronym "TRIAC" has become ordinary word "triac" -- both "TRIAC" and "triac" refer to the same thing.