Hacker News new | ask | show | jobs
by sethherr 1041 days ago
I agree with the code generation of libraries in Phoenix being a drawback.

I think it maybe a reaction to there being too much magic in Rails dependencies, but it makes upgrades much harder.

3 comments

I've found the code gen approach to be very positive. Most of the generated code is minimal app-specific modules that in turn `use` Phoenix modules. This gives you a handy place to insert your customization w/o having to resort to dynamic metaprogramming contortions the way you used to have to in Rails.

I also like the philosophy of magical experiences, without magical code. Everything is very traceable. And most of the time you don't even need to use the generators - just make your module, register in the right places, and you're done.

Jose has written about this before https://news.ycombinator.com/item?id=34935952
After reading that, I understand exactly where he’s coming from - I too have overridden a bunch of Devise in a bunch of different ways in various projects.

But, unlike the rest of Elixir and Phoenix, this approach doesn’t feel like an elegant solution - it feels like a moderately ok trade off.

A lot of that code generation is to facilitate macros. Personally, I don’t like macros when a little extra code to make a function call would work just fine.
Might be misunderstanding code generation. This means literally writing code into your project via a script. It has nothing to do with macros.