8. For a convex 2017-gon with unequal side lengths, color each side using one of four colors: red, yellow, blue, or purple, but no two adjacent sides can be the same color. Then the total number of ways to color the sides is
8. $3^{2017}-3$.

Consider the case of a convex $n$-sided polygon, let the number of different coloring methods be $p_{n}$.
It is easy to know that $p_{3}=24$.
When $n \geqslant 4$, first, for side $a_{1}$, there are four different coloring methods. Since the color of side $a_{2}$ is different from that of side $a_{1}$, there are three different coloring methods for side $a_{2}$. Similarly, for sides $a_{3}, \cdots$, side $a_{n-1}$, there are three coloring methods each. For side $a_{n}$, use three different colors that are different from the color of side $a_{n-1}$, at this point, it also includes the case where it has the same color as side $a_{1}$, and the number of different coloring methods where side $a_{1}$ and side $a_{n}$ have the same color is exactly the number of different coloring methods for a convex $(n-1)$-sided polygon, $p_{n-1}$, hence
$$
\begin{array}{l}
p_{n}=4 \times 3^{n-1}-p_{n-1} \\
\Rightarrow p_{n}=3^{n}+(-1)^{n} \times 3(n \geqslant 3) \\
\Rightarrow p_{2017}=3^{2017}-3 .
\end{array}
$$