Play Framework
August 20, 2020Play Framework does most of what all the other web framework seems to me doing. It has some performance magic underneath, I suppose. Specially because of immutability and async abilities. It has Scala for support. That should make it awesome to use. The first hello world programs scare you because you don’t know what is happening. There is an Action wrapping a method that returns an OK wrapper. But the more you look at it the more familiar it becomes. The action is an request to response mapping. The controller is an object, not a class. No classes and less state make it easy to reason about. There is not a lot of configuration or registering you find in other frameworks. There is url mapping to controller. There is no dependence injections. Dependency injections are for objects with state. This is mostly method calls. You can get the request object as an implicit parameter. There is a configuration file, you can put anything there. There is all the usual ways of merging configurations. Separate configurations for different environments. The database drivers and urls are also there. The DAO is also an object. The mthods are static. We put domain in case classes. You have to make the business logic independent of the controller but it can access the database any way it wants. The controller just returns a result. Mostly OK result. But all sorts of HTTP results. The results are based on HTTP status codes. That is why they say it does not hide HTTP from the application like some Java frameworks do. Also it is cool to return a case class instead of one number. The helper methods in DAO use some kind of SQL. They are easy to configure. Any library is easy to add. But there is also a way to add lifecycle things to application during on start and on stop. This is a stateless server after all. Authentication can be done by wrapping it in an authenticated class. You have to do some easy configuration. There is templating language. It is a function. It translates to a function. You can serve other things. You can do thing asynchronously. Guess this works like NodeJS. Form handling is also cool. One form object you pass around which can or cannot handle things. Parsing JSON is easy but I don’t understand the syntax behind the configuratoin but configuration is easy. It is also some implitit thing involved. Using documentation to build along is easy, I think