mmport80

mmport80

Obviously I am playing devil’s advocate a litte - but -

I see incredible power when using abstract code. One can do a lot in a little space, pick out bugs easily, etc.

Sure, explicitness is good when you are learning.

But when you want write something reliable and maintainable you probably should be reaching for a suitable abstraction and that means explicitness is kryptonite in such cases.

What do you think?

Showing Posts 18 to 9

mmport80

mmport80 OP

good pt!

mmport80

mmport80 OP

Thanks for this. Appreciate it. You are right.

If I think about macros like mini compilers, and ways to create new semantics not readily available in Elixir.

They end up being a little like oil and water when it comes to composition and polymorphism etc.

axelson

axelson

Scenic Core Team

Additionally if you create a library whose only interface is a macro then it is not usable by other BEAM languages such as Erlang.

michalmuskala

michalmuskala

I would say that in general, macros belong to libraries. There are very few cases where I would consider defining a macro in an application.

For libraries my rule of thumb is to first define an interface of only functions and data structures and then evaluate if it needs macros to make it less verbose or nicer to use. The important bit is that macros shouldn’t be the first thing you start with. This leads to a much more flexible design.

mmport80

mmport80 OP

Yep, i agree that functional is a big jump already.

But don’t you lose a little from having /such/ an explicit macro?

If I have the some basic atoms which I compose and recompose together, I can reuse and compose to my heart’s content.

that’s why I am sort of suspicious of macros, they are not so much an abstraction, but a concretisation which I cannot really reuse easily..

Nice crystalisation actually, maybe that’s why I don’t like macros - because they often are not easily reuseable abstractions…

mmport80

mmport80 OP

Personally I think explicitness is a little overrated

Yup, me too, I suppose non-macro Elixir is v explicit, perhaps that’s why many people here picked me up wrong, the ABCs of abstraction are built from composition, parametric and adhoc polymorphism…

mmport80

mmport80 OP

Ecto is clearly in the Query builder / DSL region.

Thanks for the thoughtful reply, really appreciate it : )

mmport80

mmport80 OP

My point is, explicitness is a crutch sometimes, when really we want:

Explicitness /and/ DRY (i.e. a suitable abstraction)…

The good thing is, non-macro code comes is very easily explicit.

On a tangent, I would love somebody to point me to a good resource on how to use macros properly, I really need to get comfortable with that type of abstraction.

mmport80

mmport80 OP

Good pt. tbh. the macro abstraction balancing act is still something I have to fully get comfortable with. Perhaps because there is a lot left implicit!! I respect macros, but am constantly slightly worried about them : )

A simple example for “picking bugs out easily”, would be:

  1. I have an API
  2. I need to retrieve data from the DB
  3. many of my queries are similar
  4. I will write a function using Ecto queries etc. to cater for all / many of my use cases

I.e. classic parametric polymorphism. Bugs in my DB retrieval code are capture in one place…

Another example:

x) something which uses an interface and adhoc polymorphism, a result type or error type etc.

Bugs in my result / error code are again captured in one place, rather than scattered.

You get the idea. Basically it’s DRY.

mmport80

mmport80 OP

Yes 100% true. I was cheekily conflating “implicit” and “abstract”.

I suppose the question is, when someone says, this is well written because it is “explicit”, it can still be explicit and overly verbose, not DRY etc…

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 94592 917
New
cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
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
heathen
Quite interesting article Google brought me. Didn’t find any mentions about it here. What do you think in general? Would you use togethe...
New
marciol
It would be helpful to have a list of companies worldwide that hire engineers without prior experience in Elixir. Often, it can be quite ...
New
durvia
Anyone running long-lived stateful processes on BEAM? We’re building an AI agent runtime and would love to compare notes. We’re a small ...
New

Other Trending Topics Top

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
Damirados
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
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews