The direct sum $\oplus$ versus the cartesian product $\times$ In the case of abelian groups, I have been treating these two set operations as more or less indistinguishable. In early mathematics courses, one normally defines $A^n := A\times A\times\ldots\times A$; however in, for example, the fundamental theorem of finitely generated abelian groups, we normally write that every such group is isomorphic to one of the form
$$
\mathbb{Z}^n \oplus \mathbb{Z}_{r_1} \oplus \cdots \oplus \mathbb{Z}_{r_t} 
$$
where $\mathbb{Z}^n$ now means $\mathbb{Z}\oplus\mathbb{Z}\oplus\cdots\oplus\mathbb{Z}$.
From an intuition perspective, and in the sense of sets, is this more or less the same as $\mathbb{Z}\times\mathbb{Z}\times\cdots\times\mathbb{Z}$? (Bear in mind I am normally using these ideas in relation to homology groups.)
 A: For a finite number of factors, the direct sum and direct product of abelian groups (and more generally, of $R$-modules) are equal.
However, when you have an infinite number of summands/factors, the two constructions are different. Explicitly, the direct product
$$\prod_{i\in I} A_i$$
is the collection of all functions $f\colon I\to \cup A_i$ with $f(i)\in A_i$ for each $i$ (you can think of them as the "tuples" indexed by $i$, with the $i$th coordinate being the value $f(i)$).
But the direct sum
$$\bigoplus_{i\in I} A_i$$
is the collection of all functions $f\colon I\to \cup A_i$ with:


*

*$f(i)\in A_i$ for each $i$; and

*$f(i) = 0$ for all except perhaps a finite number of $i$.


That is, the direct sum is the subgroup/submodule of the direct product that consists of the almost-null elements. When there are only finitely many coordinates, saying "all are zero except perhaps for a finite number of coordinates" is the same as saying nothing.
For categories where the coproduct is not the direct sum (for example, when dealing with not-necessarily-abelian groups), it used to be common to refer to the direct product as the "cartesian product", the "unrestricted direct product", or even the "complete direct product" or "complete direct sum" (e.g., Hungerford offers the latter as a parenthetical alternative in page 59); and to refer to the subgroup of almost-null elements as the "restricted direct product" or "weak direct product" (again, the latter is used in Hungerford).

In the category of abelian groups, the direct (cartesian) product is a product, in the categorical sense: $P=\prod\limits_{i\in I}A_i$ is a group, equipped with homomorphism $\pi_i\colon P\to A_i$ for each $i$ (the projections), with the universal property that for every abelian group $B$ with homomorphism $f_i\colon B\to A_i$ for each $i\in I$, there exists a unique $f\colon B\to P$ such that $f_i =\pi_i\circ f$ for each $i\in I$; the map $f$ is defined by letting $f(b)(i) = f_i(b)$ (remember that the elements of $P$ are maps $g\colon I\to\cup A_i$ with $g(i)\in A_i$ for each $i$; that's why we have $f(b)(i)$: $f(b)$ is a map from $I$ to $\cup A_i$, so $f(b)(i)$ is the map $f(b)$ evaluated at $i$).
The direct sum, on the other hand, is a coproduct in the categorical sense. $C=\oplus_{i\in I}A_i$ is a group, equipped with homomorphism $\iota_j\colon A_j\to C$ for each $j\in I$ (the map that sends $a\in A_j$ to the element that has $a$ in the $j$th coordinate and $0$s elsewhere), with the universal property that for every abelian group $B$ with homomorphism $g_i\colon A_i\to B$, there exists a unique homomorphism $g\colon C\to B$ such that $g_i = g\circ \iota_i$ for each $i$. 
Because the set of homomorphisms from one abelian group to another form an abelian group (under pointwise addition) and composition is bilinear under this addition, then one can prove that any object which is a product for $A$ and $B$ is also a coproduct for $A$ and $B$ and conversely, any object which is a coproduct is also a product (Theorem 2 in Section VIII.2 of Categories for the Working Mathematician, by Saunders Mac Lane); in particular, finite products coincide with finite coproducts in the category of all abelian groups, which is why the direct product and direct sum agree when there are only finite many factors/summands.
A: The direct product of groups is defined for any groups, and is the categorical product of the groups. More concretely, if I have groups $G$ and $H$, then $G \times H$ consists of the pairs $(g, h)$ of one element of $G$ and one element of $H$, and we multiply these pairs componentwise.
The direct sum of groups is only defined for abelian groups, and is the categorical coproduct of the groups in the category of abelian groups. For two abelian groups, their direct sum is the same as their direct product.
Now, if instead of two abelian groups you have infinitely many abelian groups, the notions of direct sum (categorical coproduct) and direct product (categorical product) differ. In particular, an element of $\prod_\alpha G_\alpha$ is any sequence $(g_\alpha)_\alpha$, whereas an element of $\bigoplus_\alpha G_\alpha$ is a sequence $(G_\alpha)_\alpha$ where only finitely many of the $(g_\alpha)_\alpha$ are nonzero. That is, the direct sum is a proper subgroup of the direct product, at least so long as infinitely many of the $G_\alpha$ are not just the trivial group.
By the way, the categorical coproduct in the category of groups (as opposed to the category of abelian groups) is called the free product, and is very different.
Further reading:


*

*Direct product of groups.

*Direct sum of groups.

*Categorical product.

*Categorical coproduct.

*Free product of groups.
A: For abelian groups, the direct sum is a special case of the categorical notion of coproduct. This means, among other things, that if $A, B, C$ are abelian groups, there is a natural isomorphism
$$\text{Hom}(A \oplus B, C) \cong \text{Hom}(A, C) \times \text{Hom}(B, C)$$
where $\text{Hom}(X, Y)$ is the set of homomorphisms $X \to Y$. This is not hard to see. The direct product is a special case of the categorical notion of product. This means, among other things, that if $A, B, C$ are abelian groups, there is a natural isomorphism
$$\text{Hom}(A, B \times C) \cong \text{Hom}(A, B) \times \text{Hom}(A, C).$$
This is also not hard to see. The product and coproduct naturally make sense for an arbitrary number of abelian groups, and then it turns out that in order to preserve the universal properties above the direct sum ends up being the subgroup of the direct product that Pete Clark describes.
There are at least three confusing things about this setup, at least to me.


*

*The product and coproduct agree for finitely many factors. When this happens we say the category has finite biproducts. This is emphatically not true, for example, in the category of sets, where the product is the Cartesian product and the coproduct is the disjoint union. 

*The coproduct in the category of groups, as opposed to the category of abelian groups, is not the direct sum. It is the free product, which is why the free product is relevant to, for example, the Seifert-van Kampen theorem (which is abstractly a theorem about how taking fundamental groups preserves certain colimits, of which coproducts are an example). 

*It is still possible to define the direct sum of infinitely many groups (not necessarily abelian), and this construction has neither of the universal properties above.


In any case, the fact that the product and coproduct are abstractly different should hint to you that they appear in different situations, even though they look the same. You can sometimes tell the difference by asking what happens when you extend a finite construction to infinitely many things.
For example, you mentioned homology groups. Consider the wedge $X$ of countably many circles. Then I claim that $H_1(X) = \bigoplus_{i=1}^{\infty} \mathbb{Z}$ but that $H^1(X) = \prod_{i=1}^{\infty} \mathbb{Z}$. 
A: As long as you restrict to finite index sets, the direct sum and the direct product of commutative groups are identical.
For a general index set $I$, the direct product of commutative groups $\{G_i\}$ is the full Cartesian product $\prod_{i \in I} G_i$, whereas the direct sum $\bigoplus_{i \in I} G_i$ 
is the subgroup of the direct product consisting of all tuples $\{g_i\}$ with $g_i = 0$ 
except for finitely many $i \in I$.
The coincidence of the direct sum and the direct product in additive categories can also be explained in categorical terms, but I'll let someone else take a crack at that if they so desire.  
