Also writing elixir always feels like the lines of code are longer than the width of my IDE. It is so much text...
My Elixir (and phoenix) experience so far, has been far from amazing contrary to all the hype on hn all the time.
21–30 of 57 posts
Also writing elixir always feels like the lines of code are longer than the width of my IDE. It is so much text...
My Elixir (and phoenix) experience so far, has been far from amazing contrary to all the hype on hn all the time.
While action fallback sounds pretty useful, it feels like a framework solution to a language problem. The language just doesn't handle nested if statements very well. Also writing elixir always feels like the lines of code are longer than the width of my IDE. It is so much text... My Elixir (and phoenix) experience so far, has been far from amazing contrary to all the hype on hn all the time.
Also, what are the other things you did not like about Elixir/Phoenix? I am really curious to hear about them since, here on HN they are mostly praised and I wonder myself what are the cons (my experience has been great so far).
While action fallback sounds pretty useful, it feels like a framework solution to a language problem. The language just doesn't handle nested if statements very well. Also writing elixir always feels like the lines of code are longer than the width of my IDE. It is so much text... My Elixir (and phoenix) experience so far, has been far from amazing contrary to all the hype on hn all the time.
Elixir is a functional language, and while it's not pure, nested if statements deliberately do not belong.
The if statement itself is actually just a macro to a case/switch, the only reason it is there is to reduce the verbosity in cases where only one conditional branch is needed, José felt the practicality of this outweighed the fact it may get abused.
To use Elixir properly is to try and move away from conditional constructs as much as is realistically possible. This means instead using pattern matching, guard classes and multiple clause functions (both named and anonymous).
Once you take advantage of these you'll find your code stays flatter while keeping the individual branches of your conditional logic tied up into small independently testable functions.
If anyone would like to read more, I found these [1] [2] to be helpful.
[1] http://culttt.com/2016/05/30/branching-conditionals-elixir/
[2] http://blog.lucidsimple.com/2016/01/24/pattern-matching-help...
I've wanted to use Phoenix a few times but every tutorial to get me started relied 100% on ecto which for something like a transformation API was frustrating. I didn't want the complexity of a database I wanted to learn the request lifecycle in it. Overall, it was challenging with too many resources being out of date or just so focused on a different type of API than I needed to build
While action fallback sounds pretty useful, it feels like a framework solution to a language problem. The language just doesn't handle nested if statements very well. Also writing elixir always feels like the lines of code are longer than the width of my IDE. It is so much text... My Elixir (and phoenix) experience so far, has been far from amazing contrary to all the hype on hn all the time.
While action fallback sounds pretty useful, it feels like a framework solution to a language problem. The language just doesn't handle nested if statements very well. Also writing elixir always feels like the lines of code are longer than the width of my IDE. It is so much text... My Elixir (and phoenix) experience so far, has been far from amazing contrary to all the hype on hn all the time.
Also writing elixir always feels like the lines of code are longer than the width of my IDE
This just seems weird to me. The pipe operator makes the code really compact in my experience, and I wish other languages had this feature.
I have a feeling you never bothered to really learn the language and just jumped on the new fancy framework, and tried to glue some code you didn't understand.
You struggling to write something isn't a language problem. I'm interested in seeing some examples that highlight your problems.
I can't wait until May[0] for the new 'Programming Phoenix' book. I found the first edition to be a great learning experience. [0] http://shop.oreilly.com/product/9781680502268.do
While action fallback sounds pretty useful, it feels like a framework solution to a language problem. The language just doesn't handle nested if statements very well. Also writing elixir always feels like the lines of code are longer than the width of my IDE. It is so much text... My Elixir (and phoenix) experience so far, has been far from amazing contrary to all the hype on hn all the time.
Interesting. While Elixir syntax definitely requires writing more code, than for example Ruby which I use the most, I have not been struggling too much. Could you give some examples of these long, problematic snippets? Also, what are the other things you did not like about Elixir/Phoenix? I am really curious to hear about them since, here on HN they are mostly praised and I wonder myself what are the cons (my experie…
$ irb
[1, 2, 3, 4].
select {|n| n % 2 == 0}.
map {|n| n * n}.
reduce {|sum, n| sum + n}
# 20
vs $ iex
[1, 2, 3, 4] \
|> Enum.filter(fn(n) -> rem(n, 2) == 0 end) \
|> Enum.map(fn(n) -> n * n end) \
|> Enum.reduce(0, fn(n, sum) -> sum + n end)
That Ruby code is so compact that I split it on multiple lines only to make the comparison easier.Even Python is more compact even if it's harder to read because of the reverse order (I'm sure that there is a nested comprehension for that but it's beyond my comprehension skills)
from functools import reduce
reduce(lambda x, sum: sum + x, \
map(lambda x: x * x, \
filter(lambda x: x % 2 == 0, \
[1, 2, 3, 4])))
# 20
The problem here is having to type Module.function(value) vs object.methodOO languages have a more compact notation because objects act as namespaces. Elixir has alias but it doesn't help much and must be used wisely. alias Enum, as: E would only confuse people and gain little.
Then Elixir has too many do end compared to Ruby (coming from Ruby I feel them unnecessary), but that's not a big deal.
Moving from syntax to programming patterns, having to define twice my functions in GenServer (internal API and public API) is too much boilerplate. I'd like to have time to study macros really well and end up with a DryGenServer that lets me def the external API with the internal implementation. Maybe I'll defmacro a defasync and a defsync, that generate the standard "double" GenServer functions.
I can't wait until May[0] for the new 'Programming Phoenix' book. I found the first edition to be a great learning experience. [0] http://shop.oreilly.com/product/9781680502268.do
Thanks for the tip - just bought a Kindle copy. I was going to get the hardcopy, but Yikes, WHAT has happened to the cost of freight recently?!? It was going to cost minimum $45 to ship a $35 book to Australia!!