Metaprogramming is a powerful, yet pretty complex technique, that means a program can analyze or even modify itself during runtime. Many modern languages support this feature, and Elixir is no exception.
In one of my previous articles I wrote about Erlang Term Storage tables (or simply ETS), which allow tuples of arbitrary data to be stored in memory. We also discussed disk-based ETS (DETS), which provide slightly more limited functionality, but allow you to save your contents to a file.
In my previous articles we have discussed various Elixir terms and written a hefty amount of code. What we have not discussed, however, is how to structure and organize your code so that it is easy to maintain and release.
When crafting an Elixir program, you often need to share a state. For example, in one of my previous articles I showed how to code a server to perform various calculations and keep the result in memory (and later we’ve seen how to make this server bullet-proof with the help of supervisors).
In this article you will learn the basics of concurrency in Elixir and see how to spawn processes, send and receive messages, and create long-running processes. Also you will learn about GenServer, see how it can be used in your application, and discover some goodies it provides for you.
Polymorphism is an important concept in programming, and novice programmers usually learn about it during the first months of studying. Polymorphism basically means that you can apply a similar operation to entities of different types. For instance, the count/1 function can be applied both to a range and to a list:
In my previous article we were talking about Open Telecom Platform (OTP) and, more specifically, the GenServer abstraction that makes it simpler to work with server processes. GenServer, as you probably remember, is a behaviour—to use it, you need to define a special callback module that satisfies the contract as dictated by this behaviour.
Working with the file system in Elixir does not really differ from doing so using other popular programming languages. There are three modules to solve this task:
Path. They provide functions to open, create, modify, read and destroy files, expand paths, etc. There are, however, some interesting gotchas that you should be aware of.
Do you want to learn the Elixir language? If so, our new course, Get Started With Elixir, is ideal for you.
Elixir is a very young programming language (emerged in 2011), but it is gaining popularity. I was initially interested in this language because when using it you can look at some common tasks programmers usually solve from a different angle.
Exception handling is a great practice for any software development methodology. Whether it’s for test-based development, agile sprints, or a hacking session with just a good old todo list, we all can benefit from ensuring our bases are covered with a robust approach to defect handling.