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
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
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
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
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.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








