Relays were replaced with vacuum tubes early on, then transistors. Small personal computers became possible with the invention of the integrated circuit, which can place many many transistors onto a single, small chip of silicon.
We will discuss how electronic switching is used in computing later, but first we'll cover the basics of the hardware technology that makes electronic binary logic possible.
Vacuum tubes are simple, electronic devices through which electrons -- and, hence, electricty -- flows through a vacuum. The most basic tube consists of a cathode and an anode inside of the vacuum tube.
Heating the cathode energizes the electrons in the metal filament there. The electrons leave the cathode and jump into the surrounding space. As negatively charged electrons leave, they are attracted to the positively charged anode.
(Diagram from Vacuum Tube Basics, where you can learn more about vacuum tube operation.)
It's possible to control the flow of electricity by adding a grid between the cathode and anode. When a negative charge is applied to this grid, electrons from the cathode are repelled and cannot travel to the anode and, so, no electrical current can flow across the tube. This control grid acts as an electronic on-off switch. This on-off switching function is a necessary component for digital computers.
The next step of electronics development involved materials called semiconductors. At the most basic level, semiconductors are materials with an electrical conductivity somewhere between conductors (such as metal wires) and insulators (such as rubber or glass). What makes semiconductors useful for electronics is the ability to control the electronic properties and conductivity through "doping," which is adding small amounts of other elements to the semiconductor.
Early crystal radio receivers used a Cat's whisker detector. These detectors used a thin wire touching a semiconductor crystal to pick up radio signals. These early semiconductors were unreliable, however, and were soon superseded with vacuum tube technology.
A Bell Labs researcher studying radar technology at the outbreak of World War II accidentally invented the first semiconductor diode in 1939 when he purified semiconductor crystals used for Cat's Whiskers. After nearly another decade of concerted effort, the first semiconductor transistor was demonstrated at Bell Labs in 1947.
Later research showed the transistor could be used like a switch like a vacuum tube. Transistors are much smaller than vacuum tubes, use significantly less power, are more reliable, and (eventually) less expensive to manufacture. It didn't take long for hobbyists and computer engineers to figure out they could create smaller computers with transistors instead of vacuum tubes.
Vacuum tubes use tremendous amounts of energy to keep the cathodes hot, and they were fragile, with thin filaments prone to burning out. Semiconductor materials enable much more reliable electronic devices that use much less power.
Transistors are used with other types of discrete electronic components such as resistors, capacitors, and diodes and connected with wiring and printed circuit board circuit traces to create electronic devices such as radios, calculators and computers. When you see the green (usually, but they can be brown, red, or yellow) circuit board with big gobs of solder inside of an an electronic house thermostat or a toy R/C car, most of the electronic parts stickup up from one side of that board are discrete components.
The next big step in electronics miniaturization was the development of the integrated circuit, which we'll cover in the next lesson.