The formalization of all law into code fully is probably not fully achievable in the near term since there are many component parts of legal tests that are not really deterministically resolvable, and I think it would be a hard sell that justice is properly served if a call to rand() played a part in adjudication or sentencing.
I think a more profitable way to start integrating code is within the realm of contract law. A contract described in code has some advantages over even a well written legal prose contract: it's testable, components could be more easily reusable, in some circumstances it could self-monitor for breach, it's easily diffable. Such contracts could be made to be more transparent (assuming good faith and code-literacy) and less prone to purposely unenforcible clauses etc (law linter?). Some such contracts might be progressively abstracted into a genuine and good faith "standard contract" for [thing]. Of course now you need two lawyers who both can also program comfortably in the same programming language and I have to imagine the first judge to interpret such a contract is going to be pissed as hell (or more optimistically intrigued).
As far as starting from scratch all the time, we don't really do that. The US legal system was basically just forked from England at first, and within the US we have a lot of model laws that are more or less universal (look at the https://en.wikipedia.org/wiki/Uniform_Law_Commission), but we do sometimes have some weird holdouts (pretty sure Louisiana still uses some Napoleonic code instead of UCC stuff).
Edit: sorry for the wall-o-text, also just thought of IoT/semi-autonomous agents that might require the autonomy to decide whether or not to enter into a legally binding agreement on behalf of the operator without necessarily knowing ahead of time the counterparty or the exact terms. It would be a lot easier for these kind of bots if there were some generic contracting convention or DSL or something. I'm thinking trading bots and maybe of an intelligent shopping bot.