Papillon6814

Papillon6814

Do you think Kernel.++ has readability?

Hello. I’m developing a server program with elixir with a coworker.
I found a code which he wrote uses Kernel.++ in a pipeline chain.

I agree with that pipeline helps to write readable codes, but I’m not sure whether we should use Kernel.++ there.
I’d like to hear your opinion.
Thank you :grinning:

Most Liked

mudasobwa

mudasobwa

Creator of Cure

In pipelines I prefer to use Enum.concat/2 that is delegating to Kernel.++/2 when both arguments are lists.

darkmarmot

darkmarmot

I think that readability is somewhat dependent on one’s audience. Code that is highly readable to someone who’s been using a language for 5 years might seem completely foreign to someone six months in.

Personally, I really prefer pipelining where possible. Taking it a step further, I’ve recently started making heavy use of the with macro. It can also seem somewhat inscrutable at first, but it permits a style of railway-oriented programming that’s both efficient and compact.

The example I was mentioning above was a long pipeline that I ended up needing to append a newline onto the result. Rather than create an intermediate variable just to add a character, it was easier for me to just extend the pipeline with one last command like |> Kernel.<> ("\n")

It’s not something I do often, but I will use it without feeling too much guilt these days :slight_smile:

I’m sure lots of people here would argue against pipelining into the Kernel module. Programmers are a finicky lot :slight_smile: I would just suggest adopting a set of style guidelines, perhaps enforced using Credo or such.

Whichever style you agree on together will be the real right answer!

LostKobrakai

LostKobrakai

It’s still useful to use &Kernel.++/2, as this captures a “fully qualified function” instead of a local one. The latter is sometimes problematic when encoded or somehow stored between compile time and runtime (e.g. in config or plugs).

Where Next?

Popular in Discussions Top

Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
thojanssens1
It would be nice to be able to define a redirect from one route to another from the router.ex file. E.g.: redirect "/", UserController, ...
New
mmport80
I have put far too much effort into Dialyzer over the last year or so - and basically - I doubt it’s worth the effort. It’s not as easy ...
New
chuck
Let me start by stating an assumption: Phoenix is a great approach to building REST APIs. There are many reasons for this, but I will ass...
New
praveenperera
How We Replaced React with Phoenix By: Thought Bot
New
tmbb
This is a post to discuss the new Phoenix LiveView functionality. From Chris’s talk, it appears that they generate all HTML on the serve...
342 18146 126
New
fireproofsocks
I’ve been working on an Elixir project that has required a lot of scripting. I usually reach for Elixir because I like it more (and in th...
New
jesse
Hi everyone, I hesitated to post this here because I don’t want you to think I’m spamming, but I’ve been working on a Platform-as-a-Serv...
New
griffinbyatt
Sobelow Sobelow is a security-focused static analysis tool for the Phoenix framework. For security researchers, it is a useful tool for g...
New
paulanthonywilson
I like Umbrella projects and pretty much always use them for personal Elixir stuff, especially Nerves things. But I don’t think this is ...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
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
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
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
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
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New

We're in Beta

About us Mission Statement