Should I choose Elixir for web apps?

Elixir is fully functional, but it’s possible to create a OOP-like API. For a good example check this library:

Since it’s more like than actually OOP it probably does not have any compiler optimizations which are typical for OOP languages. Of course there are also probably used other optimizations, but only for functional programming (Erlang/vm optimizations).

In short Elixir is based on Erlang which used BEAM (virtual machine). This allows to create your own processes (in BEAM) even if you have started app once. Processes in BEAM are much more lightweight than OS processes which means you one app can easily create thousands and even more processes (again in BEAM VM). Each process can store its data which can be modified, but

In OOP languages you are working on exactly same data. In Elixir you are working on data copies. So when you change data you are actually getting its modified copy rather than modified data itself (it matters in memory). What process is doing is basically replacing old data with its modified copy.

# old data
data = %{name: "example"}
# store old data
change_data_in_process(name, "sample")

defp change_data_in_process(key, value) do
  # old data
  data = get_data_from_process()
  # store modified copy
  data |> Map.replace!(key, value) |> store_in_process()

Of course such code would not work - it’s just to visualize how its working inside.

For more information take a look at:

Especially in Advanced group you have some info about concurrency.

1 Like

Thanks for the reply. I just now edited my answer as I forgot to add TypeScript to the languages that meet my criteria. I actually have used C# a bit and I think it’s a great language but I wanted something a bit more light weight than Java and C#. Also, I would only want to use servers with Linux which cancels the idea of C# since .Net Core isn’t anywhere close to where it needs to be for me to consider using it yet.

I’ve seen that OOP library before and the associated talk he gave and I thought he was just trolling so I didn’t consider using it. It does look interesting though if only food for thought.

Also, thanks for sharing those actor model resources. They really helped me gain a deeper understanding of the Actor Model and how useful and awesome it is. I’m going to continue learning Elixir and I’ll try to learn more by building out an app. I don’t have any previous experience with a functional language so Elixir has been a bit of a puzzle to me but it’s quite interesting and fun and I’m starting to get how it all works.

Well … it’s similar change like Windows to Linux with “weird console”. It’s definitely change of habits, but you would find it really easy to learn soon. Comparing to other languages you do not need to go around to solve specific problem, because lots of really helpful core functions and libraries. Also documentation looks best for me here. There is almost no magic here. Even Phoenix which is considered to be framework is basically just typical library with some easy to understand meta-programming (__using__/1 macro and use … calls).

I don’t believe that we have “trolls” in our community. To be honest Elixir could look like onion …

which then could be similar to ogres:

but … I don’t believe there are “trolls” here, because we have really nice and kind community (thanks to our forum supervisors). :077:

For sure, by “trolls” I mean people which could confuse others about how Elixir is working. One time I tried to troll some people, but it was more just for 1st April (which at end I said about) and it was intended to force think why it gives error rather than confuse newbies. :smiley:

Short answer: If you enjoy it.

Longer answer: It doesn’t sound like you actually need any language specific features for what you’re doing so try each of your candidates for a bit and see which you enjoy most and go with that. If you’re specifically looking to learn something that will lead to a job then check local job ads to see what companies near you are using most and learn that.

Sounds like you’ve already made up your mind.

  • Just because it is written in an OO language doesn’t actually mean it’s OO.
  • Good OO isn’t easy.
  • OO as it is practiced today is primarly based on the assumption of unshared mutable data and as such is addicted to mutability.

Thinking Outside the Synchronisation Quadrant - Kevlin Henney [ACCU 2017]

When you are only used to manipulating the flow of control and mutating values in place with statements then it can be a bit difficult to get into the mindset of transforming data and controlling the flow of data with expressions instead.

Whichever way you turn, know what you are getting into.


.NET Core is cross-platform, I write ASP.NET Core apps on Arch Linux, just install dotnet, mono and MSBuild and you’re ready to go. It doesn’t have as good tooling as in Windows, but still enough for serious development.

I read so many developers on Quora saying that OOP is the only way to go for building apps and that Functional programming is awful for real world applications.

Read a PHP forum and they’ll still say PHP is cool lol. /jk

Nowadays almost every programming language implements functional features like keywords or libraries that mimics some behaviors. I’d say functional programming is trending topic right now, as it makes code more concise, and helps the programmer by reducing side-effects.

Either Elixir or C# are really good options for web development.


PHP too, but don’t say it to anyone.

1 Like

Elixir is a great language for Web Development, and it would be my choice if everything else was equal. That said, it’s not an OO language, and try to use it like that will have you fighting against its strengths.

Have you thought about Ruby (and Rails)? It’s an object-oriented language with a syntax similar to Elixir. Actually, it’s really the other way around but that’s another story.

Ruby doesn’t scale as well as Elixir, but neither does Go or Phyton. A lot of Elixir developers (including its author) were Ruby developers first. The end result is that you can find lots of tutorials and examples that help you with the transition. Also, the new version of Ruby supposed to improve performance and scalability.

I understand Rails makes it a breeze to get a new app up and running. If you learn both languages, you could use Ruby for rapid prototyping, and Elixir for the real system. Or, even use Ruby in production until you really need to bring Elixir into the picture.

Whatever you decide to do, choose a language that you enjoy working with. Good luck


A web app, by nature, is highly concurrent. Sure, you may not need to write your own concurrent code in your application. But by using e.g. Phoenix you would be reaping the benefits of Elixir’s concurrency, whether you realize it at first or not.

I would echo this important point.


All in all it depends on your definition of “Object Oriented”

Alan Kay, the person who is credited with coined the term “Object Oriented Programming” described it as a programming model with lots of independent processing units that maintained their own data and could communicate with one another through message passing.

That is the very essence of the Erlang (and by extension, Elixir) programming model. The units, independent in memory and compute, are known as Processes and they can communicate using message passing. This aligns very closely with the model that Alan Kay described. (He has since lamented the term saying if he had to do so again he might call it “Message Oriented” - to increase the emphasis on the separation of the processing units).

“Object Oriented Languages” grew from this concept to describe a language which sets aside a small piece of memory, of “state”, and controls access to that memory through language constructs (Encapsulation). The paradigm grew to include concepts like Inheritance (or prototyping) to allow for code reuse. And Polymorphism to help a developer apply problems solved in the abstract to concrete solutions. The task of learning “Object Oriented Programming” then, is focused on learning and applying these concepts - understanding how to use Encapsulation, Inheritance, and Polymorphism to solve problems. While these are good concepts - they are not fundamental to the “pure” concept that Alan Kay described.

If your goal is to learn those concepts, and how to work with them effectively, so that you can use any “Object Oriented Language” (C++, C#, Java, JavaScript, Objective-C, Swift, etc.) then learning Elixir is probably not the best vehicle to study. In some sense this the “practical” definition of “Object Oriented” in the modern lexicon.

If you are looking for an environment that is much closer to the “pure” concept of “Object Oriented Programming” as described by the person that coined the term then the BEAM and associated languages, including Elixir, may be your best bet.


As @felideon said, Elixir (and by virtue, Phoenix) are highly concurrent – and all web apps are highly concurrent as well.

Also, “we will only ever serve like 10 requests a minute” are famous last words.

Phoenix will delay your scaling troubles for much later. Even only for that it’s very much worth it to use Phoenix.

1 Like

I think the users on Quora are most likely talking about languages like Haskell when they are advocating against functional languages for web development. I’d also like to make a (possibly controversial) point about syntax. When someone says “functional programming language”, the languages that probably come up in the listener’s mind are Haskell, Lisp, and Clojure (and possibly Elixir and Erlang of course). Out of those, the syntax to all of them except Elixir is far enough away from the common algol-derived programming languages (e.g. C, Java, Javascript) to feel a serious amount of alien-ness. I think that the basic familiarity of the Elixir syntax (which in part derives from the influence of Ruby) is a major benefit of Elixir over other functional programming languages.

The bottom line is that Elixir is an excellent language for web applications (IMHO) and it is a relatively easy language to pick up for newcomers. You still have to deal with learning about the functional-style and immutability, but you can do that without worrying about type classes and monads (or a completely foreign syntax).


Typescript is nice, but if you want to code the server in that you are going to have to use nodejs, and I think that again Elixir is a better alternative. What you should do in my opinion, is setup an Elixir project with typescript support, so that all client code you need can be written in that. You should be able to think about some nice interfaces that would require the use of advanced OO concepts so you can get your OO experience.

Personally, I have written web app servers in JS, C#, PHP, OCaml and am starting with Elixir. I only enjoyed C# and Elixir for that task, and you should probably take that with a grain of salt but I would say that OO (in the sense of inheritance, polymorphism, …) doesn’t add much (if at all) to the web stack. The functional way the plugs work with Elixir/Phoenix is so much clearer than anything I’ve seen before.


This is very likely off-topic – but would you be so kind as to share what didn’t you like about OCaml?

I am considering learning OCaml (and up my level with Go) and I am gathering any and all feedback.

1 Like

I started OCaml recently, via Bucklescript/ReasonML. Syntax is nice in the inside.

But as a newcomer in the OCaml world, I find it difficult when dealing with the outside world… lots of coding/decoding, for exemple JSON to OCaml records…

And FFI is just painful to learn, lots of code annotations.

I am trying to wrap Phoenix js and it looks like this, just to translate one function.

  [@bs.module "phoenix"][]
  external init : (endPoint, ~opts: Js.t('opts)=?, unit) => t = "Socket";
  let init = (~opts: option(Js.t('opts))=?, path) => init(path, ~opts?, ());

I am not familiar with the syntax, but I find it ugly.

Ok, I wrote my response a bit too soon. It seems that you kind of meta-trolled me and I am too tired to be picking up on things like that right now. Normally I’d notice right away. Sorry about that :smile:

You think that response with ogre holding onion on image could be serious? :077:
Of course I was just joking. :smiley:

There’s PPX’s (think Elixir Macro’s) that do that for you in but a single line. :slight_smile:

It shouldn’t really be that bad? Just something like external the_thing : int -> int -> void = "javascript_side_call". You need to define the types it takes so it knows when you have a bug. ^.^

I find it more sensible in OCaml personally, ReasonML syntax is this weird abomination between OCaml and Javascript and it’s just yeesh to me… >.>

For note, that same code you gave in OCaml would be more like:

external init : endPoint -> ?opts:'opts Js.t -> unit -> t = "Socket"[@@bs.module
[ ]
let init ?opts:(opts : 'opts Js.t option)  path = init path ?opts ()

There is the external followed by the name you want to call things, then the types you want to use (I am not a fan of Js.t types, I prefer to explicitly define what it should or should not be personally, far far better error checking as Js.t may as well just be a dynamic type and makes your code impossible to compile on native), then the javascript-side definition. The things in [...] are attributes, like @Blah in Java or so, and those are all bucklescript specific things, that is not normal OCaml usage (bucklescript is divering more and more from OCaml over time…). The it defines an init function, which just reshuffles arguments around and calls the external function by name with them, seems a bit verbose there too, it could have just been let init ?opts path = init path ?opts () or so and still be entirely fully typed.


I learn OCaml through ReasonML because I am more familiar with JS world. But thankfully, it is easy to convert from ReasonML to OCaml.

I learned Erlang through Elixir, because I am more familiar with the Ruby world :slight_smile:

But to focus on the question, I would add that Elixir is just the Backend part of a full web apps.

You might not escape JS world when dealing with Web. That’s the reaon to learn… ReasonML.

Unless You replace it with WebAssembly… and it will be a good time to learn Rust.

1 Like

@kokolegorille / @OvermindDL1 I was asking about backend OCaml usage though! :smiley:

Appreciate the remarks on BuckleScript / ReasonML. To me, the OCaml syntax is still alien but I really do like the idea of more preliminary contracts and would endure the learning process to [hopefully] have a class of bugs be eliminated by the compiler the moment your program is compiled successfully.

As for boilerplate: don’t the BuckleScript / ReasonML stacks offer macros or function calls that emulate the above kind-of-looking-verbose snippets? I’d naively assume so.