mac8ver

mac8ver

How often do you use recursion in Phoenix Framework

Showing Posts 1 to 8

garrison

garrison

Well Elixir is an immutable language so any time you iterate over anything you’re using recursion :slight_smile:

But other than that in the context of Phoenix, you might need recursive components if you need to render a data structure that is inherently recursive, like a “file tree” type of structure. I have done this a couple of times now and it works great.

The miserable part is dealing with recursive data structures in postgres. Don’t even get me started on that…

sodapopcan

sodapopcan

Hey @garrison how do you feel about recursive data structures in postgres? :upside_down_face:

garrison

garrison

Well by sheer chance I think I just answered your question in that other thread about recursive queries…

But more generally, dealing with trees in an RDBMS sucks. There’s no way to actually query a tree (you get back rows, making a tree is your problem!). You can use that weird ltree thing but then you pretty much lose any semblance of referential integrity, and at that point why not just dump your data into a JSON column and call it a day? (Frankly this is the only sane solution anyway).

But if for whatever reason your data is actually an integrated part of your application, and it needs to stay in its own little rows with nice happy foreign keys, then you better be prepared to write recursive CTEs for everything. Want to query a folder’s contents? Recursive CTE. Want to delete a folder? Recursive CTE. Want to move a folder without allowing the user to move it into its own parent (for surely then we would all be doomed)? ReCuRsIvE CtE!

And writing recursive CTEs is torture. I’ve written a bunch of them and I can still hardly read them.

All this because I just had to have nested folders in an RSS reader… but I must admit they are nice, and when I go live I think people are really going to like them :slight_smile: Tags just don’t hit the same.

sodapopcan

sodapopcan

Ha, well I was kidding since you said don’t get you started :wink:

But ya, agreed they aren’t the most understandable things. I only used them in a semi-similar but simpler situation to yours. Didn’t realize you’d need them to delete and query! I had more of a branching timeline and stored the body text in an FTS table so never ran into what you’re talking about wrt deleting and moving—hat indeed sounds painful.

mac8ver

mac8ver OP

Thanks for the responses so far. They’ve been really helpful in clearing some concepts. I have a Java, C, Python and Python background and coming to the fact there is no concept of loops in Elixir. However, are there really good resources I can use to learn to build with Phoenix?

rhcarvalho

rhcarvalho

Hello!

While there are differences as you’ve already started to notice, you may find some “comfort” on constructs like Enum.map, Enum.filter, etc, which are operationally very similar to Python, and there is also for which is relatable to list comprehensions in Python.

In Elixir/functional programming, a mental model worth developing is that of thinking about computing in terms of transformations. You’re always transforming some input into some output, and you use the language constructs to describe the operations involved in that transformation.

Well, what are you interested in building / what motivates you? Do you prefer written content, video, or something else?

mac8ver

mac8ver OP

I’ve started using the phoenix framework and I noticed it actually comes with a lot of useful functionalities. I’m currently working on a phoenix project

rhcarvalho

rhcarvalho

Nice! If you haven’t yet, I suggest the official guides as a starting point Overview — Phoenix v1.8.8.

Once you get the basics of Phoenix, you may also consider learning about LiveView, which is a different way of developing a web application, different than traditional frameworks like Rails and Django, and different than doing backend APIs + frontend JS SPAs with React/Vue/Angular/Svelte/etc: Welcome — Phoenix LiveView v1.2.5.

When going through the guides, you may choose to follow a slightly different order of topics, for instance you can approach them in a more progressive order or pick the topics that calls your attention.

You don’t have to learn/use LiveView to enjoy the many possibilities Phoenix opens up, like realtime presence notification, and more.

There are also books and videos (both on YouTube and paid courses), a non-exhaustive list can be found at Community — Phoenix v1.8.8.

— All posts loaded —

Where Next? Top

Trending in Discussions Top

juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
axelson
Hi there! :wave: @frigidcode and I (but mostly him) have been running an Elixir Book club, we’re almost done with Designing Elixir Syste...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New
Null-logic-0
What IDE or editor are you using for Elixir development? Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
jam
This was an interesting post by Jose. Curious to hear what others think. Evolving programming languages in the AI era - Dashbit Blog Gen...
New
sntran
In my third year of college, around 2010, I found Erlang. A few years later, I found Elixir. I liked the ideas at once: many small proces...
New

Other Trending Topics Top

mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
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
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
OndrejValenta
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly) AI dream has many faces, but general...
New
kip
In 2021 I started a new library called Tempo with the objective of modelling time as a set of intervals - not as instants. In 2022 I gave...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews