Foreword

As you’re holding this book, starting your journey into the world of Elixir and Phoenix, I’m very excited for you! You’re about to discover a technology stack that can help you start your projects very quickly and move forward at a steady pace. At the same time, the technology will help you deal with highly complex challenges at a large scale. With Elixir and Phoenix, you’ll get a combination of a simple-start technology and a long-run one, a perfect combination that was out of reach just a few years ago.

In the summer of 2010, I started using Erlang, the technology that’s the foundation of Elixir and Phoenix. Back then, Erlang was one of the few available languages suitable for the challenge we were facing. Erlang made it simple for us to implement a real-time push server, requiring a surprisingly small amount of code. The initial prototype, which could manage tens of thousands of simultaneous users, required about 200 lines of code!

Over the next few years, I developed a love-hate relationship with Erlang. I was blown away by its first-class support for massive concurrency, scalability, and fault-tolerance. Writing highly concurrent code never felt so easy and natural. Our system scaled beautifully, and it kept the impact of errors to a minimum, preserving most of the service at any point in time, self-healing as soon as possible. But at the same time, working with Erlang felt tedious in many ways, with basic tasks, such as creating a new project or deploying to production, requiring a lot of manual steps. The code itself seemed burdened with a lot of boilerplate, and the language made it difficult to flush that boilerplate out. Finally, the ecosystem was much smaller than it is today, which required reinventing a lot of wheels.

I remember having mixed feelings about Erlang back then. I really felt (and I still do!) that it is the soundest foundation for building any sort of a backend side system (which includes any kind of a web server). However, the lack of tooling and libraries made the task of building such systems with Erlang harder than it should be. People used to joke that Erlang made hard things easy, but at the same time it made easy things hard.

Things started improving with the arrival of Elixir, which, compared to Erlang, seemed more focused on developer productivity, shipping with simple-to-use tools, and promoting first-class documentation. In addition, as a more complex language, bringing to the table additional features such as metaprogramming and pluggable polymorphism via protocols, Elixir allowed me to be more expressive, better organize my code, and reduce boilerplate. And at the same time, targeting the same runtime and being semantically close to Erlang, Elixir could reap all the great benefits of Erlang, and seamlessly use everything from its ecosystem (standard library, OTP, third-party libraries, and tools).

As the adoption of Elixir increased, its ecosystem expanded. The introduction of Plug and Ecto paved the way for the Phoenix framework, which finally got us to the point where we could quickly start building a typical web-facing CRUD, without needing to reinvent a bunch of wheels in the process. Phoenix quickly gained traction, and people started using it in production. As a result, the core team developers gathered a lot of feedback, which helped them evolve the tool further. Some original ideas were abandoned and some new ideas introduced, and currently Phoenix seems quite different from it’s early days, or even from the 1.0 release. But at this point, it feels that we’re past the initial development stages. The amount of deprecations and disrupting changes seems to decrease with each new version. It’s always hard to predict the future, but I don’t expect significant deprecations in future versions.

Therefore, I feel that the time to start learning Phoenix has never been better. The framework is mature and stable, the community is large and helpful, the technology has been used in various systems, and many good patterns and practices have been established. And on top of all that, there are many learning resources available, such as this book.

Back in early 2013, when I first started using Elixir, there were no books about it. Instead, I’d read the reference documentation and post questions to the mailing list, where most of the answers would be given by José Valim, who was pretty much the only qualified person to answer any Elixir-related question at the time. When Chris McCord first announced Phoenix, there wasn’t even a reference document available. Learning to work with Phoenix required a combination of trial and error, reading the Phoenix code, and asking around on mailing lists or IRC. This learning process had a certain charm, but it was definitely far from perfect. As a result, a lot of the early code written with Elixir and Phoenix was ridden with weird approaches and techniques. It took some time and a lot of strayed paths before the early adopters became familiar with these tools and understood how to use them properly.

But you don’t have to go through the same trials and tribulations. By starting your Phoenix journey now, you can avoid the mistakes made by the early adopters, and immediately start learning about proper ways to use the tools. This is where I see the biggest value of Phoenix in Action. This book will teach you the mechanics of the technology, but more importantly, it will explain how to think in Phoenix, by discussing established patterns, practices, and approaches. In addition, by cleverly avoiding the trap of writing a big reference book of epic proportions and carefully choosing which topics to discuss, Geoffrey makes your bootstrap experience smooth and easy. You won’t learn everything there is to know about Elixir and Phoenix, but no book can do that for you anyway. What you will learn, though, are the most important pieces you’ll need in pretty much any web-facing Elixir system, regardless of its shape and size.

This is why I’m really excited for you. For many of us, the learning road was long and winding, but you’ve arrived at the party at the perfect time. Having this great book to bring you into the exciting world of Elixir and Phoenix, you’re off to a good start, and your journey is about to become much more exciting. I wish you a lot of fun on that journey!

—Saša Jurić, author of Elixir in Action

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.60.166