To add to the author's experience, I spent 18 months of production time with Elixir and Phoenix. As he says, the templates are compiled and are blindingly fast compared to Rails. Pattern matching is really really nice when used in the right places (and you'll miss it if you go back to Ruby); but it can be overused. There's a faction of Elixir folks who attempt to avoid all conditionals and instead seem to prefer mult…
> Sometimes simply reading a switch statement or if/else/then is much clearer Case statements are pretty common, and for code I read the with statement[1] is even more common. This allows you to code a happy path broken into small steps and then collect your edge cases. It doesn't solve every case for if/else or cases, but it's a nice tool. [1] https://hexdocs.pm/elixir/Kernel.SpecialForms.html#with/1
Elixir and Phoenix after two years
41–50 of 111 posts
Re: Elixir and Phoenix after two years
#42Re: Elixir and Phoenix after two years
#43Sign me up. I hold hope that Elixer is the thing that starts pushing the knife into OOP. Microsoft has added a ton of features to make functional style a thing in C#, and nearly everyone hates Java...so maybe the stars are aligning.
Re: Elixir and Phoenix after two years
#44Earlier quoted context omitted.
It's pretty great anywhere that you might use Rails or Django, but if you expect spike in traffic that are hard to predict you get nice stable worst case latency. I think it's also really good if you need to hold state server side for any reason.
Rails has a ton of high quality code available for it. It looks to me like Phoenix is certainly 'good enough' for a lot of tasks, but it just hasn't been around as long. I'm looking for those use cases where someone picked Phoenix and it was just clearly a better tool than, say, Rails because of X, Y, and Z, despite maybe being inferior for one or two other things.
I would also argue that Plug is a large improvement over Rack, and the idea of explicitly passing a single context map all the way through the request is just a better way to build http responses. I also think that the Fallback controller is obviously a better way to handle common errors.
Anything related to web sockets will be leagues better in Elixir, because the BEAM is built to do a thing like that.
SSR html as a compiled linked list is a better idea than runtime string interpolation.
Sure, Rails has libraries for everything, but some of the core parts just aren't a nice. So if you don't need all of that breadth of ecosystem then Phoenix is a better choice IMHO having worked professionally with both for a number of years.
Re: Elixir and Phoenix after two years
#45What are people finding as the real sweet spots for Phoenix? I have used Erlang very successfully in a semi-embedded context, but that's quite different from a web server that can usually be scaled horizontally pretty easily. One obvious one is if you have to hold open a lot of concurrent connections like web sockets. It'd be great for that. Others?
Re: Elixir and Phoenix after two years
#46I wish more Node.js people shake off their Stockholm syndrome and check out Elixir and Phoenix.
Re: Elixir and Phoenix after two years
#47To add to the author's experience, I spent 18 months of production time with Elixir and Phoenix. As he says, the templates are compiled and are blindingly fast compared to Rails. Pattern matching is really really nice when used in the right places (and you'll miss it if you go back to Ruby); but it can be overused. There's a faction of Elixir folks who attempt to avoid all conditionals and instead seem to prefer mult…
> and perhaps there could be a more concise enhancement of Erlang which would get the job done Erlang already is a more concise language than Elixir but also noisier as there are more punctuation characters. I would love if Erlang would drop some of its punctuation, as some of it is frankly unnecessary. Elixir syntax is definitely simpler than Ruby’s. Probably in the same ballpark as Python complexity wise: Elixir ha…
What?
Here's more-or-less the entirety of Erlang's "noisier syntax with more punctuation characters"
-spec f(A :: any(), B :: some_type(), C :: list()) -> any().
f(A, {B}, [C | _]) ->
A1 = fun() -> io:format(a, []) end,
A1(),
case C of
> -> 1;
_ -> #person{ok = ok, field = C}
end.
Edit: %% plus map syntax
#{"tuple" => {1,2}}
M#{"key" := "new_value"}
%% plus list comprehensions
[X || X
Elixir has all that plus more. The equivalent in Elixir is something along the lines of @spec f(a :: any(), b :: some_type(), c :: list()) :: any()
def f(a, {b}, [c | _]) ->
a1 = fun() -> IO.inspect(a) end,
a1.(),
case C do
> -> 1
_ -> %Person{ok: :ok, field: c}
end
end
## and don't forget the capture and pipe syntax
x |> (&f(y, {&1}, list)).()
## and default function parameters
def f(a, b, c \\ []), do: something()
## and sigils
String.replace(str, ~r".*", "")
## and Ecto adds its own characters
id = 1
(from p in Person, where: p.id == ^id, select: p) |> Repo.all()
## and dropping down to Erlang is a function call on an atom
:io.format(x, y)
And I'm definitely forgetting more...Edit:
## and string interpolation
a = 1
s = "The value is: #{a}"
## and two different map syntaxes
%{a: :map, with: "various", keys: "as", atoms: 0}
%{"another" => "map", "but" => "keys", "are" => "strings"}
## and different map access
map[key]
map.key
## and map update
%{ map | key: "new_value" }
## and list comprehensions
for x Re: Elixir and Phoenix after two years
#48What are people finding as the real sweet spots for Phoenix? I have used Erlang very successfully in a semi-embedded context, but that's quite different from a web server that can usually be scaled horizontally pretty easily. One obvious one is if you have to hold open a lot of concurrent connections like web sockets. It'd be great for that. Others?
Re: Elixir and Phoenix after two years
#49Right now, I’m trying to find a way to speed up builds in CI because they’re the biggest bottle neck to deploying. Building an umbrella with 5 apps, 3 of which are phoenix, leveraging parallelised docker buildkit, will still take 8~ minutes.
Re: Elixir and Phoenix after two years
#50Earlier quoted context omitted.
In terms of language, Phoenix is a complete replacement for Rails for me. I feel more comfortable growing a functional codebase, and the BEAM means I don't have to worry about scaling as soon as I would with Rails. I think it's a good fit for when you want to do more with a small, experienced team. I would reach for Rails when I'm concerned about finding developers (Elixir devs are fewer and more expensive, generally…
I fear it would be difficult to hire Elixir people as well, but now I realize it's actually also hard to hire decent Ruby/Rails people. Honestly I think we should just accept anyone who can demonstrate thinking and programming skills of any language and then plan for 2-3 months of ramp-up time to get them into our language of choice.