pfitz

pfitz

What are your debugging techniques?

Coming from Objective-C/Swift/PHP/Java I am used to a full IDE for my projects. The one thing I miss the most is a good debugger. So far I just did „poor mans debugging“ with IO.inspect but I am guessing there are better ways to debug ones elixir apps. So how do you debug your apps ?

Most Liked

rvirding

rvirding

Creator of Erlang

You have to be very careful when debugging things in a concurrent environment, at least when you debug in a more traditional way which stops and controls execution. Anything that is waiting for the debugged process will hang and in many cases may time out and crash, which is not what was intended. Also doing something like IEx.pry in a function which is called in many processes will also be interesting.

Sorry to sound very negative here but having very concurrent systems does change you need to work with them. Sometimes IO.inspect is all that is reasonable. Or use the built-in tracing facilities.

Robert

Qqwy

Qqwy

TypeCheck Core Team

Because of the ability to run multiple Erlang applications side-by-side in the same process and because of metaprogramming awesomeness, one of the fancy things you can do is IEX.pry(after you require IEx in the module) , which starts a shell at that current location in the code, so you can debug the scope you are in.

The cool thing about IO.inspect by the way is that you can plug it in everywhere in your pipelines without altering the result:

(1..10)
|> IO.inspect
|> Enum.map(fn x -> x * x end) 
|> IO.inspect
|> Enum.sum
|> IO.inspect

gausby

gausby

I think that we, as a community, need to study our options for inspecting our applications. As others has mentioned in this thread: The Beam is a different beast. Introducing break points changes the program and such.

Personally I have to look into this book: http://www.erlang-in-anger.com. It is another Erlang book, but learning a little bit of Erlang goes a long way :)—it describes strategies for tracing and probing a running Erlang system.

rvirding

rvirding

Creator of Erlang

Yes, most of that book should be directly applicable to Elixir, with a bit of syntax change. The way systems are built, work and interact are basically the same.

Qqwy

Qqwy

TypeCheck Core Team

For anyone who reads this topic and doesn’t know about observer: :observer.start will make your life easier. It basically is a Task Manager, for inside the BEAM. It gives you a lot of high-level information about what is going on in your system, and it is very useful to, for instance, spot bottlenecks in your message-passing.

Where Next?

Popular in Questions Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
Exadra37
Sometimes I want to check if the input into a function is not a blank string. My first approach: defmodule Example do def do_stuff(s...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

Other popular topics Top

pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
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
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
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
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

We're in Beta

About us Mission Statement