Cyytrus

Cyytrus

Why isn't `:timer` an Elixir module yet?

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.

Most Liked

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 #4
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.

kevinschweikert

kevinschweikert

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

Last Post!

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.

Where Next?

Popular in Discussions Top

AstonJ
Are there any Elixir or Erlang libraries that help with this? I’ve been thinking how streaming services like twitch have exploded recentl...
New
chulkilee
Here are the list of HTTP client libraries/wrappers, and some thoughts on HTTP client in general. I’d like to hear from others how they w...
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
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 40042 209
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
Fl4m3Ph03n1x
Background This question comes mainly from my ignorance. Today is Black Friday, one of my favorite days of the year to buy books. One boo...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44139 214
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

We're in Beta

About us Mission Statement