Cyytrus

Cyytrus

Currently, Elixir relies on :timer from Erlang’s stdlib. However, in every company I’ve worked at, I’ve noticed developers manually calculating milliseconds rather than using this library. This results in code that’s harder to read and less semantically clear.

This makes me wonder: why hasn’t :timer been ported to Elixir? Is there community interest in having a native Elixir timer module? I’m seriously considering opening a PR to implement it, but I’d like to understand if there are technical or philosophical reasons it hasn’t been done yet.

Showing Posts 1 to 10

kevinschweikert

kevinschweikert

Welcome! Since 1.17 there’s Kernel.to_timeout/1 which should make calculating milliseconds obsolete

jswanner

jswanner

Welcome @Cyytrus!

There is a recent addition to Elixir to turn durations to milliseconds: Kernel — Elixir v1.20.2

Separately, since we can use Erlang functions directly, there’s no need to port things to Elixir unless something is going to be improved in the process (like developer ergonomics)

LostKobrakai

LostKobrakai

Besides the other answers: Erlang modules are generally not „ported“ just for the sake of a port existing. You can call erlang modules just fine, please do so. No need for a shallow port. The new to_timeout for example exists to integrate with the new elixir duration definition handling.

10
Post #3
BartOtten

BartOtten

There is of course the split of documentation and as such less knowledge of erlang modules. So I do see use in shallow copies.

dimitarvp

dimitarvp

I agree that’s a real problem and have been bitten by it a good amount of times. But I started seeing it as a “git gud” thing. We can’t constantly duplicate code for surface conveniences. API reshaping, using different contracts, hell, even swapping function argument positions so we can do Elixir pipes, all those are somewhat valid scenarios for introducing shims / wrappers. But just because I or somebody else has not tried to look if Erlang stdlib can help them? I’d say it’s not needed then.

hauleth

hauleth

The same can be said about any function in any library. I do not think that “having single place to search for documentation” is valid argument for maintenance burden of wrapping everything.

sodapopcan

sodapopcan

Ya, seems more like a need for better cross-document searching. Easy to say, harder to do, though. I confess that even though I’m all-for not-shallow wrapping, I almost never think to look in the Erlang docs if I can’t find an Elixir function :thinking:

hauleth

hauleth

For that I highly suggest Dash on macOS (or equivalent like DevDocs.io or Zeal). That provides you offline docs search ad you can add all docs you need.

BartOtten

BartOtten

That I do see use is not to say I advocate for shim libs. After all: where to stop, who keeps them up to date, do we adapt to Elixir conventions, will we use opt lists or maps etc etc.

On the other hand: the need to point to Erlang stdlib it’s not that great. The user suddenly has to know ‘their’ conventions, their doc system and ask questions about it at erlangforums.

brkn

brkn

Keeping it up to date might not be hard. I checked the commit history of erlang’s timer module, it has 12 commits that change source code for the last 5 years (I’m counting very liberally, spec and doc changes are included). Most of them are tiny.

— All posts loaded —

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 92995 915
New
AstonJ
The obligatory hello world thread! Who are you and where are you from? :stuck_out_tongue:
4616 55835 594
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
arcanemachine
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, 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
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
matt-savvy
Is there a word for the ~> symbol used in Version strings? Do you also just call it a Squiggle Arrow™ ?!
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
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
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
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