aochagavia

aochagavia

Adapting to Elixir, coming from C# and Typescript

Two months ago I started working professionally on an Elixir project. I had no previous Elixir experience, but I am picking it up at a reasonable pace (previous experience with Rust, Haskell and non-blocking programming in general have proved very useful). One of the things that I find myself missing is the top-notch IDE support I used to have in C# and Typescript, which gave me an incredible productivity boost and made it possible to find my way in new codebases very quickly. Unfortunately, IDE support for Elixir is quite basic at the moment, and my productivity suffers from it (though the fact that I am still learning the language also accounts for the productivity hit). Did anyone here have to adapt to Elixir coming from statically typed languages with great IDE support? How did you adapt?

Some concrete things that boost my productivity as a programmer, which I find myself missing, are:

  1. Find all usages of functions, modules, struct fields, etc.
  2. Rename functions, modules, struct fields, etc and have their usages automatically updated.
  3. A strict compiler that catches type errors, enabling things like “type-error driven development”, where you change something and chase the compiler errors until everything is fixed (it is almost magical to fix all errors and see that the change you introduced “just works”!).

Without these features, I notice that I am much less confident about changing existing code, which I find problematic, because frequent refactoring is often necessary to keep a codebase healthy. Writing new code is not a problem, though.

For the time being, I am using plain textual search a lot (which doesn’t really cut it given the size of the codebase, but I know of nothing better at the moment), using @spec wherever it makes sense (it is not as nice as proper types, but it helps a bit) and writing tests to ensure everything is working properly (ExUnit is great).

By the way, I understand that many of these features are incredibly complex or even impossible to have in a language such as Elixir, so it is probably not a matter of waiting until the tooling gets better. That is why I am looking for ways to adapt my workflow as a programmer, since I assume I am not the first one to stumble upon these obstacles.

I’m looking forward to your suggestions and insights!

Most Liked

asianfilm

asianfilm

Consider writing your core business logic in Gleam because Elixir is not (and is likely never) going to give you the type-driven development experience of Haskell.

I have a modern 50,000 line Elixir codebase that uses best practices like Credo, Dialyzer and test suites for its core business logic and it never gives me enough refactoring confidence.

I’m considering moving its core business logic to Gleam, which has a lot of Elm influence, and some new IDE support in its latest release (but that aspect is also still a work-in-progress).

aochagavia

aochagavia

Thanks for your answers! I forgot to mention I am currently using vscode with the ElixirLS and Elixir Test extensions. I assume other IDEs offer a somewhat similar development experience (btw I tried IntelliJ a few months ago, but it didn’t work as smoothly).

Right now it looks like I will need to get used to basic IDE / compiler support and hope the features of the language compensate for that. Some that are already proving very useful are:

  1. Process as a first class citizen (I really like the idea of putting state in processes rather than objects, because you are forced to think up-front about supervision)
  2. Easy multi-node programming (I recently had the joy of using a replicated Nebulex cache; with just a few lines of code, everything magically worked, whereas in other language I would have needed to deploy an additional service like Redis)

My hope is that these and other benefits will in the end outweight the limitations caused by lack of static typing (and the great IDE they usually enable). Thanks to @AstonJ for pointing this out!

Now if anyone has any tricks to keep a codebase maintainable, I’d be glad to hear them (maybe there is a cheat sheet somewhere). One trick I am already applying is to use structs for GenServer state, and pattern match on the struct when handling messages, so you get compiler warnings if you try to access non-existent fields and get autocomplete support in the IDE.

wfgilman

wfgilman

For what it’s worth, in Jose’s 10yr talk he speaks about prioritizing the IDE experience to make Elixir more accessible and make the learning process easier. It’s toward the end of the presentation here https://youtu.be/Jf5Hsa1KOc8

Where Next?

Popular in Questions Top

chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> somethi...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
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
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Other popular topics Top

Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

We're in Beta

About us Mission Statement