AstonJ
This blog post hit my timeline earlier, and I’ve also been learning about some fantastic Elixir related tips via @pragdave’s new online course, his book, and @sasajuric’s EIA - so thought it would be cool to start this thread to see what tips you might have yourself ![]()
Trending in Guides/Tuts
# ~/src/livebook/.iex.exs
System.cmd("xdg-open", [ LivebookWeb.Endpoint.access_url() ] )
Because Livebook requires a unique passcode on ...
New
You probably already know that <span>{nil}</span> in a HEEX template produces <span> </span> when rendered. I fin...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
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
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 12 to 3- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
mudasobwa
My fave is
__CALLER__struct has acontextkey which might be used to distingush context of macro invocation (might be:guardwhen invoked in guards,:matchwhen invoked in matches, ornilotherwise.) Here is the self-explanatory example fromKernel.or/2macroIt helped me to build the
MapSetmatchers fwiw.bennydreamtech23
This is a very nice tip, it makes you understand the function and adding a doc to the function even make it better to understand what that function is doing, if you want to use multiple clause function, so you can understand what each function with its own clause is handling
Thank you
bennydreamtech23
Learning the basics of any programming language or anything in life. Is like a farmer forging it tools
. Reality hit me that I didn’t understand anything about the language, so I requested help from CTO and when recommend things to me, I went to senior developer in my team to ask questions and while learning with all these materials, confusion finished me.
When I started elixir, I just started with how to use Ecto, I would ask my senior colleagues any questions and they will always wonder how come the simplest thing about the language I didn’t understand. Last year when I thought of going full stack into Elixir
Then I was hit the utmost truth, I don’t know anything in this language and when I accept the truth and also a declaration. I will forge myself in this language, I started learning and still on learning journey and the progress I can see, make me wonder why I delay this journey. elixir documentation would help you, also Elixir in Action is a great book for elixir developer, we have Exercism for elixir challenge and practices, we also have Elixir school for roadmap and learning curve but above all this we have Livebook to practice your skills and we have Elixirforges a YouTube channels for beginners and any level of developers and we have Elixir mentor. We have chatgpt to ask questions. Don’t just stay okay in your programming language, advance daily
AstonJ
Here’s a neat tip from PragDave
https://twitter.com/pragdave/status/1000456904185966592
mrxrsd
More than tips, I’m trying to find repositories with sample code. I’m very fresh in FP (and Elixir too), I´ve already started @pragdave´s course too. It was a great source but I want to find more code to learn strategies of coding in FP because today all my code looks like an OO approach.
It’s easy to find tools and libs written in Elixir in github, but sites, apps and information systems that is my focus now it’s not so easy to find.
If someone knows or have any github repositories I will be gratefull.
OvermindDL1
Also, just to clarify, it is so the compiler can scan the exposed functions on the module to know what to import from which module.
/me wonders if an option on
importcould importonly: ...names without the compile-time checks, perhaps likeimport Blah, compile_check: false, only: [my_fun: 1, my_fun: 2, more_funs: 1, ...]josevalim
To clarify, both alias and import are fast to compile and both do not affect the runtime performance. The issue is that import implies a compile time dependency, aliases do not. When you do
import Foo,Fooneeds to be available at moment and the compiler will block until such happens.kelvinst
Reading @josevalim’s post on this thread just got another insight of tip:
Prefer
aliasoverimport. Aliasing is clearer (explicit is better than implicit), faster to compile and does not affect performance on runtime at all (I guess)!kelvinst
Oh, one more thing! Apply the “let it fail” philosophy wherever you can!
For example, instead of:
Do no match all clause, and let it fail for unknown scenarios:
Again, silly example, but what I mean is: exceptions like
CaseClauseErrorare better errors to get than unexpected values escaping out of your own code, believe me.kelvinst
Well, I’ve some:
Understanding some key concepts of Elixir, which @josevalim nailed explaining them on his keynote for last ElixirConf EU. For those who like to go straight to the point, is the “What is Elixir? (ElixirConf version)” part I’m talking about. What I mean is that, once you understand the concepts he talks about, you will understand how Elixir is made to work, and consequently do better code for Elixir.
Use railway oriented development, and
Kernel.SpecialForms.with/1is a great tool for it. Pipe operators are great when you have to make a simple job in many steps, but when you have to handle errors on any of these steps,withfits better.Another silly thing I do is to avoid var attributions on my functions, at all. I know, maybe a lot silly, but conceptually it’s very tight with what @AstonJ said. No attributions help me to think when I can extract another function to do something that I’m saving in a variable to use after. Of course, that’s not something to do in every single case, sometimes it’s a good idea to save calculated values which will be used a lot later. But most times, you could do this:
Without attributions:
I know, silly example, but on complex cases it can help you a lot. Hope you got what I mean.