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?
Trending in Discussions
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...
New
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
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
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
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
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
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
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
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
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 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
LostKobrakai
For me explicitness is not about “not using abstractions”. It’s that the code I use is explicit in what it does (no matter how abstract it is) and it does not do anything I don’t expect. Take elixir macros for example. I don’t need to know how a macro is implemented to have a macro, which is explicit in what it does. E.g. in a project of mine I’m using macros to setup breadcrumb texts/urls. I still need to supply url/title/parent in the macro for a page, which is the things I need to deal with, but how the elements of the breadcrumb are build up and merged is hidden in the macro. Compare that to an implicit calculation from e.g. a module name. There I’m bound to a naming schema or something and can no longer explicitly set e.g. a different parent. I’d consider both “abstract” ways to build up a breadcrumbs list, though.
Also a functional language goes a long way here, as side effects are not littered all over the place to begin with, so the chance for unexpected results is smaller than in oop.
tmbb
Personally I think explicitness is a little overrated. What I value more than explicitness is composition (and explicitness certainly helps in that department) and runtime deterministic performance. That means I don’t care much if my elixir macros launch nuclear missiles at compile time, as long as they generate nice “static” and predictable code. Even if such code is divorced from the macro invocation. And most things that macros do is just defining new modules and functions or expand into normal elixir syntax.
Contrast this with python, which doesn’t really support compile time metaprpgramming and must use runtime (load time? Boot time?) metaprogramming.
Elixir does allow you to compile code on the fly, but as long as you keep away from such things, you’re pretty safe.
I don’t like using the nqme of the module in macros (like phoenix does for the MVC part), but as long as it’s easy to override it’s not too bad.
cmkarlsson
I think you have it the other way around
Explicit doesn’t mean you can’t have good abstractions. In terms of reliability and maintainability I’d pick explicit over implicit (but as we’ll see it is not that simple)
I’d say in terms of how easy something is to learn I think implicit is probably easier because of information hiding. For example, elixir makes a number of things that are explicit in erlang implicit and from what I understand a big reason behind this is to make it easier to learn. It doesn’t change the abstraction though, it is still the same (think gen server optional callbacks). It is just that it pushes the time a beginner need to learn about a concept further into the future. In the gen server case, the implicit call backs may actually hurt maintainability as you can easily miss to implement a callback. So in general I think things are made implicit to do things faster now so that you don’t have to understand things until later.
I don’t think explicit implicit is enough though so I misuse a few other terms to try to make things clearer.
Are these scientific terms? Yes. Am I using them correctly? Probably not
How these combine gives you an overall idea which trade-offs are being made. Lets take a common example. ORM vs SQL.
SQL is explicit, but not terse. It is a good abstraction accessing relational data. SQL is not very expressive. ORM is implicit and terse. The abstraction is only good at the basic level. The query level of an ORM can be very expressive.
In terms of “learnability” I think ORM seems to have the upper hand, likely because it hides away important information you really should now before using it. Hence, implicit can be technical debt.
Is there a middleground? Yes, some query builders. They have the benefit of SQL in that the abstraction over data is good but they are also terse and expressive. The “query builders” are explicit, while still keeping a good abstraction. They are more maintainable and reliable than SQL and ORM. I’m not quite sure where
ectois in all this. I think somewhere in the middle but towards the ORM layer (just a feeling, no concrete data behind this).josevalim
I think you would have to first define what is explicitness.
Some could say that managing your own memory is very explicit but I am sure we would collectively agree that we don’t want to allocate memory by hand. Doing so would get in the way of other things, such as your business logic.
Explicitness is not about lacking abstractions. Often those things go together: macros are a high form of abstraction, so we want their use to be explicit.
Explicitness is not about outlining all of the configurations to a function or a library instead of relying on good defaults. It is not against convention over configuration.
Explicitness is about making the choices clear when we believe those choices matter. It is about readability. We use explicitness when we believe omitting information is harmful to the understanding of the software compared to clearly spelling it out.
We will likely agree on many things that need to be explicit but others things will be guided by opinions and/or personal experience.
peerreynders
Care to elaborate on the “pick out bugs easily” part?
If this is primarily about macros then it is important remember that there are always tradeoffs involved. Example:
Evidently it’s equivalent to:
which isn’t transparent on first sight unless you are already familiar with
In a way the macro invocation is an alternate representation (compression) of the code that it will leave behind. That succinctness suppresses certain details (which may be desired) some of which could improve clarity (e.g. showing how the resulting code connects and relates to the “rest of the world”). The only way to compensate for that lack of exposed detail is to understand what the macro actually represents. So improved succinctness may also increase the cognitive load for anybody trying to comprehend what the code does.
In many situations the tradeoff is worth it. But every case is still is a balancing act between the benefits of succinctness, reuse potential and the effect on clarity and comprehensibility. Not all abstractions are created equal.
OvermindDL1
Uh, what? o.O
Abstract is not the opposite of explicit, implicit is the opposite of explicit. You can be perfectly abstract with either explicit or implicit.
As for between explicit and implicit, explicit means things are obvious in what they do, few to no surprises (
4 = 2+2), where implicit means that you cannot necessarily understand what is happening or that it is surprising ([2, 2] = 2+2).Perl may be more succinct than python, but that is because they chose different syntax, the actual ‘tokens’ between them is pretty equal, however perl is more ‘implicit’ in that you cannot always know what, say, a function will return or even ‘do’ at all when called at a certain place unless it is in, oh, a scaler or list context, and even then this can be surprising depending on where ‘this’ code is called and so forth. Perl has a lot of ‘surprise’ because of it’s implicit/hidden state, where Python is far more explicit by default.
dimitarvp
Definitely not. That just means you are delaying actual thinking about your code for a later point in time. Usually denoted by the concept of technical debt.
“I will do it later” is a not a good time and effort management technique.
mmport80
I suppose from my pov, what I was thinking about, is not Ruby on Rails style doing “one thing well in a little space” but Haskelly academic style abstraction etc. : )
Which is a bit more thoughtful up front : )
mmport80
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…
mmport80
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:
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.