All of the modern meanings seem to be rooted in its widespread use as slang throughout the Massachusetts Institute of Technology (MIT), starting in the 1960s. There, the original meaning of "hack" was a quick, elaborate and/or bodged solution students devised for a technical obstacle; it was used with hacker, meaning one who discovers and implements a hack. The word itself comes from the German word meaning "someone who makes furniture with an axe", implying a lack of finesse in a "hack"; it is believed by many in the hacking community that the reason for this is because programs too large to run on the limited computer resources of the time had portions "chopped" or "hacked" out in order to be reduced to a more reasonable size.
See: MIT hacks
Over time, the meaning of the word there was expanded, perhaps through contact with the amateur radio community. It came to mean either a kludge, or the opposite of a kludge, as in a clever or elegant solution to a difficult problem. In the term "hack value" it also acquired a meaning of anything that was simultaneously fun and clever.
The initial hacker community at MIT, particularly those associated with the Tech Model Railroad Club, applied this pre-existing local slang to computer programming, producing the variant which first came into common use outside MIT.
In a similar vein, a "hack" may refer to works outside of computer programming. For example, a math hack means a clever solution to a mathematical problem. The GNU General Public License has been described as a copyright hack because it cleverly uses the copyright laws for a purpose the lawmakers did not foresee. All of these uses now also seem to be spreading beyond MIT as well.
The term has since acquired an additional and now more common meaning, since approximately the 1980s; this more modern definition was initially associated with crackers. This growing use of the term "hack" is to refer to a program that (sometimes illegally) modifies another program, often a computer game, giving the user access to features otherwise inaccessible to them. As an example of this use, for Palm OS users (until the 4th iteration of this operating system), a "hack" refers to an extension of the operating system which provides additional functionality. The general media also uses this term to describe the act of illegally breaking into a computer, but this meaning is disputed.
The term is additionally used by electronics hobbyists to refer to simple modifications to electronic hardware such as a graphing calculators, video game consoles, electronic musical keyboards or other device (see CueCat for a notorious example) to expose or add functionality to a device that was unintended for use by end users by the company who created it. A number of techno musicians have modified 1980s-era Casio SK-1 sampling keyboards to create unusual sounds by doing circuit bending: connecting wires to different leads of the integrated circuit chips. The results of these DIY experiments range from opening up previously inaccessible features that were part of the chip design to producing the strange, disharmonic digital tones that became part of the techno music style.
Companies take different attitudes towards such practices, ranging from open acceptance (such as Texas Instruments for its graphing calculators and Lego for its Lego Mindstorms robotics gear) to outright hostility (such as Microsoft's attempts to lock out Xbox hackers or the DRM routines on Blu-ray Disc players designed to sabotage compromised players).