Hacker News new | past | comments | ask | show | jobs | submit login

> Phoenix also feels a little bit magical in the way Rails is

I've felt this about every backend web framework I've encountered, Django included. There's a tension between reducing boiler-plate, and not having directory structures/symbol names/etc. have some implicit order to them. If you want explicitness, don't use a framework and maybe use something like Flask/Werkzeug

> I miss types

Most frameworks have typespecs defined which are enforced by dialyzer, using a much richer type system than most. e.g. Without creating some explicit enum you can make a function signature like:

@spec some_function() :: {:error, :bad_args | :out_of_bounds } | {:ok, SomeStruct.t}

And then you can a caller can just pattern match on that with a 'case' statement, and dialyzer will complain if all paths aren't handled.

> I miss C# and Typescripts documentation

hexdocs.pm is pretty amazing. Elixir as a language encourages documentation and has iterated heavily on its documentation tooling. I love that I can just fire up an iex console and go `h Module.some_command` and I'll get great docs back. And then `@doctests` that both work as inline unit tests as well as low-cost documentation for the library author. I think the incentives to make good documentation are there, and that has inspired the community to document well. And then there's elixirforum.com if I get stuck. In constrast, many times a Django extension has left me wanting in its description about intended behaviours.




>> Phoenix also feels a little bit magical in the way Rails is

>

> I've felt this about every backend web framework I've encountered, Django included. There's a tension between reducing boiler-plate, and not having directory structures/symbol names/etc. have some implicit order to them. If you want explicitness, don't use a framework and maybe use something like Flask/Werkzeug

One of the things I love about phoenix is how little magic there is. Not directed at you, but I agree there is always some amount of "it just works" with a framework but Elixir/Phoenix felt immeasurably more "the code is here" vs "well that particular thing is method_missing'd a few layers down into this which routes into that and then kaboom, here's your entire app."

This is helped by Ecto, which is the perfect mix of helpful and not helpful to me. It gets what I ask for and only what I ask for. It tells me when I've mucked up and generally it feels like a nice API to SQL vs its own thing (and dropping custom SQL is super easy). The data layer is most often the most hidden magic layer in frameworks IMO as routing some HTTP GET to some controller/function/whatever is pretty simple and easy to reckon.


Agreed, Ecto is the perfect balance of helpful and explicit. It allows people to avoid the performance footguns of typical ORMs, while still providing a friendly way to do that relation mapping, pluggable way to do validation, etc. and there are just things you can do with joins + select that an ORM can’t do, but Ecto can.

The magical parts of Elixir/Phoenix, would be the naming conventions of Controller/View/Template (which I think can be overridden), and `use` which brings a lot of useful functions but it isn’t obvious to a new user how to source docs for that.


Oh my god, why didn't I know about "h Module.some_command`. Thanks, that is going to be really helpful!

Will be reading the IEx documentation more closely.


There was a really great talk at ElixirConf 2022 with this tip + loads more. [1] Definitely check it out!

[1] https://www.youtube.com/watch?v=BotVs6TXR-c


> Thanks, that is going to be really helpful!

That makes me really happy :) And if you prefer docs in web-form, just look up any module in hexdocs.pm . Also can't overstate how helpful elixirforums.com is - a lot of smart + helpful people on there.


It is one of my favorite things about the Elixir REPL, and the ease of using them is a great incentive to write docstrings for your own code. The way examples integrate into the docs and test suites is really cool too.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: