6 ms·
Building a chat app in 8 minutes with Phoenix
- m4r71n 9y agoHere is another write-up that builds the same thing (and reads a bit nicer): https://medium.com/@Stephanbv/elixir-phoenix-build-a-simple-chat-room-7f20ee8e8f9c https://medium.com/@Stephanbv/elixir-phoenix-build-a-simple-...
- minimaxir 9y agoYou can't do a build-X-in-low-Y-minutes trope when X involves implementing 30+ line classes. EDIT: This comment was not appropriate, I apologize.
- spuz 9y agoWhy not?
- minimaxir 9y agoThe build-X-in-low-Y-minutes trope implies that something is trivial to implement (usually by importing middleware that does the heavy lifting). A 30 line class is not trivial.
- always_good 9y ago> implies that something is trivial to implement I don't think it does. It shows something implemented quickly, suggesting that it's a tutorial you can sit down and follow in one go.
- BeenAround 9y agoBuild implies something other than cut-paste or git clone ./make This title is misleading. Install a chap app in 8 minutes would be more appropriate, although really it's just sensationalism.
- nathan_long 9y ago> The build-X-in-low-Y-minutes trope implies that something is trivial to implement I think it just implies that the reader can do it without prior knowledge, and that Y minutes is surprisingly small. You wouldn't write "build a blog in 80,000 minutes" even if it could be done with one line of code. And you wouldn't write "build [complicated thing] 3 minutes" and then show an expert rapidly typing a pre-determined program into an editor. If a newbie can do it in Y minutes following the tutorial, it seems valid to me.
- minimaxir 9y agoI'll agree the "surprisingly small" interpretation is more charitable.
- tudelo 9y agoSeems more like a succinct tutorial vs a "look how easy and fast this is". There are definitely alternatives with less code.
- nickjj 9y agoI'm in the very early stages of building what will be a pretty large web app with Phoenix and so far I really like it. I have a lot of prior Rails / Flask experience and minimal Elixir experience but you can still figure things out for the most part. It's kind of funny but, even at this Elixir newbie stage I feel more confident reading and tracing most Elixir code vs Ruby.
- tres 9y agoYeah, it's interesting, I've had the same experience. There's not so much magic lurking beneath the surface. Things are relatively easy to track down when you do need to figure things out; otherwise, things are pretty intuitive. And when it comes to performance, threads and queueing, not having to deal with duct-tape and gum solutions like Resque (Ruby's "One Ring" (I love it and I hate it)) makes such a big difference.
- bookercodes 9y agoGreat screencast, Alex! The best tools are the ones you don’t even notice, and Elixir is an absolute pleasure. You get to focus on the problem with little ceremony. Chat is a really interesting application of Channels, too. It’s especially interesting to me as my team and I are working on a hosted API called Chatkit that makes it equally easy to add real-time chat to your applications, no matter what technology you’re using: https://pusher.com/chatkit https://pusher.com/chatkit In addition to basic chat data, we also manage, “Who’s online”, typing indicators, rich media... And more I highlight those features in particular because I am especially curious what that would look like with Elixir and Pheonix? Managing chat data, especially at scale is quite a hairy problem. By the way, it simple/clean to subscribe to Elixir Channels on other platforms like Android and iOS, for example? One place we think we can add a lot of value is X-platform client SDKs (JavaScript, Kotlin, Swift, etc.)
- dep_b 9y agoLibraries exist for Swift and JavaScript for sure but honestly the implementation in vanilla JS wasn’t that hard.
- elcritch 9y agoYou should read Discord’s experience with Elixir if you haven’t already [1]. They didn’t use Phoenix channels though AFAIK. Also the Phoenix channel implementation uses CRDTs behind the scenes from what I gather. They make problems like user presence much more tractable [2]. 1: https://blog.discordapp.com/scaling-elixir-f9b8e1e7c29b https://blog.discordapp.com/scaling-elixir-f9b8e1e7c29b 2: https://github.com/phoenixframework/phoenix/blob/master/guides/docs/presence.md https://github.com/phoenixframework/phoenix/blob/master/guid...
- alekx 9y agoThanks! I'm glad you liked it.
- no_identd 9y agoYou likely want to read this, and my comment there: https://opkode.com/blog/slacks-bait-and-switch/#comment-3799191155 https://opkode.com/blog/slacks-bait-and-switch/#comment-3799...
- dep_b 9y agoI’ve been writing an API in Phoenix for a high message volume high user count application and it’s pretty amazing how little code I have been writing thus far. Some concepts are a bit weird like GenServer but it completely decouples your application from your state. Writing tests was intuitive and one of the few times I’ve been doing TDD that really felt faster than manual testing.
- arvidkahl 9y agoElixir turns from wonderful to magical once you grasp the GenServer concept and learn about its extensions, namenly GenStage. The producer/consumer pattern and the back-pressure logic will allow you to build incredibly scalable, resilient systems. When I first saw it in action, I was mesmerized.
- tortilla 9y agoJust finished reading "Functional Web Development with Elixir, OTP, and Phoenix" and I really like it. It gave me a better understanding of GenServer/OTP: https://pragprog.com/book/lhelph/functional-web-development-with-elixir-otp-and-phoenix https://pragprog.com/book/lhelph/functional-web-development-...
- tecknowlogic 9y agoYou seem to be on the right track. I am sure you'll find success.
- mryanmay 9y agoNice work, Alex!
- alekx 9y agoThanks!
- abledon 9y agoHas anyone used gen stage / flow for their jobs / small - medium projects ? What are some examples where this could be used ? Game server ? I found an example on YouTube about using it in an automation warehouse but that seems too niche to implement
- qohen 9y agoPeter Hastie, of sports-news site Bleacher Report, gave a talk at Erlang & Elixir Factory (2017) about GenStage (and Flow) -- there's a description of the talk and an embedded YouTube video at the bottom: http://www.erlang-factory.com/sfbay2017/peter-hastie.html http://www.erlang-factory.com/sfbay2017/peter-hastie.html
- tortilla 9y agohttps://www.youtube.com/watch?v=Aa--NDjL9SI https://www.youtube.com/watch?v=Aa--NDjL9SI In the talk by Chris Bell, (29:15) they use Flow to migrate millions of records.
- Subetai 9y agoFlow - used it at work for an odd use case where had to merge data from 3 database sources (given to me in csv format) against other data to migrate it. It involved 100s of millions of rows and lots of unknowns so flow was perfect for processing and adaptability whereas spark or many similar solutions felt a bit heavy for the use case. GenStage specifically: we needed an internal load tester and GenStage plus easy concurrency allowed to quickly build an effective and reliable tool with rate control
- ShaneWilton 9y agoWe use Elixir at Tinfoil Security for our API Security Scanner, and it uses GenStage quite a bit under the hood. It's a big simplification, but we basically have a producer that emits a stream of "scan tasks" to be performed (things like "scan this endpoint for SQL injection"), and then those are consumed by individual worker processes. It lets us super easily manage things like rate limiting and throttling, while providing backpressure so that an influx of scans (or scans on large APIs) won't overload our infrastructure.
- netsearcher 9y agoelixircasts.io is a very good resource for anybody starting out with Elixir/Phoenix.Elixir is an absolute joy to code.I wrote http://newsofworld.org http://newsofworld.org entirely in Elixir/Phoenix.
- chimen 9y agoI cried in pain when I got to securing my app (uberauth, guardian etc). There's too much to grasp and I ended-up just copy pasting code in frustration. Elixir & phoenix are fun though. I really like how much easier it is to test an elixir app (functional language).
- erokar 9y agoI agree. Django and Rails still have an advantage here.
- alekx 9y agoI'll be releasing some episodes on this in the coming weeks/months to help shine a light on this topic for others.
- enraged_camel 9y agoYou can use Coherence. It's basically Devise for Elixir: https://github.com/smpallen99/coherence https://github.com/smpallen99/coherence
- QuinnWilton 9y agoI've been coding Elixir professionally for a few years, and working in security for longer, and I recommend against using Coherence for anything but toy apps. It's a fairly full-featured Devise-substitute, but the code quality isn't great, and a lot of the less-used features haven't had any sort of real-world testing. There's been a few trivial, high-severity security vulnerabilities in it, and I wouldn't be surprised if more are hiding. For example, when I last read through the codebase it was common to find features that simply wouldn't work, because the code referenced hardcoded parts of the sample application. You'll also going to run into a lot of issues trying to migrate off of Coherence if you ever need to support anything other than form based username / password login. I think it really is worth the effort to go with Ueberauth [0]. You'll need to do more work upfront, but the maintainability gains will quickly pay off. You can even use :ueberauth_identy [1] to provide username / password based auth without too much trouble. [0] https://github.com/ueberauth/ueberauth https://github.com/ueberauth/ueberauth [1] https://github.com/ueberauth/ueberauth_identity https://github.com/ueberauth/ueberauth_identity