Classes as a compilation unit

Posted by Yannbane on Programmers See other posts from Programmers or by Yannbane
Published on 2012-12-18T23:26:15Z Indexed on 2012/12/19 5:13 UTC
Read the original article Hit count: 181

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.)

© Programmers or respective owner

Related posts about java

Related posts about programming-languages