Phoenix LiveView Tutorial: Bootstrap Your Messenger App

Phoenix LiveView Tutorial: Bootstrap Your Messenger App

We're back with the first practical part of our Modern Talking with Elixir series, and this time we'll get the initial setup for our Phoenix LiveView-based Messenger app up and running.

We'll prepare our app for Phoenix LiveView and install all needed dependencies, design the app's Ecto schemas, related contexts, and database structure, to accommodate for the app's business logic.

To learn even more about how we'll build our Messenger app and get deeper into Phoenix LiveView, subscribe to our newsletter and await further episodes of the series!

Read more...

Elixir Trickery: Using Macros and Metaprogramming Without Superpowers

Elixir Trickery: Using Macros and Metaprogramming Without Superpowers

There's hardly any more misunderstood element of Elixir than its metaprogramming power. The way to understand it is actually not to try too hard to wrap your head around it.

Elixir is a language heavily relying on its macro mechanism, which is both powerful and limited, and both complicated and simple, at the same time. The good news is that when you get to know the simple part about it, it's very easy to start writing macros even if you're a complete noob - and I'm going to give you plenty of examples to demonstrate that.

Read more...

Modern Talking with Elixir: Messenger App Tutorial with Phoenix LiveView

Modern Talking with Elixir: Messenger App Tutorial with Phoenix LiveView

Have you ever wondered why Elixir and its ecosystem is gradually becoming the go-to platform for many web application developers who want both performance and productivity, not a tradeoff between them?

Well, we'll show you why - and we'll do it via a thorough crash course of Phoenix Framework's hot deal, Phoenix LiveView, using which we'll build a Messenger-like live chat application.

In a series of articles (don't forget to subscribe to our newsletter!), we'll convince you that Phoenix LiveView will revolutionize the way you create reactive UIs!

Read more...

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

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

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.
Read more...

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

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!

Read more...

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

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.

Read more...