Classes as a compilation unit
- by Yannbane
If "compilation unit" is unclear, please refer to this. However, what I mean by it will be clear from the context.
Edit: my language allows for multiple inheritance, unlike Java.
I've started designing+developing my own programming language for educational, recreational, and potentially useful purposes.
At first, I've decided to base it off Java.
This implied that I would have all the code be written inside classes, and that code compiles to classes, which are loaded by the VM.
However, I've excluded features such as interfaces and abstract classes, because I found no need for them. They seemed to be enforcing a paradigm, and I'd like my language not to do that. I wanted to keep the classes as the compilation unit though, because it seemed convenient to implement, familiar, and I just liked the idea.
Then I noticed that I'm basically left with a glorified module system, where classes could be used either as "namespaces", providing constants and functions using the static directive, or as templates for objects that need to be instantiated ("actual" purpose of classes in other languages).
Now I'm left wondering: what are the benefits of having classes as compilation units?
(Also, any general commentary on my design would be much appreciated.)