nodemodule

nodemodule

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?

Showing Posts 1 to 10

Cochonours

Cochonours

I’ve not been using Elixir for a long enough time to have a thorough answer to your questions, but if the only other languages you are ready to use for web apps are Go and Python, then it’s a no brainer : use Elixir.

If you want more OOP and an nice yet enterprisey language, then I’d advise C#. I used to enjoy working with that for a big intranet website.

Eiji

Eiji

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
store_in_process(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()
end

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.

nodemodule

nodemodule OP

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.

nodemodule

nodemodule OP

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.

Eiji

Eiji

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:

sanswork

sanswork

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.

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.com/t/elixir-from-java-guy-perspective/3373


adrianrl

adrianrl

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

Spoiler

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

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

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.

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews