OpenSourceDPS909

Functional Programming For The Web!? No Javascript!?

Since the beginning of my journey of learning how to build software in college, I felt that the only possible way that one could build a nice dynamic website was by writing some Javascript code. However,  about 2-3 years ago I discovered Elm! Then, I believe the following year from discovering Elm I stumbled upon Purescript.

Elm_logo.svgELM is a purely functional programming language for developing web applications. Elm compiles to javascript, therefore, most of the things that you can do in javascript can be done directly with elm. Unfortunately, building backend server is not possible with elm.

 

 

 

purescript_logo

Purescript is another purely functional programming language. Similar to Elm it compiles to javascript as well. Purescript is a bit more powerful than elm it offers library for developing web servers and offers more polymorphism. The downside compared to Elm is that the learning curve is quite steep.

 

Now, I would like to continue by mentioning an important aspect of these two platforms. Elm and Purescript are both built in Haskell! I have been developing a few things in Haskell for the past 6 months, and I noticed that a lot of people would ask me “whats built in Haskell?” or “I can’t see where I would use Haskell …”.

I have tried both platforms but absolutely prefer Elm over Purescript(It doesn’t mean that Elm is better!!). I find that elm is way more beginner friendly and I would consider it maybe a nice introduction to Haskell.

I faced a small issue when developing with Elm and Haskell. I noticed that I was stuck with a non-isomorphic application.  An isomorphic application is simply an application whose code runs both on server and client side. Since I was using a library named Servant as my backend, I was able to pair it with another library that could convert my Haskell Data Structures to Elms so I would not have to recopy the same Data structures (DRY right!). However, I still did not quite feel pleased with it – nonetheless great option! But, a beautiful Haskell library called Reflex rose from the darkness to my rescue! Reflex is a Practical Functional Reactive Programming library. There is still development being done as we speak but there are still a few people using it in production! 🙂 Reflex deserves a blog of its own so I will end my first blog with this, thanks for reading!

2 thoughts on “Functional Programming For The Web!? No Javascript!?

Leave a comment