This is a brief review on modeling genetic codes with the aid of 2-adic dynamical systems. In this model amino acids are encoded by the attractors of such dynamical systems. Each genetic code is coupled to the special class of 2-adic dynamics. We consider the discrete dynamical systems, These are the iterations of a function F:Z2→Z2, where Z2 is the ring of 2-adic numbers (2-adic tree). A genetic code is characterized by the set of attractors of a function belonging to the code generating functional class. The main mathematical problem is to reduce degeneration of dynamic representation and select the optimal generating function. Here optimality can be treated in many ways. One possibility is to consider the Lipschitz functions playing the crucial role in general theory of iterations. Then we minimize the Lip-constant. The main issue is to find the proper biological interpretation of code-functions. One can speculate that the evolution of the genetic codes can be described in information space of the nucleotide-strings endowed with ultrametric (treelike) geometry. A code-function is a fitness function; the solutions of the genetic code optimization problem are attractors of the code-function. We illustrate this approach by generation of the standard nuclear and (vertebrate) mitochondrial genetics codes.