slouchpie

slouchpie

Money libraries - which do you use and why?

There seem to be 2 Elixir “Money” libs:

and neither one makes reference to the other.

Personally, I use the kipcole9 one, a.k.a :ex_money because it seems to be more well-considered (it uses :cldr_utils) and the author is very active here (Ex_money - money with currency type).

However, my library of choice is “less popular” (less stars and forks) on Github.

So I am wondering what other people think. Is one library better than the other? Is it bad to have 2 competing libraries doing much the same thing? Is it possible to achieve approximate consensus on which library deserves to be the de-facto money library for Elixir?

First 10 of 14 Posts! Switch mode

egze

egze

I remember that kipcole9/money took much more time to compile and we replaced it with plain Decimal. Decimal — Decimal v3.1.1

I used elixirmoney/money also before and it just worked.

slouchpie

slouchpie

kipcole9/money takes more time to compile because of :cldr. As per the docs

Cldr attempts to maximise runtime performance at the expense of additional compile time.

When using just :decimal, did you find it hard to account for all of these: GitHub - ex-money/money: Elixir implementation of Money with Currency · GitHub Personally I am unable to bear the mental burden of keeping these things in mind when working with money so that’s why I use :ex_money, a.k.a. kipcole9/money.

egze

egze

Yepp, I read it. Our use case was quite simple, so we were fine.

LostKobrakai

LostKobrakai

My take is that the :money library is mostly providing a datatype, while :ex_money is a toolkit of dealing with money, especially in an internationalized fashion.

Some of those factors:

  • Available currencies
    In :money the list of currencies is static/hardcoded and you can only add additional ones. :ex_money depends on :cldr for currencies instead of maintaining a list on it’s own and also has means for adding additional ones.
  • Rounding rules (a.k.a. business rules of currencies)
    With :cldr in the back :ex_cldr does not only know the number of decimal places a currency uses, but also about things like alternate rounding rules, like when cash is supposed to round differently than e.g. accounting.
  • Formatting
    :money does only support a single set of default formatting or customized per API call. :ex_money again uses :cldr to adjust formatting to settings matching a certain locale (like the users’).

So all in all it’s :ex_money for me if only for the fact of harnessing the knowledge of a unicode maintained database of those mentioned things as opposed to a library maintainer having a (likely worse) maintained copy of it.

11
Post #4
slouchpie

slouchpie

This is a good summary of the main differences between the 2 libs.
I think this should be made clear in the Github READMEs of both libs.

slouchpie

slouchpie

Thank you for contributing to the conversation (and to those libraries!).

For me, I like to keep my apps globally applicable, so I care about the use of :cldr and the ability to configure which locales/countries/currencies my app understands and can work with. Moreover, if you want to use cryptocurrencies, it behooves developers to be able to define their own custom currencies.

What I am looking for is for the community to confirm that one library is “more correct” or “more comprehensive” than the other. I believe, right now, that :ex_money, a.k.a. kipcole9/money is both more correct and comprehensive and yet has less stars and forks on Github (which might influence new Elixir devs).

strzibny

strzibny

Yes, I think the use of :cldr is an excellent point.

Every library can have its users, there does not have to be a more correct one. Is Phoenix the most correct web framework for Elixir?

slouchpie

slouchpie

With that in mind, I think the 2 libs should reference each other. A new Elixir dev visiting github would not know which lib to choose.

mindok

mindok

I’m sure the maintainers would appreciate a PR to the readmes (and maybe the docs) to include those references :wink:

Last Post!

lukaszsamson

lukaszsamson

ElixirLS Core Team

In my company (fintech domain) mostly Decimal as integrates nicely with ecto. The library used to be buggy (I and my coworkers authored a few PRs) but that’s no longer the case. The biggest problem with Decimal now is performance. In case of performance sensitive code we use plain old integers or even NIFs.

Where Next?

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...
2976 91332 914
New
f0rest8
Hi everyone :waving_hand: Posting here to showcase and announce that Metamorphic is now officially live on a public-facing domain at htt...
New
byu
@chrismccord : I just saw the Extract AGENTS.md from Phoenix.new into phx.new generator commit to the phoenix project. My initial shotgu...
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
AstonJ
Just a general thread to post chat/news/info relating to AI/ML stuff that may be relevant for Nx now or in the future. Got anything to sh...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
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
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
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
zachdaniel
Introducing AshStorage! Attachment and file management that slots directly into your resources :smiling_face_with_sunglasses: I had hope...
New

We're in Beta

About us Mission Statement