title: Reducing C++ code size
body: <p>I am working on a dynamic language (that compiles into C++) for microcontrollers, being a CS guy I decided to do it properly first then worry about optimization. Below is how my object system is structured,</p>
  
  <pre>
  <code>
  
  Base (Interface)
  |
  |---- Number (Interface)
  |      |
  |      |-- Int
  |      |-- Float
  |
  |---- Char
  |
  |---- Sequence (Interface)
  |      |
  |      |-- LinkedList
  |
  |---- Function (Interface)
        |
        |-- Built-in Functions (Functors)
  </code>
  </pre>
  
  <p>Now that everything is working generated code size started to be a problem, every operation has to be represented by a functor, (+,- while,for etc..) so I am guessing that is causing the bump in code size or I pass everything as base class then cast as needed so I have a lot of casts, currently a simple led on/off loop is costing 15 kbytes even though it doesn't use all object types (6 functors + 4 integers).</p>
  
  <p>I have tried various avr-gcc options that did not reduce code size. So I am wondering how can I figure out which part of the code is consuming so much space?</p>