nodemodule

nodemodule

Should I choose Elixir for web apps?

Hi, I’m having trouble deciding on whether to use Elixir as my main programming language for building web apps which usually won’t involve much of a need for concurrency.

I would prefer a language that is fun, productive, and that is easy to scale. Elixir seems to check all these boxes better than any other language out there but there’s just one thing that’s holding me back.

I would prefer to use an OOP language in order to further my OOP skills in case I want to land a job or build a team (both easier with OOP).

I’ve been learning Elixir for a few weeks now and it seems to be mostly functional from what I’ve learned but I’ve also read about how it’s (arguably) The Most Object-Oriented Language.

The object oriented nature of Elixir appears to mostly be related to the fact that all Elixir code runs inside of isolated processes which communicate via messages. So it appears to be functional on the dev side of things and OOP on the runtime (correct me if I’m wrong).

Should I be concerned about using a Functional language for most of my work? 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. Perhaps they are confusing impure functional languages like Elixir and Clojure with a pure functional language like Haskell, not sure. Elixir does appear to be a lot more useful for building non-trivial web apps than other functional languages so I’m kind of confused as to what I should do.

The only other languages which are meeting my criteria are TypeScript, Go, and Python. I find Elixir to be more fun than those three but Python is harder to scale than Elixir from what I’ve heard.

What would you do in this situation?

Marked As Solved

Cruz

Cruz

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

Also Liked

axelson

axelson

Scenic Core Team

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).

joeerl

joeerl

Creator of Erlang - Fondly Remembered

I always think of web apps as the quintessential concurrent problem.

I suppose their might be web apps that have only one session at a time but
not many.

Each session might process one event at a time, but web apps should manage dozens to millions of parallel sessions - this is where the concurrency comes in.

easco

easco

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.

felideon

felideon

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.

peerreynders

peerreynders

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.


https://forum.elixirforum.net/t/elixir-from-java-guy-perspective/3373


Where Next?

Popular in Questions Top

dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
Kagamiiiii
Student & New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
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
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
Codball
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement