Creating JVM language [PART 16] - Ditching statics

Sources

OOP and statics

What is the the greatest advantage of object oriented programming?
In my opinion it is polymorphism. How do you achieve polymorphism?
By using inheritance. Can you use inheritance with statics? No, of course not.

In my opinion statics violate the object oriented concepts, and should
not be included in truly object oriented languages. Instead of using statics
objects you are way better just by using singletons.

So why would Java call itself object oriented when there are statics?
My theory is that for some historical reason they wanted C++ guys to adapt to Java quicker and “lure” as many as possible into java world.

Switching to purely non-static world

Until last post (about object creation) all Enkel classes were purely static.
They consisted of main method and other static methods. The reason behind this
was to first implement all basic language features like variables,conditional statements,loops,
method calls, and then move to OO. The time has come to start implementing OO.

What about main method?

All Java programs need to have static main method defined. The way Enkel handles this is as follows:

INVOKESTATIC vs INVOKEVIRTUAL

There is one important difference between both of them - INVOKEVIRTUAL requires owner.
INVOKESTATIC pops arguments off the stack. INVOKEVIRTUAL pops owner off the stack
and then it pops arguemnts. It’s mandatory to generate owner expression.

If there is no owner provided by a programmer the implicit “this” var reference is provided: