How to define $[-\infty, \infty]$ or $[0, \infty]$? I am familiar with basic undergraduate topology. For example, I know the process of one point compactification of a non-compact topological space, and how it applies to, say, $\mathbb R^2$. My question is:

Can I define and topologize $[-\infty, \infty]$ or $[0, \infty]$ in a similar way? 

If so, how to describe a continuous function from some topological space $X$ to this $[-\infty, \infty]$ or $[0, \infty]$?
Moreover, will $[-\infty, \infty]$ or $[0, \infty]$ be compact?
 A: In order to carry out a one-point compactification, you start with a topological space. So you have to decide what topology you're going to give $[-\infty, \infty]$ and $[0, \infty]$. 
One possible topology you could give $[0, \infty]$ is to give a subbasis consisting of stuff like $[0,a)$ and $(a,\infty]$. That would give you the normal topology when you restricted to $[0,\infty)$. Similarly for $[-\infty, \infty]$ give a subbasis of $[-\infty, a)$ and $(a, \infty]$**. 
These are both going to end up being homeomorphic to $[0,1]$, and so compact. Hint: find an explicit homeo by playing around with the arctangent function.

**If I topologize $[0, \infty]$ this way, it is the one-point compactification of $[0,\infty)$. But $[-\infty, \infty]$ is not the one-point compactification of $(-\infty, \infty)$, because I added two points.
A: The following holds: 
Theorem: let $(X,<)$ be an ordered space in the order topology. Then $X$ is compact iff for every $A \subseteq X$, $\sup(A) \in X$ exists. For a proof, see this post. 
Note that this implies that $X$ is Dedekind-complete (i.e. every non-empty subset $A \subseteq X$ that has an upper bound in $X$ has a supremum in $X$). But compactness is stronger, as $\sup(\emptyset) = \min(X)$ must also exist, as does $\max(X) = \sup(X)$. But this is all that we need: 
Corollary: $(X,<)$ is compact iff $X$ is Dedekind complete and $\max(X)$ and $\min(X)$ exist. 
Left to right we just showed, and if the right side holds, let $A \subseteq X$. If $A = \emptyset$, $\sup(\emptyset) = \min(X)$ exists by assumption. So assume $A \neq \emptyset$. Then $A$ has an upper bound, namely $\max(X)$, so $\sup(A)$ exists by Dedekind completeness. So $A$ is compact by the previous theorem. 
Now, if $(X,<)$ is any linearly ordered space in the order topology, it has an essentially unique Dedekind-completion $(\tilde{X},<)$ that $X$ is a subset of and whose order extends that of $X$. This uses Dedekind cuts as in the construction of the real numbers from the rational numbers. The most general form (for partially ordered sets as well) is the Dedekind-Mac Neille completion.
It also has the property that $X$ is dense (topologically) in $\tilde{X}$.
If $\min(X)$ already existed, it's still $\min(\tilde{X})$ as well, and likewise for $\max(X)$. If a minimum does not exist in $\min(\tilde{X})$, we add a new point $-\infty$ to it, and for a maximum, if we don't yet have it, we add a new point $+\infty$. We then keep the order on $\tilde{X}$, and also define that $-\infty < x < +\infty$ for all $x \in \tilde{X}$. 
This new set, $\tilde{X}$ (the completion) with 0,1 or 2 points from $\{-\infty,+\infty\}$ added as needed, is the ordered compactification of $X$. So it's a two step process in this construction: first take a completion for almost all subsets of $X$, and then the above corollary says we're almost there: we need a max and a min too. We then get a compact ordered space $o(X)$ with an order extending that of $X$, and such that $X$ is dense in it. One can show it is essentially unique as well. Here we just care about existence.
For your two examples: $[0,\infty)$ is already complete (so the first step does nothing) and then we add a maximum $+\infty$ as $\min([0,\infty) = 0$ already exists. So then we have that the ordered compactification of $[0,\infty)$ which here coincides with the one-point compactification (as we only added a single point). And $\mathbb{R}$ is also complete and has no max or min, so we add them and get a new compact ordered space $[-\infty, +\infty]$ which is topologically just the unit interval $[0,1]$, as $(0,1)$ is both topologically and order-isomorphic to the reals, and its ordered compactification is likewise easily seen to be $[0,1]$.
