Coding In Elm-lang

Coding In Elm-lang

Hi All.Hope you are all good.

Recently i had the chance to rewrite some sections of code i had written in javascript over to elm and wanted to share my experience with it.

I had been experiencing an issue where a web dashboard which was being used for monitoring of a service was receiving information too quickly thus causing the dashboard to become unresponsive.

the use case seemed like a good fit for elm where i had to rewrite a specific section of the dashboard so i decided to try out elm for this use case and see how it goes

Elm is a static functional programming language which is mostly used on the frontend which boasts having no runtime exceptions.

I will skip the parts about the setup,installation of elm since that was quite easy and simple for the most part. That can be easily done by reading this page on the elm-lang website.

first impressions on my usage of elm

  • what surprised me first about elm was the deep use of the type system as well as the ability to create custom types.

    the use of types as variables in the program was interesting.types were not just to be used as specifications/signatures which had to be satisfied but could be used as variables in the program.this was interesting.

  • the type signatures were a form of testing on their own.

    this reduced the amount of tests you may have to write later on and gave you some form of confidence in your code.

    you may have to write other tests but at least the ability of your code not to crash not just theoritically is a great confidence booster.

  • the compiler was interesting.a very strict teacher :).it was sometimes difficult to create the types which satisfied the compiler. this may lower productivity if you have to always be fighting with the compiler to find out the correct types. on the flip side you get not to deal with some class of runtime errors

  • tea(the elm architecture) was interesting and somewhat familiar in the sense that processes in the erlang programming language share a similar structure.

    In that language processes (which are an abstraction over functions) get events from various sources which are then processed by combining the local state with received events state to create new state.

  • there was a noticable increase in performance which i hadnt observed with the previous frontend library which i was using

    previously i had used jquery/javascript to write some code which was appending data to onscreen content. when the data was coming in too quickly the dome updates got hung up,was lagging and the screen content become unresponsive. with elm i had no such hung ups.the screen was displaying the data beautifuly with no lag and the screen wasnt unresponsive. was quite painless.

    I did not change the whole code base to elm but a specific section of the codebase was changed. this gives you ability to incremetally integrate elm into your code base which was nice.

Well,its been interesting so far. Comparing short term developer productivity as in dynamic front end programming langauges with static languages which give you quick market products vrs long term code refactoring,confidence in no runtime errors,etc can be an interesting challenge.

Another thing to consider is if you do manage to get the customers and with money rolling in you can now refactor your code?? hmmm.will that be possible at that is point easily without a rewrite??hmmm.

all these constraints which happen on a daily bases are up to the team and management of course. merging business and technical requirements are about weighting prons and cons based on each companies peculiar circumstances.

Anyway adios and happy frontend coding!!! will give more updates as i learn more about elm.


Read more