Live data from Hacker News

Phoenix 1.3.0 Released

phoenixframework.org

41–50 of 143 posts

Re: Phoenix 1.3.0 Released

#41
post #17

Earlier quoted context omitted.

It's more Rails than Django but once you've seen one MVC framework you've seen them all. I'd suggest: https://pragprog.com/book/phoenix/programming-phoenix In structure it reminds me a lot of the very first Rails book co-authored by DHH. It's a good way to get into the language/framework.

Thanks for the link. One thing I hated about Rails when I tried it was the level of magic involved. Does Phoenix suffer from that at all?

Phoenix is much more straightforward and explicit but macros are used a lot in both Phoenix and the Elixir standard library. I think most of the macros are fine but opinions vary widely on that.

Re: Phoenix 1.3.0 Released

#42

Phoenix is great! I only wish there was one recommended way for authentication and authorization - there are so many [1] different libraries that I got stuck in researching the options - I am confused, do not know which one to use. What is your preferred way? I would like to avoid to implement every little detail on my own - to get security done right was the main reason for me using open source libraries. It would b…

Auth : Guardian

Re: Phoenix 1.3.0 Released

#44

Phoenix is great! I only wish there was one recommended way for authentication and authorization - there are so many [1] different libraries that I got stuck in researching the options - I am confused, do not know which one to use. What is your preferred way? I would like to avoid to implement every little detail on my own - to get security done right was the main reason for me using open source libraries. It would b…

The beautiful thing about Phoenix framework is that there is no "one-true way" to do things. Rails is omakase, Phoenix is not, and that's a good thing.

You want the whole enchilada? Use Guardian.

Need oauth? Use ueberauth.

Just want email and password? Use comeonin to hash your password.

It's liberating to know exactly how your system works and that it's not hidden behind some magical blackbox like Devise.

Re: Phoenix 1.3.0 Released

#46
For anyone curious about Phoenix and Elixir, I can sincerely recommend the following resources to get you started:

- Programming Phoenix by Chris McCord, Bruce Tate, and José Valim [1]

- The Little Elixir & OTP Guidebook by Benjamin Tan Wei Hao [2]

- Elixir in Action by Saša Jurić [3]

Phoenix initially attracted me to Elixir, I've stuck around for that and the OTP platform: pattern matching, process based concurrency (actor model), supervision, immutability, macros, and more.

"Elixir took the Erlang virtual machine, BEAM, and put a sensible face on it. It gives you all the power of Erlang plus a powerful macro system." – Dave Thomas

[1] https://startlearningelixir.com/r/programming-phoenix

[2] https://startlearningelixir.com/r/the-little-elixir-and-otp-...

[3] https://startlearningelixir.com/r/elixir-in-action

Re: Phoenix 1.3.0 Released

#47
The directory reorganization is a good sign that Elixir/Phoenix are not simply rehashing Ruby/Rails for the sake of popularity but are willing to prioritize what makes the most sense for this particular language - and asking how they can improve upon what already exists.

I recently ported my app from 1.2->1.3 and moving away from Models to Contexts/Data was a simple transition that makes a lot of sense.

The `data` files (aka your new models) are basically where the schema for your model lives and the `context` (your models API) is the interface for your data.

For example when building a blog:

Instead of having User, Session, Post, and Comment models which contains your DB schema, business logic, and interfaces for getting/setting data all models directory ala Rails:

    blog/app/models/comment.rb
    blog/app/models/post.rb
    blog/app/models/session.rb
    blog/app/models/user.rb
    blog/app/controllers/...
    blog/app/views/...
you instead create a namespace for each group of data:

    lib/blog_app/accounts/accounts.ex
    lib/blog_app/accounts/session.ex
    lib/blog_app/accounts/user.ex
    lib/blog_app/blog/blog.ex
    lib/blog_app/blog/comment.ex
    lib/blog_app/blog/post.ex
    lib/blog_app/web/controllers/...
    lib/blog_app/web/views/...
And in your data file `lib/blog_app/blog/post.ex` for example, you'd keep just your schema defining the fields like "title, permalink, body, etc" and code to handle validations and virtual attributes.

Then in your context file `lib/blog_app/blog/blog.ex` you define the API that access your data. So from your controller instead of calling:

    Post.all
    Comment.all
    Comment.find(1)
    User.new({..})
You now call:

    Blog.list_posts
    Blog.list_comments
    Blog.get_comment(1)
    Accounts.create_user({..})
It makes for a very logical structure for your MVC code.

Re: Phoenix 1.3.0 Released

#48
post #40

Earlier quoted context omitted.

As a .NET developer by day, I'm curious what you like about Elixir over C#/.NET? I have a copy of Elixir in Action on my nightstand, I just haven't had a chance to crack it open yet.

Pattern Matching makes it easy to write small, understandable code The Concurrency Model is simple to the point where creating a whole pubsub system to handle events, push out notifications, and handles backpressure can be done in Finally the pipe operator is like C#'s LINQ statements but with so much more power and flexibility, hard to explain but I highly recommend cracking open that book on your nightstand!

The Elixir pipe operator |> is the equivalent of the Clojure thread first macro ->, right?

Re: Phoenix 1.3.0 Released

#49

For anyone curious about Phoenix and Elixir, I can sincerely recommend the following resources to get you started: - Programming Phoenix by Chris McCord, Bruce Tate, and José Valim [1] - The Little Elixir & OTP Guidebook by Benjamin Tan Wei Hao [2] - Elixir in Action by Saša Jurić [3] Phoenix initially attracted me to Elixir, I've stuck around for that and the OTP platform: pattern matching, process based concurrency…

This is the best Elixir material I've used: https://pragmaticstudio.com/elixir

You build you a simple HTTP server using Elixir and learn a lot of the core language and architecture choices when writing Elixir code. It doesn't pester you with this is an int, this is a string. You just start building this HTTP server out and learn about Elixir along the way.

Re: Phoenix 1.3.0 Released

#50

Would you suggest to choose Elixir / Phoenix for an api for a startup? Is it too risky now, or good enough + very attractive?

It's used by fairly big projects/Companies bet365, Bleacher Report, New Relic,Discord, PagerDuty, Puppet labs, FireEye etc.
Post reply on HN