We show that a minimal subset of Java 8 excluding classes supports a simple and natural programming style, which we call lambda-based object-oriented programming. That is, on one hand the programmer can use tuples in place of objects (class instances), and tuples can be desugared to lambdas following their classical encoding in the lambda-calculus. On the other hand, lambdas can be equipped with additional behaviour, thanks to the fact that they may implement interfaces with default methods, hence inheritance and dynamic dispatch are still supported. We formally describe the encoding by a translation from FJ-lambda, an FJ variant including lambdas and interfaces with default methods, to FJ-lambda-, a subset of FJ-lambda with no classes (hence no constructors and fields). We provide several examples illustrating this novel programming style.
Lambda-based object-oriented programming
Zucca E.
2021-01-01
Abstract
We show that a minimal subset of Java 8 excluding classes supports a simple and natural programming style, which we call lambda-based object-oriented programming. That is, on one hand the programmer can use tuples in place of objects (class instances), and tuples can be desugared to lambdas following their classical encoding in the lambda-calculus. On the other hand, lambdas can be equipped with additional behaviour, thanks to the fact that they may implement interfaces with default methods, hence inheritance and dynamic dispatch are still supported. We formally describe the encoding by a translation from FJ-lambda, an FJ variant including lambdas and interfaces with default methods, to FJ-lambda-, a subset of FJ-lambda with no classes (hence no constructors and fields). We provide several examples illustrating this novel programming style.I documenti in IRIS sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.