I am implementing a DSL, which will generate Java classes and methods. Because of the nature of the language, it will be separated into a runtime and a generated library, which the runtime will operate over.
I have two options for implementing this library, and am wondering if either is a known better practice.
Option 1: My language code blocks all map to classes. This means generating a large number of classes, many of which will be inner classes, to implement nested scoping. The outer classes will be instantiated via reflection from the runtime, and the inner classes will then be directly constructed and utilized.
Option 2: My top level language constructs map to container classes. Nested constructs will map to methods within the container classes, which will be invoked by reflection from the runtime.
So, the main question is - which will perform better, if there is a significant difference?
For practical consideration, we're probably looking at a comparison between approximately
Option 1: 50,000 classes (10,000 outer, 40,000 inner) Option 2: 10,000, with 4 methods each, to be invoked via reflection
Aucun commentaire:
Enregistrer un commentaire