News for hackers. Stuff that matters.
Re:Kotlin Money by bayindirh on Tuesday October 08, 2024 @09:58AM (#41777460)
> However, no mainstream language has a first-class data type for representing money...

I beg to differ. Java has "Decimal" class which guarantees to be safe from IEEE754 floating number side effects, and specially created to handle cases like money and financial calculations.

In these days it's used as BigDecimal, it seems [1].

[0]: https://docs.oracle.com/javase/8/docs/api/java/text/DecimalF... [1]: https://docs.oracle.com/en/java/javase/23/docs/api/java.base...

Re:Kotlin Money by jeremyjh on Tuesday October 08, 2024 @10:06AM (#41777523)
Can BigDecimal tell me which currency a monetary value is denominated in?
Re:Kotlin Money by bayindirh on Tuesday October 08, 2024 @10:10AM (#41777569)
No, but Java has a specification (JSR 354) to build money and currency APIs [0].

A library built upon it can be found here [1].

[0]: https://jcp.org/en/jsr/detail?id=354

[1]: https://javamoney.github.io/

Re:Kotlin Money by mhluongo on Tuesday October 08, 2024 @10:09AM (#41777557)
Tell me you've never worked in fintech without telling me you've never worked in fintech :)

Decimals aren't enough. You have frequent currency conversions and all sorts of other chores. Using a fixed-decimal datatype doesn't solve those problems by itself, it's just a tactic.

Re:Kotlin Money by bayindirh on Tuesday October 08, 2024 @10:11AM (#41777575)
See JSR-354 then: https://jcp.org/en/jsr/detail?id=354

Yes, I never worked in fintech, but lots of my family members work or worked in banking sector. So, I'm not an alien when it comes to money, and how it works and processed in IT side of the things.