system
Given the following post, respond as if you're commenting on Reddit:
human
I am a student and when i was done learning for my chemistry test i was wondering how people measured atom masses, for example magnesium (Mg) has a mass of 24,3U (according to my textbook) How did scientists scale the weigh of an atom?
gpt
It's easy to forget what was known historically, and what we've learned recently, and answers like "just use a mass spectrometer" forget that the atomic masses were known long before mass spectrometers were invented.  It was all worked out by comparing weights of reactants and products, and using logic and math.

Here's a simplified "toy" example.  Suppose you react some hydrogen gas with chlorine gas to make hydrogen chloride.  You play around with the mixture, and find that you get a complete reaction, with no hydrogen or chlorine left over, if you start with 35 grams of chlorine for every gram of hydrogen.  From experiments that react hydrogen chloride with other things, you're pretty sure it has 1 atom of hydrogen and 1 atom of chlorine -- it's HCl rather than H2Cl or HCl3 -- and so this tells you that chlorine atoms are 35 times heavier than hydrogen atoms.

Now you do some other reactions, say hydrogen chloride with sodium hydroxide to form sodium chloride (table salt) and water.  You find that mixing 40 grams of sodium hydroxide with 36 grams of hydrogen chloride gives 58 grams of salt and 18 grams of water.  This is a more complicated reaction, but you can use the known masses of hydrogen and chlorine to find the unknown masses of sodium and oxygen .... and you continue like that through the periodic table.