4 ms·
> Grouped aliases/imports/requires are a mis-feature in my view. They save a few characters when typing but they complicate searching for module uses and refact
by denvaar 3y ago
> Grouped aliases/imports/requires are a mis-feature in my view. They save a few characters when typing but they complicate searching for module uses and refactoring.
Totally agree with this. I prefer to not use aliases most of the time, or to explicitly list out each module path separately if they are too long to fit inline. All preferences though.
> Similarly, I don’t like comprehensions as everything they do can be achieved with functions, and they are not composable.
I don't use comprehensions too often, but I would miss them if they vanished. Some things are just plain easier with them. They are also valuable in unit tests to show better error messages[1]:
# Don't do...
assert Enum.all?(posts, fn post -> %Post{} == post end)
# Do...
for post <- posts, do: assert %Post{} == post
EDIT: Although I suppose you could just use Enum.each as well.
[1] https://keathley.io/blog/good-and-bad-elixir.html https://keathley.io/blog/good-and-bad-elixir.html
- conradfr 3y agoInitially I didn't like grouping but lately I started to group aliases by their content/function. Like schemas together etc. But that's really nitpicking. Remembering the difference between require, use and import, now that is a struggle.
- atonse 3y agoI've been coding elixir for 7 years and still don't quite understand why I have to keep typing "require Logger" to just use the logger, and why it isn't just required in the framework across the board. Something to do with require being a macro and being lexically scoped (but you could probably just require it in the usings for Phoenix right?)
- sbaildon 3y ago>> Grouped aliases/imports/requires are a mis-feature in my view. They save a few characters when typing but they complicate searching for module uses and refactoring. > Totally agree with this. I prefer to not use aliases most of the time, or to explicitly list out each module path separately if they are too long to fit inline. All preferences though. recode[0] has a formatter plugin that reformats grouped alias/import/requires [0] https://github.com/hrzndhrn/recode https://github.com/hrzndhrn/recode