3 ms·
Show HN: Cashe - A money library written in Ada
Introducing Cashe: a Money library written in Ada 2022!
The purpose of Cashe is to give Money its own high-precision datatype taking advantage of Ada's fixed type decimal system[1]. This allows storing money, associated with a currency, at a defined precision with the choice of utilizing fuzzy or exact equality (see readme for more details).
It supports ISO Currencies[2] as well as Custom-defined currencies[3], and even a working Currency Exchange[4].
You can install it using Alire, which is Ada's package manager with a simple `alr with cashe`
There's quite a bit of examples in the readme if you would like to see what the code looks like, but I also gave full code examples for almost all of the functions in the API Documentation[5].
[1] https://github.com/AJ-Ianozi/Cashe/blob/main/src/cashe.ads https://github.com/AJ-Ianozi/Cashe/blob/main/src/cashe.ads
[2] https://github.com/ada-iso/ada_iso https://github.com/ada-iso/ada_iso
[3] https://aj-ianozi.github.io/Cashe/cashe-currency_handling_ads.html#robo1 https://aj-ianozi.github.io/Cashe/cashe-currency_handling_ad...
[4] https://aj-ianozi.github.io/Cashe/cashe-exchange_ads.html#robo2 https://aj-ianozi.github.io/Cashe/cashe-exchange_ads.html#ro...
[5] https://aj-ianozi.github.io/Cashe/toc_index.html https://aj-ianozi.github.io/Cashe/toc_index.html
- khalidx 3y agoFor those doing currencies in JavaScript, is it worth it calling out to a language like this that has better support for precision? How do you handle it in your code today?
- sa46 3y agoI use a hand-rolled Money class that’s an ergonomic wrapper around big.js, an arbitrary precision decimal library. I think using a separate language is massive overkill.
- jhvkjhk 3y agoCool. I always want to write my own beancount-clone with budgeting. How to deal with precision easily is one of the obstacles; now I wish I can write Ada!
- lemper 3y agoit's never too late to start learning, no?
- jhvkjhk 3y agoIt's on my TO-DO list!
- ajdude 3y agoI actually created this library with a budgeting app in mind! In my case, compliant with Ledger rather than Beancount. It's easier than ever to get into Ada these days. There's a bunch of tutorials on Adacore's website [1] with a playground/sandbox that you can mess with. With Alire[2] (which is to Ada what Cargo is to Rust), you can get the toolchain and any packages with a simple command. If you're on linux or mac, you can also use GetAda[3] that will automatically install Alire for you. [1] https://learn.adacore.com/ https://learn.adacore.com/ [2] https://alire.ada.dev/docs/#first-steps https://alire.ada.dev/docs/#first-steps [3] https://github.com/AJ-Ianozi/getada/tree/main https://github.com/AJ-Ianozi/getada/tree/main
- jhvkjhk 3y agoHa, I guess ledge-like users are the only group caring this topic. Thank you, Ada gave me an ancient feeling because they chose the first programmer's name. It seems to have modern tools, nice.