Elixir for a newbie

Hi guys,

I know that there have been a few topics like this. I’d love to hear your opinion whether or not Elixir is a good choice for a newcomer.

A bit about my background - so far I’ve:

  • developed a few simple programs like 20-23 years ago with BASIC (C64/C128 times),
  • written a few apps with Delphi (~10-15 years ago),
  • built some apps (mostly tutorials/books) with Ruby and Ruby on Rails,
  • fiddled around with Python (including Flask and Django - nothing serious),
  • went through most courses on CodeCademy,
  • went through 2/3 of JS on FreeCodeCamp,
  • know HTML and CSS.

I am not looking for a career switch, I just want to test and build my own web apps (got a few on my mind).

Would you recommened Elixir (and next - Phoenix) over Python and Flask? I have some doubts about the language, ORM (read somewhere that it’s not fully-featured, ie there’re some troubles with stuff like belongs_to, destroying dependencies and stuff like that) and avaliable resources.

Somehow I feel like functional programming will be easier to process for me than OOP, but I’m not entirely sold.

Thanks in advance for any words,

Mike

4 Likes

If you take opinions from other beginners, mine is yes.
I spent one year trying out Java, Python, Ruby, C#, Go, Haskell, Erlang, PHP, before landing on Elixir.
I would say that Elixir is the Python of Haskell ; )
I also love Erlang more than the other languages, but in my case it was impossible to progress with it.
Elixir is the beginner friendly language in which you can actually find learning materials, help, and libraries for web development.
I had the misfortune of trying a particular Erlang web development book and still think the author should be prosecuted for scamming :slight_smile:
Anyway, Elixir is full with good people who will help, and most of the documentation is digestible.
As to Phoenix, yes, it is an awesome framework for beginners, and it’s possible to adjust it to your needs.
I’m personally using it without Ecto and with Rollup, instead of Brunch, without too much trouble.
Functional programming + SRP is absolutely the most amazing thing, and Elixir has a “with” statement that helps a ton.
Languages like Java feel like the production line of corporations for ready made employees, and for me the “dance” they do in such languages doesn’t seem helpful for the dev, but rather for their easy replacement.
It’s awesome there’s information out that even with OOP you can have impossible dependencies hell and so on.
So in short, it’s awesome, there’s absolutely nothing better.
Thanks to Erlang there’s no need for anything better, and even if something comes up, they will need 30 years of experience to prove they’re on par with Erlang.

2 Likes

YES! YES!

You’re in the right place to actually solve this doubts!

Ecto is actually pretty much full-featured! Maybe some features are not the way most people are used to, but that does not necessarily means it’s not full-featured.

Give it a try! You’ll see how amazingly simpler it is than OOP.

Actually, it’s more close to a Ruby of Erlang… :smile:

5 Likes

PS.: I don’t know what you red, but belongs_to and cascade deleting (if is that what you mean by “destroying dependencies”) are pretty fine and stable

I like Python better :stuck_out_tongue:

Yep, but Elixir syntax feels like Ruby and not Python. :stuck_out_tongue: Sorry…

2 Likes

I’m also an Elixir newbie, although I have tons of Java/Scala experience.

I came to Python first and found it approachable until I needed to get concurrent, then thread programming felt like Java 1.x.

Elixir is also approachable and it has been easier to get beyond the toy stages with my web apps vs Python.

Sooner rather than later though you’ll get hit with the supervision stick in Elixir. The supervision concept can add complexity to the code examples and be confusing conceptually to newbies. But it’s worth the time you put in to understand supervision and OTP behaviors.

Once you get those concepts I find that nearly all Elixir code is composed of functions acting in small ways on explicit data. I find the lack of objectification and wrapping and obfuscation very refreshing in Elixir. Just linear chains of data processing, over and over.

Oh, and you don’t have problems with Python 2.x vs 3.x. Python 3.x has been out for ages, yet IDEs, frameworks and a bunch of other deps end up being 2.x only, or only recently support 3.x, or only partially support 3.x. You don’t deal with that mess with Elixir. For the most part there is a standard toolchain for Elixir. Mix + Pheonix + Ecto + sprinkle in libs interesting to your app. No version mess.

5 Likes

I tried to give a compliment related to usability, not a syntax comparison, sorry for the misunderstanding. :slight_smile:
Ruby at some point becomes hard to read for me.
I like my functions to look like functions, my vars to look like vars, strings like strings, numbers like numbers, I like to have syntax that’s instantly recognizable for the different events and actions in programming, dreams, dreams.
Programmers claim to be lazy, but I would venture to say I’m even worst, because I absolutely refuse to be a second layer of perser/interpreter to someone’s code, just because they don’t want to type (). Is it a var or a function, or a function with 5 params, or params in function with vars of the params? Not to mention Haskell where apparently the number 1 is a function :slight_smile: (please don’t tell me there are such things in Elixir/Erlang, have pity ty).

1 Like

No, numbers are numbers, not functions. But you can use your function without parens, it’s up to you. :wink:

I agree it takes time to get used to it, but once you do, functions without parens feel the just the same as with them, and sometimes even clearer to read. But that’s an opinion of course… :slight_smile:

No they don’t. :wink:

Not in Elixir, not in Scala. All functions should always be called with parenthesis. In Elixir a Macro often makes sense to call without parenthesis (if it is a syntax-style macro, like defmodule or so), but any and all function calls I wish absolutely required parenthesis.

That or either functions should never use parenthesis, ever, like OCaml does that well:

let a_func x y = x * y

let 42 = a_func 21 2

let a_func2 = a_func 2
let 42 = a_func2 21

Just get rid of the superfluous syntax, no parenthesis, no comma’s. ^.^

But mixing function calls with and without parenthesis is still confusing to this day, and I’ve used languages with it for over ten years now (yeesh, Scala is that old now? Apparently even much older…). >.>

6 Likes

So nice to hear that “numbers are numbers” in Elixir. I’ll just repeat that a couple of times to avoid having Haskell dreams tonight.
As to functions, everything is readable when people read their own code :slight_smile:
Let’s have a fun example of that.
Which of the following is the correct interpretation of the code: abcdefg
A) a(bcdefg)
B) abc(d(ef(g)))
C) abcdef(g)
D) Depends on the mood of the person asking the question.
E) It’s a variable.

Phoenix is better than flask. Flask is very restrictive on what it allows (like almost all Python frameworks). The answer to “How do I do this cool thing” in WSGI python frameworks (like Flask) is “You don’t. Are you sure you need that? Are you aware of the many benefits of the prison of stateless web servers and the WSGI architecture?”. I’ve been there.

In Phoenix the answer to “How do I do this cool thing” is probably “Just read the docs for Phoenix.Channel and Task.Async”. Also, don’t worry about blocking the thread with that long running Ajax request.

Well, I agree that sometimes no parens feels strange, and that’s why it’s up to you to put them or not. I do not bother by having this kind of syntax sugar anywhere you want anyways, and the elixir styleguide does not take a side on with or without parens AFAIK.

Considering no spacing or anything of the sort, ‘obviously’ it is referencing a symbol of name abcdefg. ^.^

1 Like

Yes, this and optional brackets which I don’t quite understand either.

I must try the new code formatter to see how it handles these kind of things. Will it add parentheses if there are non? Will it remove them? Will it turn tuples in a list into keywords? The other way around? Will it leave it?

1 Like

Correct answer: E) It’s a variable. To become a function call you would need spaces like this:

a bcdefg == a(bcdefg)
abc d ef g == abc(d(ef(g)))
abcdef g == abcdef(g)

And, at least for me, in the second case I would do:

g()
|> ef()
|> d()
|> abc()

So much better with pipe ops! :wink:

Sorry for the off-topic BTW

2 Likes

I guess it does not take a side on this eternal flamewar… :lol:

1 Like

Wat? @OvermindDL1, is this true?

Lol, inside a macro, 1 can perfectly be a function, a symbol, a variable, a dictionary, a process, and some other things. Macros can transform arbitrary And Elixir into arbitrary Elixir (as long as it’s valid syntax, a sometimes annoying restriction). But in practice it’s usually just a number xD

2 Likes

The correct answer is “In what language is the code written?”, and since I’m using an advanced version of Haskell where even spaces are not required (it’s called Hackskell btw, cos 1337), the correct answer is D. :slight_smile:

1 Like

Or a function call. Or a macro (which is a function).

1 Like