title: Are Kotlin inline functions less expensive than Java anonymous classes?
body: <p>Heads up: I'm writing some of this from memory so I may have some of the concepts incorrect. </p>
  
  <hr>
  
  <p>Java has the ability to write an anonymous function. This is useful when you have a listener interface for some kind of event. As an example: </p>
  
  <pre><code>button.setOnClickListener(new View.OnClickListener(View v) {
      @Override
      public void onClick(View v) {
          // handle the action here
      }
  });
  </code></pre>
  
  <p>The anonymous listener will be compiled as a class that is called something like <code>OnClickListener$1.class</code>. This is an underlying design decision of the Java language. Everything is an object, even anonymous functions. </p>
  
  <p>This becomes an issue when you want to write a more functionally driven code base. The large amount of anonymous classes creates a large class count, which can be a problem on constrained platforms such as Android. </p>
  
  <p>In Kotlin functions are much more first class from a source code point of view. My question is, does Kotlin compile these functions down to byte code more efficiently than Java does with anonymous classes or will I run into the same issues as the large class count in Java? </p>
  
  <p>Thanks, </p>