I am taking a course based on Nand2Tetris and we are tasked with building a game in Jack. I intend to build a version of breakout. Instead of having objects tightly coupled to each other, I wanted to implement a publish/subscribe pattern in which objects communicate via a central EventsBroadcaster object. Objects would subscribe to events via EventsBroadcaster.subscribe() and publish events via EventsBroadcaster.publish(). When an event is published, EventsBroadcaster would look up every object subscribed to that event and call its on() method. That method would have the signature on(String event, Data data) where Data is just a dummy class. In reality any object could be passed via data and the receiving object would just have to "know" what fields to access. I thought that maybe this would work because of Jack's lack of type checking, but I suspect that this will result in symbol lookup problems. If Jack will not support this, is there any way to implement something close to this in Jack?
Re: Does Jack support any version of polymorphism?
Jack does not support polymorphism or subclassing, so it is impractical to write code based on object hierarchies. You will be really glad that it doesn't when you are writing the Jack compiler in projects 10 and 11!
To write games in Jack you need to go old school and write a service loop that checks the keyboard and calls state based screen update code.
Look at nand2tetris/projects/11/Pong to see a simple example.