Phoenix as a Meteor alternative

Latest meteor club podcast is an interview with Chris McCord on Elixir and Phoenix.

6 Likes

I gave Phoenix a try. I like it. Iā€™m intrigued, especially by functional programming. Anyway, I tried both the projects share on GitHub by @ryanswapp and @SkinnyGeek1010 (thanks guys!)

What I kept thinking is why not just write a DDP server to talk to the Meteor client. This way one can simply start with Meteor then if performance is an issue, swap out the server without changing anything on the client.

Then I found this:

A DDP server (not client) written in GO.

@arunoda Are you guys using this? Could this address Meteor performance woes? What are the performance metrics like? Kind of crazy idea is to use this along with @martijnwalravenā€™s Meteor iOS

Edit:

Though not possible with a Go DDP server, for my own references Iā€™ll collect other interesting projects to replace mongo as well.

https://github.com/metstrike/meteor-oracle introduced by @metstrike

@numtelā€™s (and contributors like @vlasky) packages for MySQL or Postgres.


It is possible to have a ā€œMeteorā€ or DDP stack without Meteor. Just goes to show just how flexible one can be with Meteor.

I feel the same way. It seems so clean to me!

Did you by chance listen to the most recent Meteor Club podcast? If not, hereā€™s a link https://simplecast.fm/s/2f11905f21 Josh, Ben, and Sam talked to Chris McCord about Phoenix and he had a lot of interesting things to say. One of which is similar to the DDP server idea. He basically said that Phoenix channels have been designed as low level infrastructure for people to build on top of and they talked about a potential DDP layer on top of that. Interesting stuff.

Awhile back some Meteor folks tried to hook Meteor up to Elixir https://teamgaslight.com/blog/the-philae-experiment-landing-an-elixir-app-on-meteor Itā€™s a pretty interesting post. They also made a DDP client package https://github.com/cincinnati-elixir/philae.

I personally have been trying to figure out how Meteor would fit in with Elixir and have struggled to come up with viable options. The thing that Meteor is great at is abstraction. Itā€™s abstracted away a lot of tedious things like syncing data between the client and server, authentication, etcā€¦ With Phoenix, Iā€™m not sure you really need all the Meteor abstractions. If you can use tools like RethinkDBā€™s changefeeds in conjunction Phoenix channels and a state manager like Redux on the frontend then Iā€™m not sure where Meteor fits into the picture.

The other thing I wonder about is whether an Oplog tailing/Long Polling type system is really the best way to go. I really like the idea of using Phoenix as a message broker to notify all clients when things change so you donā€™t need to be constantly polling the database. Iā€™ve experimented with broadcasting events from the controller when something successfully changed and itā€™s seemed to work pretty well. Itā€™s almost kind of a lazy DDPā€¦ haha

Anyways, Iā€™m glad you like Phoenix! Even if itā€™s not something that we use everyday I think the functional world can teach us a lot about how to build better programs. My code has definitely gotten a lot cleaner since I started working with Elixir :slight_smile:

3 Likes

I feel it depends on the application for me. SQL is functional. Data is transformed as it moves from one function into another. Data is the focus. Procedural languages have their advantage too. There isnā€™t a landslide winner either way. That said, yes, Elixir is refreshing.

I have, interesting talk for sure!

Right, but the aforementioned DDP projects is a Go DDP server not a client. It means it speaks DDP to DDP clients. Be this a Meteor client w/ React or Meteor iOS.

There are some changes coming to RethinkDB that will give it full Meteor compatibility https://github.com/rethinkdb/rethinkdb/issues/4629

There are nuances that typical ā€œreal timeā€ apps often overlooked.

With a DDP Server (not client!) written in Elixir or Golang, it seems to me much of the performance problems for high-traffic application can be resolved. This further supports the idea that Meteor is indeed a very good choice in the beginning given that the problematic parts can be swapped out when needed.

To rehash: At the heart of Meteor is the DDP protocol. There are many clients that rely on a Node server; yet it is quite possible to have a server written on something else. Perhaps Golang?

1 Like

Iā€™ve been playing around with RethinkDB in Phoenix and just wrote up a post on actually using it inside a Phoenix app. I plan to follow this post up with one describing how to use changefeeds with channels to make real time applications. Let me know what you think! http://ryanswapp.com/2016/01/02/getting-started-with-rethinkdb-and-the-phoenix-framework-building-an-app/

6 Likes

By this ā€œIn a follow up post we will use RethinkDB Changefeeds and Phoenix Channels to make our app realtimeā€ I was just trying to let everyone know that Iā€™d be doing a third post on using changefeeds with channels to make the simple app we built real time. The app built in that post isnā€™t realtime (yet - the third post Iā€™m planning will make it that way). Sorry if that wasnā€™t clear!! :grimacing:

1 Like

@ryanswapp do you still plan on recording a video series on your phoenix/react/redux template? I know, law school right?

3 Likes

eagerly waiting for the video series.

4 Likes

:stuck_out_tongue_winking_eye: @jacobin @kaiyes I am still planning on the video series!! Itā€™s been a bit delayed because Iā€™ve been experimenting with different approaches to building apps with Phoenix. Iā€™d like to nail down a solid implementation before I make a video series on it.

Now, thatā€™s not to say that the template I made is a bad implementation. I just want to get a little more comfortable with the technology so I have some value to offer. Iā€™ve got a bunch of free time tomorrow. I might look at pumping out some material. We shall see :smile:

4 Likes

Elixir Fountain

I have been working my way through these podcasts while we wait. Thereā€™s 18 of them, akin to the meteor podcast series.

3 Likes

Sorry, it should have been clear. I should learn to read better :blush:

Awesome, as soon as I have some minutes, I will read it :wink:

Here is some other probably unrelated stuff, but itā€™s Phoenix with React so it will fit the picture somehow; http://blog.overstuffedgorilla.com/render-react-with-phoenix/

2 Likes

@jacobin @kaiyes Just an update. I spent a bunch of time working on a new React Starter Template (Purely client side - no backend). https://github.com/ryanswapp/react-starter-template This template is ready to go for production.

Iā€™ve decided to start a tutorial site that Iā€™m currently building so you can plan on that popping up in the next couple of weeks. Itā€™ll focus on Meteor, React, and Phoenix development. Some of the videos Iā€™m planning will discuss my new boilerplate and how its setup. In addition, Iā€™ll show how to build the template for production and deploy it to S3 or Github pages as a static site that talks to a Phoenix API hosted on Heroku.

6 Likes

I know you use webpack but thought I would mention that Phoenix 1.1.2 was released two days ago, which includes the new Brunch with npm support.

2 Likes

Ya I saw that! Had to upgrade to Node 5.4 to create a new app (which is good). Do you know if Brunch creates client bundles for you? Or is it like Grunt/Gulp where you have to run your code through Browserify?

Iā€™m really comfortable with Webpack now and it is amazing so I donā€™t think Iā€™ll be switching any time soon. I also donā€™t think Brunch supports hot code reloading?

That said, if I build an app without a React frontend Iā€™ll most likely just use Brunch

Have a look here on how to use react with the new version of brunch in phoenix: https://medium.com/@diamondgfx/phoenix-v1-1-2-and-react-js-3dbd195a880a#.sbaj68qi4

1 Like

Ya it looks pretty straightforward. The only problem is that the vast majority of the react ecosystem uses webpack so all the tools are designed around webpack. :frowning: I used to not be a big fan of webpack but now I love it! Tough learning curve for sure, but itā€™s a great build tool.

@ryanswapp There is a new phoenix react example thatā€™s been brewing the past couple weeks. Itā€™s a Trello clone. The blog is up to 4 parts now. Hopefully it has some ideas for you to use.

Elixir.
Phoenix
Ecto
PostgreSQL

Webpack
Sass
React
React router
Redux
ES6/ES7 JavaScript

2 Likes

Thatā€™s pretty cool. I hadnā€™t seen that. Thanks for sharing!

What a nice discussion! I followed Meteor when it was still < 1.0. This was when I was first leaning web development and It was the first web framework I liked, before I tried Django but the experience repelled me.

I ended not using Meteor because one of my basic needs was to serve JSON and this is/was difficult (maybe the situation has changed since). I finally when with Dart because I liked the idea of sharing code between client and server (I donā€™t think like this anymore). Ended up ditching Dart in favor of Elixir after investigating about scalability for a month (contendors where Go, Scala, C#).

Phoenix is a really nice framework that takes a lot of the good things that Ruby brought to the scene. Here are some remarks about Meteor vs Elixir/Phoenix.

Meteor

Pros

  1. Dead simple realtime with database pub/sub to live updates. This problem is hard to tackle and you have to create a lot of infrastructure to do it elsewhere.
  2. Easy to get started. Client and server on the same project.
  3. Lots of libraries.

Cons

  1. Diverges a lot from standard web dev, e.g. creating a REST API is not easy.
  2. Too much magic. This magic gets you started easily but can bite you later.
  3. If scalability becomes a problem you might have reached a dead end. Meteor is too opinionated.

Elixir/Poenix

Pros

  1. Scales
  2. Phoenix is an excellent framework for general web development.
  3. FP is an excellent paradigm.
  4. No JavaScript! Well, at least not on the server. People here favor using Elm on the frontend a lot, so even better.
  5. Fault tolerance and all the OTP goodies.

Cons

  1. If you want all the magic Meteor does with its pub/sub and automatic update system you are going to miss it.
  2. Starting isnā€™t as easy. Meteor is excellent for total newbies to web dev to get something up and running.
6 Likes