Rolling

Rolling

Hello,

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…

Showing Posts 1 to 7

pmangalakader

pmangalakader

Have you happened to use the pry feature in elixir ? and also try to use observer which provides certain monitoring facilities…

This thread here is very much related to this:

Also, this uses Visual Studio Code, that provides some GUI comfortability:

https://forum.elixirforum.com/search?q=visual%20studio

There are various plugins for Vim, Atom, etc., please do check the elixir-lang official site for supported editors.

Thanks.

AstonJ

AstonJ

Welcome to the community :023:

We have a few options - tho many are not a full blown IDE they come pretty close :smiley:

First, you may find this poll interesting:

And here are some other threads of interest:

And a few more at the code-editors tag.

On the Elixir website there is also a list of code editor support with install instructions :smiley:

CODE EDITOR SUPPORT

I’d recommend trying a few and seeing which one you prefer, and if you run into any issues or have any other questions just let us know :smiley:

Rolling

Rolling OP

I was afraid of being misunderstood by not being able to explaining my situation properly…

I am not so much looking for an IDE. I know that there is not some thing as RStudio.

I wanted to know how people program in Elixir. Do they know exactly that every code line is correct so that they do not need to see the variables’ values at any time? No need to debug?

I will have a look at ‘pry’, thanks.

kokolegorille

kokolegorille

It is not usual to follow variables changes because variables are immutable.

You might get used to sequential coding, but it’s more

input -> function -> output

or more like a pipeline of transformation… like

output = input
|> apply_change1()
|> apply_change2()
|> apply_change3()

In that case, You can insert some inspect/1 in the pipeline to see how data changes.

csisnett

csisnett

@Rolling Welcome to the forum!

When I start writing a function and I want to experiment I usually do the following :

start an iex session: iex -S mix, alias Project.Module the modules I’m using so that I don’t have to write the long names every time I’m just use Module to refer to them

Whatever operations I wanted to do inside the function I try them in the console one by one, check that they work as expected or fix them

To get the values from a specific expression I usually do:

iex (5)> 2+2
4
iex (6)> var = v 5
4

and if I change a module I need to load it again: r Module in order to be able to call the updated functions

nthock

nthock

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.

opsb

opsb

TDD is definitely how I approach it. If you’ve not used it before this mini series from Kent Beck is a great introduction (not elixir but easy to follow) TDD Intro, Episode 1, first 10 minutes, unedited

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
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
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
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
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
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
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews