# What is the difference between badness and penalty?

What in LaTeX is the difference between badness and penalty?

Are badness and penalty the same?

In what range are the values for both, badness and penalty?

Badness is something that TeX calculates based on the amount of needed stretch- or shrinkability compared to the available stretch- or shrinkability. This is valid for horizontal (paragraph) or vertical (page) calculations. The user cannot influence this computation directly; only an upper limit can be specified with \pretolerance for the first and \tolerance for the following passes which TeX executes to find the line breaks in a paragraph. Plain TeX uses the values 100 and 200 but some commands in LaTeX, like \sloppy, changes the \tolerance. (There are more parameters for badness like \hbadness and \vbadness that are lower limits for warning messages about overfull boxes.)
Penalty is something that either TeX adds to a break based on parameters that the user can manipulate or the user enters it directly into the input source. For example, two parameters in paragraphs are called \hyphenpenalty (break at an hyphen that TeX inserts) and \exhyphenpenalty (break at a hyphen that occurs in the input); there are many more, for example, in math mode. For page breaks there is, for example, the \brokenpenalty that is applied if the last line on the page ends with a hyphen. Again there are many more.
A user can enter a penalty using the command \penalty. A break at glue has no parameter-driven penalty, its penalty is 0. So the user must specify a value via \penalty if the break at this glue shall be treated differently. Often the tilde is used between words to prevent a break at glue as it contains a penalty of 10000 (no break allowed). On the other hand TeX is allowed to break at a penalty less than 10000 even if there is no glue or a hyphen.
One parameter, the \linepenalty, has a special meaning: It is added to the badness of a line in a paragraph; so it has not directly to do with a break. (It helps in many cases to keep the number of lines in a paragraph small.)