BLOG

Switching from C# to Elixir – a programmer’s story

Sometimes programmers need to change the language they use for software development. Find out how it was for our developer to switch from C# to Elixir.

Sometimes programmers need to change the language they use for software development. Whatever the reason – requirements of the project or simple curiosity – this process can be difficult, especially if the new language is radically different in terms of syntax and paradigm. Recently I had to make the switch from my favourite language, C#, to a language that was completely new to me, Elixir. What came of it – is told further.

Here at Diatom, we strongly believe that Elixir is “The Next BIG Thing”!

Prehistory

After successfully completing the previous project, I was asked whether I wanted to try something new. As you probably guessed, I agreed without hesitation and started to download the code for the Elixir project, on which programmers had already worked for some time.

First impressions

While I was downloading the project source, I decided to read more about Elixir online. To my great surprise, it was an Erlang-based language with no C-like syntax, and it was very difficult to understand. I decided to postpone the analysis of the language and began to launch the project. For obvious reasons, my much loved Visual Studio environment did not suit working with the Elixir code and I decided to install Atom editor and several plug-ins in order to work with it, which provided a comfortable working setup. The installation of extra software didn’t create any problems in terms of running the project, although it took some time because before that developers worked only under Linux (and I had Windows). After some minor configuration, I launched the web server from the command line (command «mix phoenix.server»), and the project successfully appeared in the browser window.

Then it was time to study the basics of the language. The syntax was difficult to understand, but I had years of experience in software development, Google and my work colleagues to help me. This was my first experience working with a language based on a functional programming paradigm rather than OOP, so I spent a lot of time familiarizing myself with the development life cycle and code structure.

Two months later

After few weeks, I felt relatively comfortable working with Elixir. I understood why this language was chosen for the project – creating channels to communicate client-side code with the server side and doing broadcasts are very easy in Elixir. These features were very important because it was a chat project. For C# in such cases developers mostly use SignalR, but this is slower than Elixir with Phoenix Framework solution.

As a modern language, Elixir works perfectly with JSON and has its own ORM and package manager.

What I did not like

  • No C-like syntax;
  • Query is ORM technology for Elixir, which despite its power, is not convenient to use (but other aspects of the language partially compensated for this);
  • Elixir lacks the powerful IDE of Visual Studio.

What I liked

  • Elixir is designed for easy and flexible work with parallel processes (it is simply difficult to overestimate all the possibilities);
  • List and Map data types provide exceptional ease of data management;
  • Tuple data type that allows you to easily control the branching of logic based on the call function results;
  • Ease of work that is provided by different operators for working with data;
  • Highly convenient documentation using the @spec keyword;
  • Сode execution speed;
  • Functions overloading based on parameter values;
  • Pipeline of operations that really reduces the amount of code that needs to be written.

Conclusion

Elixir is an extremely powerful language with a wide range of possibilities. However, for programmers who have worked extensively with C #, making the switch can be fairly difficult. Although I don’t regret the time I devoted to learning Elixir and I plan to continue working with it, I ‘m not planning to leave C#. I can recommend to anyone who works with C#, Java, Delphi or a similar language that they at least learn the basics of Elixir to experience an alternative code writing approach.

Previous
Next