I have this arbitrary career goal: I want to make a back end that serves millions of requests and does it blazingly fast. Having been a Rails developer for most of my programming career, I’ve been branching out to learn a new language. As you can see from my past posts, I was dabbling with Golang. I even wrote http://gruuub.com with it. It’s fast for sure, but I wanted to see what else was out there.
Functional programming is weird. I tried to do an exercism.io in Elixir and utterly failed. After that, I decided that some reading was in order. I bought Programming Elixir and started reading it, and that helped a ton. I could actually write some Elixir code after that. Nice. On to making a web app!
Phoenix is an MVC framework heavily inspired by Rails. In fact, I found that a lot of features of Rails are already present in Phoenix. Migrations, the awesome router we all know and love (albeit slightly different), even the flash. It’s a full-featured web framework for sure. Getting it up and running equally simple. Install Elixir, install Phoenix, generate an app, create your database, and run
mix phoenix.server. Pretty simple.
A Test Drive
I tried utilizing the database, but failed. I created 3 models with migrations, but ultimately failed to implement the controller actions for them correctly, so I scrapped it and just used mock data. But holy Batman, making those models and migrations was dead-simple because of the generators.
If I were 1) using the database and 2) serving from a real server (not localhost), I’m guessing this would be slower. But I don’t think it would slow down that much. Here’s the server log with response times:
Behold, MICROSECONDS. Have you ever seen that
µ symbol in a server log before? My team mate had to Google it. Yeah…lightning fast.
Phoenix is lighting fast but is still just as productive as Rails. More to come when I get something working in production. You should also hire QuickLeft to make something with Elixir so I can get paid to work with it more.