On PowerJava: "Roles" Instead Of "Objects"
By Geertjan-Oracle on Jan 05, 2013
While looking for a good candidate language for creating tutorials around language support using the NetBeans APIs, I recently came across the PowerJava project.
I was kind of curious about the background and purpose of this language and so contacted Fabio Filippi, from the Università degli Studi di Torino, the developer behind the language (pictured, right). I asked him a couple of questions.
Hi Fabio, how did PowerJava come to be?
I started working on PowerJava in 2011. This language was thought up by Guido Boella and Matteo Baldoni. It was initially sketched out by Erik Arnaudo in his bachelor thesis, but he didn't finish the work and used Java 1.3 grammar. I completely changed the code and the patterns used, using Java 1.5 grammar, and added relationships and other solutions. With that thesis I took the highest grade, 110/110 and honors.
And what does PowerJava consist of?
PowerJava is a role-oriented extension of Java 1.5. "Roles" substitute "Objects" as first-class citizen. Roles lead to being able to add "Relationships" as primitive entities of the language, reducing the gap between object oriented languages and relationship oriented languages (like SQL).
This is the pattern used to implement Roles:
This is the pattern us to implement Relationships:
There are many new reserved words in PowerJava:
- definerole: the type of a role
- role: the interface of a role
- relationship: the type of a relationship
- from/to: role of the binary relationship
- outer: institution of a certain role
- that: actor of a certain role
- tuple: tuple of a relationship
- universe: table of all relationship
- playedby: interface that can play a certain role.
Why are Roles necessary and what do they have that Objects don't?
Roles are necessary when talking about a reality that changes, such as a society. Objects are too static to represents situations like institutions and users. For example, a guest becomes a user that becomes a customer.
Here are two examples:
- The first is without relationships, Persona.pj; here part of it is displayed in the NetBeans PowerJava editor:
- The second, Unito.pj, extends the first by adding relationships:
The second example solves problems such as "how to check if the student and the professor are in the same school?" and "how to know that a professor is not a student of him/herself?" and "where to save votes that are of a couple (student,course)?"
Finally, in Printer.pj you can find a more standard example.
What's the current status of PowerJava?
To be honest, I'm not using PowerJava anymore. I abandoned the project and haven't seen my thesis professor since that time. He probably also left the project. I developed PowerJava for my bachelor thesis and now I'm writing my masters thesis on a different subject.
Nevertheless, thanks for the interview Fabio, PowerJava has some really interesting concepts! (And it's perfect as the basis of NetBeans editor API, i.e., lexing and parsing, tutorials.)