BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Haskell Web Framework IHP Aims to Make Web Development Type-Safe and Easy

Haskell Web Framework IHP Aims to Make Web Development Type-Safe and Easy

This item in japanese

Created at digitally induced, the Integrated Haskell Platform aims to be an opinionated framework bringing Haskell type-safety to server side rendering combined with fast development.

IHP is based on Warp Web server and uses an ORM as its persistence layer. IHP uses nix to simplify the installation process, including its integrated database, compiler, and development environment. Digitally induced claims you can build your first web application using IHP in 20 minutes, thanks also to IHP Code Generator, which aims to give you a jump start with Haskell code, and Database Schema Designer. IHP uses its own HTML markup DSL, which is called HSX in analogy with React JSX, but which is transformed to type-checked Haskell code as a previous step to HTML generation.

InfoQ has spoken with digitally induced CEO Marc Scholten to learn more about IHP.

InfoQ: Can you explain what was the main motivation behind IHP creation?

Marc Scholten: At digitally induced we develop many complex software solutions with our clients and partners. While working through the software lifecycle we could see certain problems happen over and over. Especially quality issues when working with very dynamic languages and issues related to package-management. So we set out to solve these problems.

While a lot of people think that the choice of programming languages does not matter, we believe that technology choices vary in power and have a strong impact on the product. We have looked at a lot of different technologies and found Haskell to be a great fit for our aim of highest quality software engineering and developer happiness.

While Haskell is a great language, we could not find a really good framework to work with. We have been looking for something opinionated, well documented, and easy to get started with. After evaluating some solutions we decided to build it ourselves.

The same process lead us to pick nix as our primary package management solution: We want our developers to be able to switch projects very quickly. We intended to make a completely standardized development environment. You should be able to clone a project and be ready to start it with a single command. We aimed to get rid of everything that needed to be done manually. The Nix package manager was just the right tool to make this possible.

InfoQ: IHP strives away from the recent and ever more common approach of generating your UI inside the browser, relying instead on server-side rendering. How do the two approaches stack up against each other in your view? What are their benefits and downside?

Scholten: There is certainly a case for single-page applications. For example when doing very interactive things, like web-based 3D tools or when working with interactive charts.

What we see right now is that a lot of developers choose to build single-page applications without thinking about the costs and tradeoffs. Single-page applications take a lot more effort to develop because additionally to handling the application state in your backend, you also need to do all of the state handling at the client. Obviously, this leads to a lot more code. And therefore more code to maintain. This leads to a lot more bugs and slowed down application development.

In our experience, many applications built right now as an SPA could be built faster and more stable as a server-side rendered application. The recently launched hey.com is a great example: the application is very interactive, yet it’s not a single-page app.

When you have a specific part of your application that is very dynamic and cannot be implemented as a server-rendered application, you can still build a small encapsulated SPA just for that specific page. This hybrid approach has worked very well for us and we believe that this is the way forward in building great web applications.

InfoQ: Which advantage does Haskell bring to the web development, in your experience?

Scholten: In practice the biggest advantage of Haskell is type-safety. Compared to e.g. NodeJS, this results in significantly fewer bugs per LOC. We practically have no runtime errors. And when it’s time to make big changes, you can easily refactor your Haskell application without breaking anything. This helps a lot when you are building new features at a fast pace. We evolved from moving fast and breaking things to just moving fast.

Many programming language ecosystems are moving into the direction of more type-safety, e.g. with TypeScript or the recent developments in the PHP world. We have worked with a lot of different technologies, and nothing really compares to Haskell in this aspect.

InfoQ: What is IHP level of maturity and production-readiness?

Scholten: IHP is already used in production by digitally induced and our partners. The overall application architecture of IHP has been refined in many iterations before we have open-sourced the framework. Additionally, IHP is built on top of battle-tested Haskell libraries, such as the warp web server. Therefore you can expect this to be pretty stable and scalable for large projects already.

IHP has been described as Haskell on Rails by Haskell engineer Matt Parsons on Twitter. While criticizing a few design decisions in IHP, Parsons considers it a useful endeavour:

It's fresh energy in the ecosystem with a strong focus on developer experience. It's a Rails port, which we don't have and we could definitely use. It opens the door for Haskell in other places.

IHP is available on most operating systems, including macOS, Linux variants, and Windows via its Linux Subsystem. You can get it on GitHub.

Rate this Article

Adoption
Style

BT