vonH

vonH

Why would I choose Elixir as a general purpose programming language?

In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of libraries, tools and the overall ecosystem. I am not that concerned about the concurrency benefits, the BEAM VM, and associated frameworks like Phoenix, nor am interested in the benefits of Python with stuff like numpy, django etc, just the plain power and elegance of the language.

  1. As a novice programmer why would a language like Elixir be preferable to one like Python or Ruby, in terms of its ability to express and implement ideas, ie as a general purpose programming language? Even assumng that the person had gained some experience with languages like Python or Ruby, what would make Elixir a more compelling choice? I am assuming that switching to a more functional style would be a better choice than the imperative and/or object oriented approach of Python and Ruby.
    In a way i am asking whether a functional programming language is a better way to program and on settling on that paradigm, Elixir would be the one to go for.

  2. As a functional programming language, why would I choose Elixir over other functional programming languages like language like Haskell, Ocaml or LISP/Scheme? I am not that familiar with any of them but if Elixir will give me all the benefits of functional programming with good browser output, then I am happy with go with it, but again the main thing is its expressiveness,not its associated libraries.

Most Liked

OvermindDL1

OvermindDL1

Quick post while I have a minute. :slight_smile:

  1. Immutability means that the code is easy to reason about, test, and if done properly, much easier to read. You have no surprise hidden mutation of state in random calls. You have no worry about how a variable is going to change as it is called. The program is easy to follow and read.

  2. Elixir is built on the EVM/BEAM, if you want to build something for the web, network processing, or as a glue it is unparalleled, you will not have to worry about significantly optimizing your code later as you may need to in any other language. Immutable function programming means you build things up via functions to transform data as it flows through the program, wonderfully simple and expressive without tons of cruft.

  3. As an aside, when not to choose Elixir, if you want to learn functional typed programming, something like Haskell will ‘teach’ you better than almost any other language, however OCaml will be the best if you want to write to ‘get stuff done’ (that does not involve massive scale, OCaml has a GIL like Python does (though being fixed later)) at a low level as OCaml is ‘fast’. But as always, for web or scaling, anything on the EVM is pretty hard to beat.

  4. Alternatives: There is a growing language on the EVM called alpaca, it is still early and young but it is a typed functional language on the EVM, interoperates with Elixir and all.

  5. Notes: LISP/Scheme is not functional, is as about as imperative as it gets by default, and with libraries/macros it becomes anything. :wink:

22
Post #2
nroi

nroi

In a way i am asking whether a functional programming language is a better way to program

Not in general, no. Functional programming has its advantages as well as its disadvantages. Listing advantages of functional programming in this forum feels like preaching to the choir, so just to give you a vague idea of where functional programming is just ill-suited, consider dynamic programming algorithms or other algorithms where the most straightforward (and efficient) solution involves continuously modifying an array.

Programming paradigms and languages are tools, not religions. Try them out, gain experience, extend your toolbox, then choose the right tool for the job.

rvirding

rvirding

Creator of Erlang

Unless of course you use LFE, Lisp Flavoured Erlang, which is not imperative and behaves like Erlang and Elixir. :wink:

Where Next?

Popular in Questions Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New

Other popular topics Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52341 488
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New

We're in Beta

About us Mission Statement