Design of Library Interfaces (Student Talk)
Flatline is a library in Scala which provides a simple EDSL to implement extensible and modular command line argument parsers and simple REPLs in a declarative and typesafe way. I will talk about the design decisions for the flatline library.
The modularity flatline can provide to applications is impressive. It is so easy to setup an application to expose a complete new set of commands to the command line. If the Play framework implemented the CLI argument parser with flatline, Play could easily let applications provide custom CLI commands or even whole subcommand branches which are then used to, for example, mockup the UI for a demo version without infrastructure or automatic UI tests.
Other CLI libraries have either relaxed syntax and semantics (as seen in scopt and scallop), use reflection (see JewelCLI) or use meta programming (see sbt’s REPL). Dependent types give us independence of runtime and platform features to ensure typesafety and do not require AST manipulation. The more restrictive syntax and semantics allow for more freedom in choice of the parsing strategy.
The EDSL is implemented with object algebras which benefits the library in multilple ways. First, it helps us to decouple library interface and implementation. Second, it tightens semantics and reduces the amount of (bad and good) programs that compile. It is now safe to assume that modules written in flatline are free of unpredictable side-effect and can be worry free composed. Besides that, the library interface itself is extensible and can be enriched with new features.
The design choices made for flatline allow easier maintenance of the library itself and applications written in flatline. The requirement for platform specific code erases and interface and implementation are decoupled. This makes our applications more portable, maintainable, and extensible in the long term. Flatline shows exemplary how important the design of a library interface is.
Sun 22 Oct
|15:30 - 15:52|
|15:52 - 16:15|
|16:15 - 16:37|
|16:37 - 17:00|