Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm building my startup in phoenix.

First of all I wanna say that Clojure is a fantastic language and if the dials on my particular needs were different, I would have gone with Clojure and am considering clojurescript for a subproject paired with an elixir backend.

When I started the project, realtime over WebSockets were a huge consideration. Additionally, we weren't doing anything revolutionary from a computer science perspective. Phoenix came in with a clear story for all the work I wanted to accomplish.

There were well accepted and documented libraries for doing authentication and a really nice library for accessing the database.

The language has few gotchas and is relatively easy to learn. I have no doubt I could take a good js or python developer and have them be proficient within 2-3 weeks. Thats a big deal for when we are ready to onboard more people.

The elixir language feels a lot like clojure with a ruby like syntax. you have maps(structs) and a similar theme of 100 functions on one data structure. When sketching an idea, I can build my data structure out as a map and delegate to functions based on specific properties within the structure just the same as you would in Clojure. The language supports hygenic macros though I have been content with using the ones provided by absinthe and the kernel.

Phoenix itself is Extremely composable. Yes there are some constraints imposed by the language but no where near what you'd find in a more magical framework like ruby. In every case I've run into, I've been able to granularly pull and modify whatever functionality I've needed. middleware for instance is oriented around plug. Plug consists of a struct that contains data pertaining to the http request and response. ALL middleware is a function that takes a plug struct and returns a plug struct. Its about as composable as you're going to get. The end result is a very stable system that is really easy to reason about.

The biggest advantage, however, has been the deployment and infrastructure story. OTP is fantastic and lets us create workers about as easily as you could create a controller in rails. This is big. for our mvp, we don't need to setup redis or rabbitmq nor deal with the headaches of configuring them in prod. I can create a pubsub worker that responds to events and broadcasts data to the users in real-time and stay completely within phoenix.

Of course it has its downsides. For one, its definitely not my language of choice if I was doing image processing or constraint solving. At some point, we are going to create other microservices that handle those kinds of tasks better and when it happens, we'll have to pull in rabbitmq or kafka. Obviously phoenix can't have isomorphic apps like you would find with clojure and javascript.

TLDR: if you're trying to do something really novel, go with clojure. Its a much more flexible language with some really neat libraries that you'll need to learn to integrate yourself. If what you're doing is CRUD but with realtime, elixir will give you a great base ecosystem with sensible defaults to get off the ground fast.



There is another type of application where Elixir/Erlang really shines. The most obvious example of this type of application is a web based game where you have thousands of instances of the game running at once. The concurrency and isolation model is pretty much a perfect fit for this.

I was trying to hack something together in Java that wouldn't kill the database. Queries to table x would bottleneck, then table y. Add some caching here and there as each problem cropped up. But the obvious design in Elixir just removed most of the problems - each instance of the game works as its own set of processes and each instance holds what it needs in memory. It's not that I couldn't have arrived at this model with Java eventually, but it doesn't exactly lead you there, and a language like Elixir/Erlang was basically built with this in mind so everything is a lot easier to accomplish than with something like Java.

I really think everyone should learn either Elixir or Erlang. There are certain applications where OTP and BEAM just makes everything so much easier than the alternatives. If you have the right problem it can be an insanely productive language.


I had one case where I needed to store account data and ended up storing it in a gen server object for each account which pushed its state to all devices logged into that account. It was so easy to build I forgot about it but this 4-hour project would have taken over a week if I had done it in any other language.


Thanks for chiming in.

It helps to better understand the use case for each language.

I like the way you put it: Elixir = CRUD but with realtime.

Maybe I'll end up learning both, but have to start with one.

Hey and good luck with your startup. It reminds me of what PG wrote about - i.e. choosing the right tools to build your business matters [0]

[0] http://www.paulgraham.com/avg.html


You'll actually find it pretty easy to learn both. Elixir was very inspired by Clojure, so it works similar to it in a lot of ways. It is like taking Clojure and removing the Lispy aspect from it (which to me is the biggest downside of Elixir, as I love Lispyness, but that also makes it more approachable and familiar to people without a Lisp background).

The biggest difference will actually lie on the host platforms. Learning BEAM and Erlang standard library Vs learning JVM and Java standard library.

For complenetess, I want to point out there is also a Clojure variant running on BEAM/Erlang called Clojerl found here: https://github.com/clojerl/clojerl

Development is pretty active, and I think it is approaching maturity pretty soon.


> When I started the project, realtime over WebSockets were a huge consideration. Additionally, we weren't doing anything revolutionary from a computer science perspective. Phoenix came in with a clear story for all the work I wanted to accomplish.

Incidentally, my app uses websockets and real-time updates based on RethinkDB changefeeds.

But more to the point of this thread, one of the major advantages is that I use a single language for both client-side code that runs in the browser and server-side code that runs in a JVM. Same language, same data structures, no impedance mismatch, no crippled transit format. All the domain code is shared between both environments.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: