
Phoenix 1.3 is pure love for API development - chx
http://swanros.com/phoenix-1-3-is-pure-love-for-api-development/
======
Exuma
<3<3<3 for Elixir / Erlang / Phoenix

I learned about it about 20 days ago and have spent every day since then
absorbing, reading and learning.

I LOVE this language / framework / OTP / methodology / community

~~~
swanros
I experienced the same. Once you start, it's hard to stop. An amazing
community around this awesome language is hard to let go.

------
Exuma
Do you find it's a lot of extra writing for the contexts? I'm new to Phoenix
and my first thought is it seemed kind of verbose to define every single
'meeting point' across 'models'. For simple apps it seems OK but I have some
complicated apps with many models and interactions

~~~
_asummers
One of the things that is being stressed in this release of Phoenix is that,
to paraphrase Chris, your entire application is a model of your domain -- that
"models" are really just Ecto schemas, so data, and your web part is really
just a shim over your larger application. I encourage you to watch this[0]
talk.

[0]
[https://www.youtube.com/shared?ci=Muyt0zSUAbQ](https://www.youtube.com/shared?ci=Muyt0zSUAbQ)

------
jsmeaton
Can anyone point me to a decent fully contained example of a smallish app in
Phoenix on something like github? I've spent a couple of hours reading some of
the Elixir docs and getting familiar with some concepts, but I still have no
idea how an Elixir app or a Phoenix app would actually look.

~~~
hansihe
I have worked with Elixir quite a lot, and I think I have a fair idea of how
the language works in general, and how OTP apps are structured.

Even so, I find myself having the exact same issue as you are having when
using Phoenix and Ecto. The way I like learning something new is by looking at
something someone else has made. This gives me a much better view of how
things are done than just reading getting-started guides and docs. I have
looked, but I haven't found a lot of examples that actually applies to the
latest versions of Phoenix and Ecto.

~~~
auxbuss
Hi,

Take a look at the Building Umbrella Project from elxirconf:
[https://github.com/poteto/elixirconf-201620](https://github.com/poteto/elixirconf-201620)
by Wojtek Mach.

The source:
[https://github.com/wojtekmach/acme_bank22](https://github.com/wojtekmach/acme_bank22)
is a great example of an umbrella app. For example, he uses two instances of
phoenix (backoffice and bank_web). It's a working app, so you can experiment
with it too.

The talk is here:
[https://www.youtube.com/watch?v=6NTmUQClHrU18](https://www.youtube.com/watch?v=6NTmUQClHrU18)
I found it very instructive.

~~~
tvon
FYI, your links all have numbers appended to them. The working links seem to
be:

[https://github.com/poteto/elixirconf-2016](https://github.com/poteto/elixirconf-2016)

[https://github.com/wojtekmach/acme_bank](https://github.com/wojtekmach/acme_bank)

[https://www.youtube.com/watch?v=6NTmUQClHrU](https://www.youtube.com/watch?v=6NTmUQClHrU)

------
autoreleasepool
I can't wait until May[0] for the new 'Programming Phoenix' book. I found the
first edition to be a great learning experience.

[0]
[http://shop.oreilly.com/product/9781680502268.do](http://shop.oreilly.com/product/9781680502268.do)

~~~
cyberferret
Thanks for the tip - just bought a Kindle copy. I was going to get the
hardcopy, but Yikes, WHAT has happened to the cost of freight recently?!? It
was going to cost minimum $45 to ship a $35 book to Australia!!

~~~
JimmyAustin
I can only assume continental drift...

------
tchow
While action fallback sounds pretty useful, it feels like a framework solution
to a language problem. The language just doesn't handle nested if statements
very well.

Also writing elixir always feels like the lines of code are longer than the
width of my IDE. It is so much text...

My Elixir (and phoenix) experience so far, has been far from amazing contrary
to all the hype on hn all the time.

~~~
djm_
My first thought when I read this was that it sounds like you're struggling
against the language because you're trying to use it in an imperative fashion.
I'm well aware this may not be correct but it's what I'm going to assume for
the rest of this comment, so please forgive me if it's incorrect.

Elixir is a functional language, and while it's not pure, nested if statements
deliberately do not belong.

The if statement itself is actually just a macro to a case/switch, the only
reason it is there is to reduce the verbosity in cases where only one
conditional branch is needed, José felt the practicality of this outweighed
the fact it may get abused.

To use Elixir properly is to try and move away from conditional constructs as
much as is realistically possible. This means instead using pattern matching,
guard classes and multiple clause functions (both named and anonymous).

Once you take advantage of these you'll find your code stays flatter while
keeping the individual branches of your conditional logic tied up into small
independently testable functions.

If anyone would like to read more, I found these [1] [2] to be helpful.

[1] [http://culttt.com/2016/05/30/branching-conditionals-
elixir/](http://culttt.com/2016/05/30/branching-conditionals-elixir/)

[2] [http://blog.lucidsimple.com/2016/01/24/pattern-matching-
help...](http://blog.lucidsimple.com/2016/01/24/pattern-matching-helps-reduce-
conditional-logic.html)

~~~
swanros
Agreed, the fact that you're saying you can't nest if statements is a sign
that you still don't get the grasp of functional programming.

cases, conds, with statements, recursion, pattern matching...

------
angelofm
I love elixir and phoenix, I have started learning it around a month ago and
it has been a eye opener, the only thing that I struggle are the error
messages, sometimes I spend more time than I should try to understand where I
made a typo, I am not sure if it's just me because I am so new to this
technology or many ppl have the same problem.

~~~
auxbuss
Raise an issue.

José pays a lot of attention to providing great error feedback. And yeah,
we've all had incomprehensible messages en route when learning elixir. Things
aren't perfect, but they'll only get better when folk point out the
shortcomings.

------
kkirsche
I've wanted to use Phoenix a few times but every tutorial to get me started
relied 100% on ecto which for something like a transformation API was
frustrating. I didn't want the complexity of a database I wanted to learn the
request lifecycle in it. Overall, it was challenging with too many resources
being out of date or just so focused on a different type of API than I needed
to build

~~~
Dangeranger
If you don't want to deal with a database and ecto then you should just learn
Plug first as Phoenix requests and responses are built upon it.

[https://github.com/elixir-lang/plug](https://github.com/elixir-lang/plug)

[https://elixirschool.com/lessons/specifics/plug/](https://elixirschool.com/lessons/specifics/plug/)

------
ricardobeat
Is there an actual reason for shortening everything to "phx"? I would guess
the same rules as naming variables would apply here.

------
bharani_m
action_fallback seems like a great addition. It is helpful to expose all your
error codes in a single place.

However, I am not too convinced about having a context for each resource. I
think that should be optional, meaning that I should be able to specify a
context for some related resources but at the same time, I should be able to
have resources outside of any context.

~~~
josevalim
It is not a context per resource. The context should group all resources and
responsibilities that belong to that context. For example, if you are building
Github, you could have an IssuesTracker context where you would find the
issues, labels and other all issues tracker related resources in there.

------
the_common_man
Best part for me is the new fallback controller plug. Really well done. That
and the centralized error list. This is one of the things which is miss in Go
(I think this is the same in Rust, but I am not an expert).

~~~
philfra
Be careful: that is a framework, not a language feature.

~~~
the_common_man
Is a language useful without useful frameworks around it?

~~~
namelos
I believe at least most of those lisp dialects are useful without any
frameworks. You get view template with s-expr for free instead of erb/ejs/eex.
And you are basically composing everything like plug in elixir very easily.
However, the down side of not having a major framework is community does not
have same context to discuss and share, which keeps almost every lisp dialect
remains out of mainstream.

