Hacker News new | ask | show | jobs
by rainsil 1772 days ago
Elixir and Phoenix is a great option. As a functional language, the focus is on pipelines of functions that progressively transform data structures, which is how Phoenix processes requests (through "plugs" transforming a Plug.Conn struct), and how Ecto, the database library, performs validations. Pattern matching and assertive programming, the use of keyword lists for optional arguments, behaviours (i.e. interfaces), and an ergonomic macro system make the language (almost) as productive as something like Ruby, and typespecs, along with Dialyzer, allow you to claw back some type safety. The architecture that Phoenix promotes, particularly the use of contexts, encourages you to write maintainable, well organised and encapsulated code.

LiveView is really Phoenix's killer app. It allows you to write responsive SPA-like applications without writing any JavaScript. It sends user interaction to the server over websockets and ships an optimised diff structure back to the client to patch the DOM, without having to deal with client-side state management and JSON deserialisation. It's built on top of OTP GenServers, which make it easy to write performant, stateful "processes" that scale well and are monitored by "Supervisors" that deal with restarting (or otherwise dealing) with them in the event of crashes, which reduces the need for defensive programming.

The ecosystem is also quite good, and I've found well-designed libraries for dealing with most common problems, such as auth, persistent background jobs, serialisation, wrapping common APIs. Documentation for every library is available on hexdocs.pm, and is usually decently comprehensive. For Phoenix itself, pick up Programming Phoenix, which does a better job of giving a big-picture understanding than the docs, but only has a short chapter on LiveView.

By way of criticism, I'd say that Phoenix should work on improving its directory structure to be something similar to [0], and deployment story (it's relatively difficult to find a nice solution that deals with things like migrations).

[0]: https://elixirforum.com/t/best-practice-for-directory-struct...