In the last several months I tried to learn Elixir and Phoenix. Thanks to some good learning material I think I have learned the basics.
I have some experience with some other programming languages, mainly Java and R. Both have an exceptional IDE (intelliJ and RStudio) which support me a lot in my daily routines (commands on cli, debugging, etc.).
While I feel it is not so hard to think in functional programming (coming from an OOP background), it is very hard for me to program “blindly” in Elixir. In RStudio I can always see and inspect all the variables in memory so I can step through my code line by line and see how it changes my variables. My approach to programming is trial and error: I write a new line of code, try it (in most cases by using breakpoints and then inspect my variables, but in RStudio you also can execute just a selected line) and when it does what I wanted it to do I move to the next line…
I miss this extremely when I am developing with Elixir so I guess I’m doing it wrong. What is the right approach with Elixir? Writing testing functions? Are there any guides/tutorials for this?
The books I know show and explain what is the correct code, but not how to come to it. Hopefully you can understand what I mean. It is not so easy to explain…
I always write the tests and use IO.inspect/2 either in the code or the test to see the value passed in. This is my own variant of TDD. Instead of red-green-refactor, I write enough in my test code (sometimes without assertion) to execute the code I am writing, and use mix test.watch to run the test so that I can see the value.
Personally, I enjoy this way of writing code compared to using iex -S mix. When I am done with the code, I will end off my test with the assertions to check everything is working correctly.