Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are an employee at a tech company whose job is to analyze programs written b

ID: 3826402 • Letter: Y

Question

You are an employee at a tech company whose job is to analyze programs written by the various departments throughout the company and help them optimize their code. Your team’s specialties include helping eliminate unreachable code and reducing the size of of programs in memory. A tech consultant is telling your CEO they have a special, proprietary algorithm that is guaranteed to (1) eliminate all unreachable code in programs and (2) reduce all programs to their most efficient in memory representation (i.e. with respect to code size). Your CEO is considering purchasing access to this algorithm, potentially threatening your position as a program optimizer! Prove that the product the tech consultant is trying to sell your CEO cannot exist by showing that both (1) and (2) are impossible for an algorithm to do optimally for arbitrary programs. (HINT: show that optimally solving these problems would require solving a problem that is already known (i.e. proven) to be undecidable... perhaps the halting problem, ...)

Explanation / Answer

In programming, optimization of code plays a major role in code readability. There is a belief that code written by an experienced programmer is 2-4 times greater than code generated by the compiler which optimizes code automatically.

Most programmers don't complain about optimizations performed by the optimizer, some of which are conventional and obligatory. Such as, for instance, tail call optimization in functional languages it is a special recursion which can be represented as a loop.

However, one should understand that multiple complex optimizations at the level of machine code may cause a great slow-down of compilation. The benefit they allow you to gain may be much too insignificant, when compared to general system design optimizations. One should also keep in mind that modern languages, with all their syntactic and semantic "frills", so that a programmer should take care while optimising the code.