Curiosum Blog

What's the difference between alias, import, require and use in Elixir?
  • Elixir

What's the difference between alias, import, require and use in Elixir? A complete guide with use cases

In most programming languages we often deal with instructions responsible for handling dependencies. Elixir is no different.

In Elixir, dependency is nothing more than compiled module which for some reason you want to use in another module. There are a couple of instructions that we use in Elixir to either make it easier or possible to interact with modules.

In this blog post I'll explain and present use case examples of four of them:

  • alias,
  • require,
  • import,
  • use.
A girl receiving new message

Sign to our Newsletter

We're committed to your privacy. Curiosum uses the information you provide to us to contact you about our relevant content. You may unsubscribe from these communications at any time. For more information, check out our privacy policy.

How database transactions work in Ecto and why Elixir makes it awesome?
  • Elixir

How database transactions work in Ecto and why Elixir makes it awesome?

Today we're going to look at how Ecto, which is Elixir's first-choice database access library, addresses the issue of handling database transactions. We'll briefly introduce you to the very concept of transaction, then focus on describing the Ecto way of handling them, and explaining how it feels superior to what other languages' libraries offer us in this department. We'll give plenty of examples corresponding to a simple app you can pull from our GitHub repository, so you can have some fun testing it out!

Elixir Trickery: Cheating on Structs, And Why It Pays Off
  • Elixir

Elixir Trickery: Cheating on Structs, And Why It Pays Off

While we can't say cheating on anyone is okay, we're not as absolutistic when it comes to cheating on Elixir at times.

Structs are there for a reason (we'll start from a brief overview), and that's certainly not for us to cheat on them. But we can if we have to - and we'll sometimes even justify that and get away with it!

Today's article will come in handy especially for those who are interested in developing libraries for Elixir and making them usable across different dependency versions, which is always a problem when writing code intended to be pluggable into different applications.