days
-6
-7
hours
-1
0
minutes
-2
-5
seconds
-1
-3
search
Interview with Ning Sun, the creator of Espresso

“As a Java web tool, Espresso sits between framework and server, just like what Servlet API did”

Eirini-Eleni Papadopoulou
Java
© Shutterstock / Sergey Nivens

Last month, we introduced Espresso, a core web abstraction for Java that aspires to become the soul of modern Java web application! Today, we invited its creator, Ning Sun to give us some insight into the tool and its functions.

JAXenter: First of all, could you please tell us a bit more about Espresso? What makes this tool special?

Ning Sun: Unlike some new Java web tools, for example, SparkJava or Javalin, Espresso is not a framework or web server at all. It sits between framework and server, just like what Servlet API did. On top of Espresso, you can design your own web framework. On the backend, you can adapt any Java web server to Espresso, without affecting the upper application.

  • It’s a light-weighted protocol, with a functional mind in design, supports composition. It borrows a few ideas from Clojure-Ring and Rust Iron. Simple and extensible.
  • It’s easier to get started than Servlet API as a web developer. The core protocol is just a function takes request and returns a response. The request and response object are almost POJOs. With Java 8 features, a hello world application is just a line of lambda.
  • It’s easier to create Espresso compatible web server, all you need to do is to provide request data to the core function and consume the response data. If you comparing it to Servlet API, you won’t need to implement web.xml, the filter, the router, and various contexts.

JAXenter:  Espresso comes with a mini-ecosystem that includes three micro-libraries. Could you give us some examples of how these libraries function and how they support Espresso?

Ning Sun: To demonstrate the usage and extensibility of Espresso, I have created some key micro-libraries.

  • Jettino, a reference implementation of Espresso adapter, is to run your Espresso application on matured Jetty web server.
  • Latte, a URL router that fits Espresso’s design. With Latte, each configured URL path will be handled by the specified Espresso handler. And after all, Latte itself generates an Espresso application.
  • Sugar, a parameter extractor that parses query string, form body and JSON body into request. As a middleware, you get sugar’s functionality by wrap your own Espresso application into its constructor. And sugar itself, by design, is an Espresso function, too.

JAXenter: You have mentioned in your blog post that the Java web ecosystem is still rather underdeveloped. Why do you think this is the case?

Ning Sun: Till today, the core of Java web ecosystem is still Servlet API. It’s pretty advanced at its era. Modern ones like SparkJava, Javalin or Play didn’t define a protocol or interface for developers. So there is the risk to lock-down to the framework. Servlet defined a common, independent protocol between web frameworks (structs, spring) and servers (tomcat, jetty). Thanks to Servlet, you can run your spring application on either of tomcat, jetty or undertow and so on.

SEE ALSO: Introducing Espresso, a core web abstraction for Java – The future of Java web ecosystem?

However, the Servlet API is complex. It uses XML or annotation for configuration. It has the concept of Filter, Session in its core. It often blurs the boundary between a protocol role and a framework role. For example, Spring MVC uses Servlet API simply as a protocol, the DispatcherServlet.

JAXenter: You have also noted the rapid evolution of Java lately. Speaking of which, I would like to ask for your opinion on the new Java release cadence. Do you believe this change had a positive impact on innovation coming in more rapidly in the Java ecosystem?

Ning Sun: I’m 100% in for the new release mechanism. I feel it gives Java the language and the platform another birth. Features like jlink, zgc are really promising and will bring more scenarios for Java. With the new release schedule, we get the feature earlier and feedback frequently. That’s how open source software should be developed in the 2010s. I’m looking forward to seeing the whole community, the tools, Maven, Gradle to catch up with the latest features.

JAXenter: Finally, what should we expect from Espresso and its mini-ecosystem for the future? Do you have some plans in motion and how can someone contribute to your project? 

Ning Sun: I hope the announcement is just a start for Espresso, as a community project and an ecosystem. There’s already a developer that got in touch with me and wants to join the development. I’m pretty busy with my day job, so I welcome more developers to join the project and work on it together to evolve it.

A few issues have been created in Espresso Github issue tracker for libraries and adapters. More importantly, I hope we can have a discussion on how to run the project and grow the ecosystem. So if you like the idea of Espresso, please join me on our mailing list.

Thank you!

Author
Eirini-Eleni Papadopoulou
Eirini-Eleni Papadopoulou is an assistant editor for JAXenter.com. Just finished her masters in Modern East Asian Studies and plans to continue with her old hobby that is computer science.