Live data from Hacker News

Learning Elixir: My side-project

adrian-philipp.com

21–30 of 38 posts

Re: Learning Elixir: My side-project

#21
I think what I learned the most about my past year of working heavily in Elixir is this.. Don't learn elixir.. learn Erlang/OTP if you really want to harness the power of Elixir. Elixir is nothing but a series of macros which give erlang some convenience and better syntax.

If you learn to harness the power of Erlang, while writing it in Elixir, then you will see the beauty of it. Get away from Phoenix as fast as possible. Seriously it will do you wonders. It's so unnecessary and cumbersome.

OTP, OTP, OTP.. can't say it enough.

Re: Learning Elixir: My side-project

#22

Elixir was my Koolaid when it comes to functional programming. After getting the hang of pattern matching, I was hooked. Everything I'd do on Ruby/Rails, I just do on Elixir/Phoenix instead.

Clojure was my FP Koolaid, but Erlang (which I learned before Elixir) really blew my mind with it's pattern matching heavy syntax. I'm happy Elixir kept it as part it's core design patterns. So agreed it's a great abstraction that every modern language should be using.

That plus extensive use of list comprehensions when working with arrays.

Re: Learning Elixir: My side-project

#23

Picking up new languages is fun. I have to say things like this tickle my funny bone though: > def backlog(board_id) when is_integer(board_id) do What happened to good old fashioned function foo (int bar) :) Is there an equivalent to typescript for elixir?

Also something to keep in mind : so far noone has found a way to properly typed in a strong static formally proving way the erlang and elixir paradigm. Over other things, the self() construct that return the own pid of a process is so far impossible to type well.

Re: Learning Elixir: My side-project

#24
post #18

Earlier quoted context omitted.

Unless you're telling me Elixir has static analysis that can tell me that `right_age(18) == true` then I'm not sure how that competes with types much less is so different from any other runtime conditional.

> Unless you're telling me Elixir has static analysis Sure does: http://erlang.org/doc/apps/dialyzer/dialyzer_chapter.html > I'm not sure how that competes with types much less is so different from any other runtime conditional. You can write: f(5) -> "got a 5"; f(X) when is_integer(X), X > 1000 -> "got an integer greater than 1000"; f(X) -> "not 5 and not an integer greater than 1000". Sure you can do it with an if…

Looking at the dialyzer docs and how you truncated my full question, I'm still not sure if Elixir has static analysis that is aware of those guards or not.

Re: Learning Elixir: My side-project

#26
post #18

Earlier quoted context omitted.

> Unless you're telling me Elixir has static analysis Sure does: http://erlang.org/doc/apps/dialyzer/dialyzer_chapter.html > I'm not sure how that competes with types much less is so different from any other runtime conditional. You can write: f(5) -> "got a 5"; f(X) when is_integer(X), X > 1000 -> "got an integer greater than 1000"; f(X) -> "not 5 and not an integer greater than 1000". Sure you can do it with an if…

Looking at the dialyzer docs and how you truncated my full question, I'm still not sure if Elixir has static analysis that is aware of those guards or not.

Sorry for being confusing. I think this might be better description of static type analysis:

http://learnyousomeerlang.com/dialyzer

Erlang is a dynamic, strongly typed language. Dynamic means the compiler doesn't do static type checks. "Strongly typed" means once a variable has a type it usually doesn't get automatically coerced to other types. So adding a string "5" and an integer 1 doesn't return a string "6" or integer 6 but throws an exception.

In addition to the compiler there is also a tool called Dialyzer. It's based on the idea of Success Types (paper on it: http://www.it.uu.se/research/group/hipe/papers/succ_types.pd...).

It checks for type inconsistencies, violations, etc just like a compiler in a traditional statically typed language. But it doesn't emit optimized code based on it. So say it deduced that a variable can only be an integer between 1 and 10 it doesn't have a way to emit some optimized assembly code based on that information. Besides the types it automatically infers, additional typing constraints can be specified by the user.

So for the guard in question, if say the second clause of right_age(_) -> wasn't there and it saw calls to the function with X=105, then Dialyzer would come back with an error with something like:

   your_module:105: Clause guard cannot succeed.

Re: Learning Elixir: My side-project

#27
post #21

I think what I learned the most about my past year of working heavily in Elixir is this.. Don't learn elixir.. learn Erlang/OTP if you really want to harness the power of Elixir. Elixir is nothing but a series of macros which give erlang some convenience and better syntax. If you learn to harness the power of Erlang, while writing it in Elixir, then you will see the beauty of it. Get away from Phoenix as fast as poss…

Can you please explain your position a bit more?

Re: Learning Elixir: My side-project

#30
post #21

I think what I learned the most about my past year of working heavily in Elixir is this.. Don't learn elixir.. learn Erlang/OTP if you really want to harness the power of Elixir. Elixir is nothing but a series of macros which give erlang some convenience and better syntax. If you learn to harness the power of Erlang, while writing it in Elixir, then you will see the beauty of it. Get away from Phoenix as fast as poss…

How does Phoenix detract from from the elixir/erlang experience? I was under the impression that it was just a web framework? I'm pretty naive on the subject—I've just never seen something like this brought up before.
Post reply on HN