pmjoe

pmjoe

How Elixir compares with Typelevel Scala?

I know a little of Elixir and apparently I’ll be moved to a Scala team at the company that I’m working by the end of the year. The codebase is pretty much Typelevel based and even having a little of knowledge of FP, from Elixir, that codebase is completely unreadable for me.

What I’m wondering is, Elixir is less functional than Typelevel Scala? Or this complexity is just the nature of a heavily statically typed FP language?

It’s astounding how simpler Elixir is compared to Typelevel Scala.

Most Liked

yawaramin

yawaramin

Interesting thread! I would say they have different philosophies.

Elixir/Erlang/BEAM philosophy is that runtime errors will happen and we have a robust framework in place to deal with them. But also it is nice to not lose productivity due to typos and other silly mistakes, so let’s add some level of simple typechecking support (at least for the time being, more in the future).

Typelevel Scala philosophy is that we can build our programs by plugging together small, ‘reasonably safe’ lego pieces of code and turning ‘effects’ into first-class values in our programs. Effect management is a very important part of this philosophy–primarily I/O, but also mutation, randomness, cancellation, etc. If we model each effect as a value (a description of what will happen at runtime), we can construct our programs as just different combinations of values–something programming languages are very good at.

Some people do argue that Elixir is less functional than Typelevel Scala because it doesn’t control effects. I don’t agree; I believe Elixir fulfills all the criteria (in my definition) to be a functional programming language. But I also think at a certain point arguing semantics is not that useful. One thing I will remind people is that all the ‘complexity’ may be seemingly overkill, but often we are not using raw Cats IO, we are using higher abstractions like fs2 streams. See eg Fs2

With a few lines of code, you can run streams that handle I/O, error-handling, cancellation handling, safe resource disposal, parallelization, retries, and many other abilities. You can of course do many similar things with Elixir, but due to the power of the type system, in Typelevel Scala code it’s often very plug-and-play:

The pattern of Network[F].server(address).map(handleClient).parJoin(maxConcurrentClients) is very common when working with server sockets.

code-shoily

code-shoily

Regardless of the flavour of Scala in question, in my opinion, Elixir (and Clojure and even ML cousins) are simpler than Scala.

With Typelevel Scala do you mean heavy usage of the Cat family of libs? If that then I’d say I had the same feeling. Other than Elixir I worked with Clojure and a little F# but I felt completely humbled when I saw some of those LoCs

Scala was (is?) my programming language for year 2024 and I wanted to get ahead of myself and start reading the Cats and the Red book but I got back to learning the basics as I didn’t quite get what they were coding on. I guess it’s the category theory influence that makes it appear tough?

I am tagging @yawaramin here since he is my go to person for all things Scala who also knows ways of Elixir. Maybe he can add some helpful info here.

Where Next?

Popular in Discussions Top

Fl4m3Ph03n1x
Background A few days ago I was listening to The future of Elixir from Elixir Talks, with Dave Thomas (@pragdave ) and Brian Mitchell. I...
New
arcanemachine
https://nitter.net/josevalim/status/1744395345872683471 https://twitter.com/josevalim/status/1744395345872683471
New
rms.mrcs
A couple of days ago I was discussing with a friend about different approaches to write microservices. He said that if he was going to w...
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
jesse
Hi everyone, I hesitated to post this here because I don’t want you to think I’m spamming, but I’ve been working on a Platform-as-a-Serv...
New
jsonify
So, is Heroku the only free option for hosting Phoenix/Elixir at this point? I’m not ready to commit to paying monthly and was wondering ...
New
chulkilee
Here are the list of HTTP client libraries/wrappers, and some thoughts on HTTP client in general. I’d like to hear from others how they w...
New
acrolink
How does the two languages compare when it comes to server side application development? Any experiences or ideas? Thank you.
New
AstonJ
Can you believe the first professionally published Elixir book was published just 8 years ago? Since then I think we’ve seen more books f...
New
Markusxmr
Since Drab has been developed for a while in the open, introducing the Liveview functionality in a way it happend appears to undermine th...
New

Other popular topics Top

lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30877 112
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
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
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement