Elixir: setting up environment

One of the first things that is required when starting with new (programming) language is… to have compiler/interpreter installed and prepare the environment. Cliche…

I am happily using nvm (for NodeJS) gvm (for Go) and rvm (Ruby) for quite a long time, and I started looking for something similar for Elixir and Erlang.
I wasn’t very lucky at first, as my first approaches were not really successful. It was mainly due to the fact that I am happy user of fish shell, and I don’t want to give up using it (even in favor for zsh).

I think I am this kind of a person who really tries to makes everything complicated ;) Even though I could have Elixir and Erlang easily installed issuing something as simple as sudo apt install erlang elixir I am not really keen on doing that. Two reasons:

  • in most cases versions of the compilers/interpreters in system repository are really not the latest (and that gets worse and worse as time passes by)
  • in such a scenario (installing programming language using system repository) it is not possible to have many different versions of a specified compiler / interpreter installed. And sometimes it is a must (maintenance of some old application etc.)

asdf to the rescue!

Back in summer 2016 I was quite successful using hybrid approach. I have used asdf (github.com/asdf-vm/asdf) for Erlang and kiex (https://github.com/taylor/kiex) for Elixir. Asdf was required only to get specified version of Erlang (as this is required by Elixir). Asdf was not accessible for me via fish - so I had to use bash for asdf and to have Erlang version of choice installed. Luckily kiex was running all fine under fish. The whole thing was not super convenient (switching between fish and bash etc.) but it worked.
The whole thing didn’t bother me that much, and I have been using such approach for quite a while. Today - as I was trying to set up environment on another machine - I have realized that asdf does support fish shell right now :) What a nice surprise. It all became so easy right now.

Asdf seems to be much more flexible than the other version managers that I am using. Asdf does not focus on one particular language. There is a concept of plugins for asdf which allow it use asdf for managing versions for many different languages. Installing plugin(s) is the second thing you will have to do right after you have asdf installed. But if you get to that point, installing new version of Erlang becomes as easy as:

asdf install erlang 19.2

which (to me) is as simple as sudo apt install erlang but, of course, using asdf has advantage of installing specific version(s)!

Asdf is very simple but powerful. All your version management is literally under your fingertips.

So, if you’re like me, and you like to have 100% control of the versions of compilers installed - please try asdf. This is a great tool!

I am actually thinking if it would be a good idea to try asdf for managing NodeJS, Go and Ruby versions (oh, and I am planning to get my hands dirty a bit with Clojure and Rust in the nearest future, and asdf supports these as well…)

Caution: dependencies

It is essential to study erlang plugin home page. It brings a lot of info on dependencies that are required to have Erlang offer everything. I haven’t paid enough attention first, and ended up with environment I wasnt able to run obser (or debugger). This particular issue is easily fixed by installing dev version of wxwidgets library (and rebuilding Erlang, unfortunately…).

So if you encounter “wxe_driver.so” related error whenever you try to launch observer/debugger - you know what to do :)

Elixir

Having Erlang installed, and being familiar with asdf, bringing Elixir on board is piece of cake (assuming you have elixir plugin for asdf installed first):

asdf install elixir 1.3.4

Elixir installation is much, much faster than Erlang.

Disadvantages of asdf

The only disdvantage of asdf I can think of right now is that installing new version of Erlang does take time. Why? It is not as simple as just retrieving binary from some repository. Source code for specific version is being downloaded and then built. It all take several minutes on my machine - but hey, how often do you install new version of your favorite compiler? Personally I think that flexibility described is worth waiting from time to time to have a specific version of the language installed. It is important to note that removing version previously installed is almost instant.
Note: after adding additional libraries (wxgtk-dev among others, so that I can start observer and debugger) compilation time now takes significantly longer. It is the price I am still willing to pay for the flexibility that asdf brings.

After a quick break from writing this blog post, I realized that there is one more thing which I don’t particularly like about asdf. Installing a new plugin requires one to go to asdf project site on github and check what is the plugin repo url - when you have it, a simple asdf plugin-add elixir https://github.com/asdf-vm/asdf-elixir.git (for Elixir) will do. I’d rather have possibility of doing all that via command line. But that a really minor thing.

Sidenote:

I have also tried using kerl (github.com/kerl/kerl) for Erlang and kiex (github.com/taylor/kiex) for Elixir, but it was not all that convenient as asdf with 2 plugins. I am not sure if it was due to the fact that I wanted kerl and kiex to run under fish shell… but as asdf works so well for me right now - I am no longer looking for any alternatives.

Summary

I am happily using asdf with Erlang and Elixir for quite some time, and frankly speaking I started thinking of giving up on other solutions, such as nvm, gvm, rvm etc. Why would I bother with so many different tools/scripts if I may have just one (plus couple of additional plugins)?
The advantage of having asdf replacing all other version managers is that I don’t have to remember about differences in command line arguments / switches.

One thing may may not be that easy to achieve using asdf with its NodeJS plugin: having specific version of NodeJS installed with all the plugins from current (or yet another installed version). I am using this approach quite often, as I have to have some global pacakges installed (for example: to make hexo, yeoman work). Using nvm this is as simple as: nvm install v7.4.0 --reinstall-packages-from=v7.0.0. It sees that asdf-nodejs (https://github.com/asdf-vm/asdf-nodejs) doesn’t support such a behavior.

Linkr - description of the project

This week I have been preparing for starting work on my Linkr project. I have been thinking about functionalities, and what mechanisms the project should support. What I have planned so far is:

Milestone 1:

  • any user should be allowed to add a link (URI) + short description of the resource
  • any user should be able to search (the search mechanism should look for the search term in the description and the URI itself)

Milestone 2:

  • user should be allowed to add tags
  • user should be allowed to sort filter links by tags

Milestone 3:

  • user should be allowed to create an acount - i.e. only registered users should be able to add new links (that whould be a change to what is M1)
  • only owner should be able to change description of the link (I think it should not be possible to remove added links)

Milestone 4:

  • user should be able to see only links of tags of interest (global filtering for logged in user)

Mileston 5:

  • ‘likes’ - users should be able to sort links starting with those which were given the highest rank in the category. I am not sure how the sorting should actually work. I guess it should not sort all the links within particular tag - that would be a nonse, as it could happen that old link were displayed on the top all the time. Maybe it should be as follows: “sort by date first (descending) and then after the ranking”?

Milestone 6:

  • users should be allowed to use rss/atom - so that they’re constantly updated with new links being added

Milestne 7:

  • users should recieve email notification on new links - this option should be configurable, so that it is possible to receive a notifaction in following scenarios:
    • no notifications at all
    • after there is a new link added
    • daily
    • on a specific day/time of the week (I am not really sure about that. I am not 100% sold to that idea, as I don’t know if such a flexibility is important. It may as well be fixed as - Friday 6PM GMT or something alike)

If I were to sum the whole idea of the project - I’d say that it is something like ‘delicious for a group of people’. I have a strong feeling that this could be useful for a group of people who may be exploring a specific area of knowledge, and this would be a nice thing to share their finding among the group.

Why Elixir?

In my first blognote related to this years edition of “Get Noticed” I have mentioned that I am planning to develop web application using Elixir & Phoenix. Why Elixr?

I have a chance to develop web applications using variety of technologies: C# + ASP.NET & ASP.NET MVC, Python + Tornado, Ruby on Rails, JavaScript + NodeJS + Angular, Meteor (using Blaze as the frontend technolgy). Some technologies were more and some were less “developer friendly”. If I were to sum up what technolgies were the most fun to use I would say: RoR and JavaScript frameworks. MetorJS was a bit more fun, but NodeJS + Angular + MongoDB is something more solid, and still used even today (apart from the fact that teams are migrating from Angular 1.x). C# + ASP.NET/ASP.NET MVC were a bit less fun, altghough ASP.NET MVC was much better and I liked it a lot more than classic ASP.NET. What I didn’t particularly like about MS tech stack was that it was more of a blob than just language + technology stack. What I mean is that it is rather impossible to create something more complicated NOT using Visual Studio. Generators (as yeaoman, rake etc.) were not available at that time, so there was not a chance to use something else for working with code than Visual Studio. Everything was IDE driven. If there was a need to add additional fields to a database, or create new tables - all these actions were invoked from withing the IDE. It was so much different to the approach I could take develiping applications with pure JavaScript or Ruby. Having powerfull command line tools I felt I had more control over the process of application development. And I also had the feeling that I understood better what is happening and why.
So - the first thing would be “openess” or simply - technology being open source. Or even free - in terms of leaving all the decisions to the user.

Scalability

My personal opinion is that web applications are facing different problems that 10 years ago. Succesful applications right now often get extremely popular in a very short time. This means that it is important to design application with scalability in mind. And that is not so easy. The number of problems one has to face when it comes to designing scalable app is huge: beginning with responsiveness of the frontend itself, scalability of the workers, session management, and (probably the most complicated) picking up proper approach related to data storage. These are all non trivial problems.

Elixir is based on Erlang virtual machine. Erlang on the other hand is a language developed in 1986 by Swedish company Ericsson. Erlang was born alltogher with OTP - Open Telecom Platform - which was used to to control switches (as far as I understand at the beginning the aim was to control and connect phone calls). Erlang is being described as general purpose, concurrent, fault-tolerant & functional programming language. The concurrency in Erlang is achieved by using actor model, which is extremely interesting concept. In short - Erlang is capable of spawning hundreds or even mant thousands of processes in a very short time. These processes are much lighter than OS processes, and are controlle by Erlang VM. Important thing is that Erlang comes with a lot of tooling for controlling processes. Elixir as a language based on Erlang benefits from all that.

As I see it nowadays - scalability becomes more and more important in the are of web applications development. Elixir seems like a perfect fit here. Why not Erlang itself? Well - partially because Elixir syntax seems more appealing to me.

Functional Programming

I have a strong feeling that functional programming is one of the most important concepts that each and every developer should deeply grasp. I was taking some Scala and Haskell courses back in the past, but I lacked a proper “battlefield” to test my knowledge. I want to make an effort this year and develop my skills in the area of functional programming. What better opportunity than creating an application using functional programming language?

Mature technology

I have already mentioned that the technology Elixir is based was created back in the 1986. It means that it is more than 30 years old. Quite a lot of time to prove its maturity.

Friendly community

What is unique in Ruby community is its openness and friendliness. I had zero problems solving problems I bumped on, when developing my RoR applications. A lot of resources are available, and people in general are very happy to help someone who is not familiar with the technology.
I have the feeling that the same is true about Elixir community. Maybe it is due to the fact that a lot of people who are interested in Elixir have Ruby background, but I am not sure if this is the (only) case.

Hype

Hype may not be the best word… I have a strong feeling that there is a lot of interest in Elixir. Not only from the developers but also from companies. More and more companies are evaluating Elixir and check if it is a good fit for their needs. I see a constant rise in interest of hiring people who are familiar with Elixir. And this interest is no longer only from the companies located on the West Coast of US - there are more and more companies using Elixir located in Europe. I treat the whole adventure as an investment for the future.

Get Noticed 2017 - start!

Some as last year - this year another edition of “Get Noticed” initive is being started. The whole idea is quite simple - to blog about a project - software that will be developed during the next couple of months (all starts beginning of March 2017, ends in May).

Last year I tried to take part in it, but due to some unpredicted things happening - I was not able to devote enough time for it, and didn’t manage to finish the application. I hope this year is going to be different and that I will be able to share quite a lot of thoughts & decisions related to application development.

My idea for the application is still the same - I want to create a simple web application that will allow people to share links to interesting resources. That’s it. Simple stuff. I hope that as time goes by I will implement more and more features for that.

So… as the idea for the application itself stays the same as last year - you may want to read a post about it from last year: Let them know you

One thing is changing this year though - I have picked different language (or should I actually say - technology stack?). Last year my choice was to use Ruby+Rails. I was a total newbie with Rails&Ruby at that time, and apart from going through some tutorials I haven’t created any application on my own using RoR.

So what’s my techonlogy of choice this year? Wel… this year it is going to be Elixir+Phoenix. I haven’t made any other decisions yet. I am not sure what storage I am going to use. I am not sure if I am going to use ReactJS, AngularJS, VueJS or any other fancy technology for the frontend itself, or if I leave it as a pure Phoenix frontend. I hope to make all that decisions while developing the application, and will try to document my choices here - on my blog.

Let them know you!

Interesting idea has spread in Poland among software developers recently - it is called “Let them know you” (“Daj się poznać” in Polish). It is all about developing an open-source project, and blogging about it for ~3 months (roughly twice a week).

I thought that as I don not have a lot of time - it is the best idea to join it!

Couple of years ago, I was working for a company which had a very cool thing happening - it was called “Something new, something interesting, something cool”. It was a weekly digest emails containing links to articles, blog notes etc. which were found interesting/worth sharing by some developers. These links were then put into an email by one person, and sent to all interested within the company.

I was so bought by this idea that I have even started doing this on my own in one of the companies I was working next. At some point I have realized that doing it all manually was the biggest disadvantage of the whole idea. I happened to forgot about including some links. I have also forgtten couple of times to send the email…

There were also other problems:

  • there was no easy way to search through all the links that have been sent
  • newcomers were usually not aware of this initiative at all - someone had to tell them about it
  • when a new person wanted this email digest to be send to them - I had to update the distribution list… again a 100% manual process

Taking all these things under consideration - myself and my friend Cyryl(github: https://github.com/cyplo blog: https://blog.cyplo.net) started thinking about starting a project that would solve some of those problems. In the end of 2014 we have created a scaffolding of the Ruby on Rails project, but… after the initial couple of commits we have ‘forgotten’ about it, and for about a year we haven’t contributed to it at all. Recently I have decided to resurect the project, and push it forward. And the “Let them know you” initiative seems to be the perfect opportunity to be more devoted in working on the project.

The github repository is located under the following location: https://github.com/curalink/curalink