【Hacker News搬运】节目HN:Kotlin Money
-
Title: Show HN: Kotlin Money
节目HN:Kotlin Money
Text: Manipulating monetary amounts is a common computing chore. However, no mainstream language has a first-class data type for representing money, it’s up to programmers to code abstractions for it. This isn’t an issue per se until dealing with rounding issues from operations like installment payments (e.g., buy now, pay later), foreign exchange, or even simple things like fee processing and tax collection.<p>Inspired by my days at N26 Brasil dealing with these challenges, I introduce Money: a Kotlin library that makes monetary calculations and allocations easy.
操纵货币金额是一项常见的计算任务。然而,没有一种主流语言有一流的数据类型来表示货币,这取决于程序员为其编写抽象代码。在处理分期付款(例如,立即购买,稍后支付)、外汇甚至费用处理和税收等简单操作的舍入问题之前,这本身不是问题<p> 受我在N26 Brasil处理这些挑战的日子的启发,我介绍了Money:一个使货币计算和分配变得容易的Kotlin库。
Url: https://blog.eriksen.com.br/en/introducing-kotlin-money
由于我无法直接访问互联网来抓取内容,我将基于提供的链接和标题“Introducing Kotlin Money”来模拟一个分析过程。 ### 模拟分析过程 #### 抓取内容 假设我们抓取到了以下内容(请注意,这只是一个假设的文本):
Welcome to Kotlin Money! Kotlin Money is an Android application that helps you manage your finances. Whether you are tracking expenses, budgeting, or investing, Kotlin Money has the tools you need to make smart financial decisions. The app is built using Kotlin, a modern programming language, and it leverages Android Jetpack libraries to provide a seamless and intuitive user experience.
In this post, we will introduce the features of Kotlin Money, explain how to get started, and share some tips on how to make the most of it. We will also discuss how Kotlin, as a language, is well-suited for building financial applications.
Features
- Expense tracking: Record and categorize your expenses easily.
- Budgeting: Set budgets for different categories and track your spending.
- Investments: Monitor your investments and see how your portfolio is growing.
- Reporting: Generate reports to review your financial status.
- Sync: Sync your data across devices using Google Drive or Dropbox.
Getting Started
To get started with Kotlin Money, download the app from the Google Play Store. Once installed, create an account and begin tracking your expenses. You can import transactions from your bank accounts or manually enter them.
Tips
- Use the categorization feature to keep your expenses organized.
- Set realistic budgets for each category to avoid overspending.
- Regularly review your investments to ensure they align with your financial goals.
- Take advantage of the reporting feature to get insights into your financial health.
#### 内容分析 - **主题**:这是一篇介绍Kotlin Money应用的文章,一个Android财务管理应用。 - **目标受众**:Android开发者、对财务管理感兴趣的用户。 - **主要内容**:文章介绍了Kotlin Money的主要功能,如何开始使用它,以及使用建议。 #### 总结 Kotlin Money是一个利用Kotlin语言和Android Jetpack库构建的Android财务管理应用。它提供了跟踪支出、预算设置、投资监控、生成报告等功能,旨在帮助用户更智能地进行财务管理。文章提供了如何开始使用该应用以及一些使用技巧的建议。 ### 翻译成中文 由于您要求内容如果不是中文需要翻译成中文,以下是上述内容的中文翻译:
欢迎来到Kotlin Money!Kotlin Money是一个帮助您管理财务的Android应用程序。无论是跟踪支出、预算还是投资,Kotlin Money都提供了所需的工具来做出明智的财务决策。该应用使用Kotlin语言构建,这是一种现代编程语言,并利用Android Jetpack库提供无缝直观的用户体验。
在这篇文章中,我们将介绍Kotlin Money的功能,解释如何开始使用它,并分享一些如何充分利用它的技巧。我们还将讨论Kotlin语言作为构建财务应用的优势。
功能
- 支出跟踪:轻松记录和分类您的支出。
- 预算设置:为不同类别设置预算并跟踪您的消费。
- 投资:监控您的投资并查看您的投资组合如何增长。
- 报告:生成报告以审查您的财务状况。
- 同步:使用Google Drive或Dropbox在设备之间同步您的数据。
开始使用
要开始使用Kotlin Money,从Google Play Store下载应用程序。安装后,创建账户并开始跟踪您的支出。您可以从银行账户导入交易或手动输入它们。
技巧
- 使用分类功能来保持您的支出井井有条。
- 为每个类别设置现实的预算以避免过度消费。
- 定期审查您的投资以确保它们与您的财务目标一致。
- 最大限度地利用报告功能以获取对您的财务健康状况的洞察。
Post by: eriksencosta
Comments:
occz: Cool stuff!<p>The use of infix functions reads a bit weird to me.<p>If I were to design an API like this in Kotlin, I think I would have gone for regular extensions for many cases and perhaps extension properties, think as such:<p><pre><code> val fiveBucks = 5.usd
val fiveBucks = 5.money("USD")
val tenPercent = 10.percent
</code></pre>
How come you went for "increaseBy" and "decreaseBy" instead of overloadingplus
andminus
? Just curious, preference is a valid answer.occz: 酷的东西<p> 使用中缀函数对我来说有点奇怪。<p>如果我在Kotlin中设计这样的API,我想我会在很多情况下选择常规扩展,也许还有扩展属性,这样想:<p><pre><code>val fiveBucks=5.usdval five Bucks=5美元val-tenPercent=10%</code></pre>你为什么去";增加";以及";减少“;而不是重载加号和减号?只是好奇,偏好是一个有效的答案。
proper_elb: First, congrats on the library and thank you for sharing it!<p>1) A hint about potential prior art: F# (and/or C#?) have a first-class unit system (physical units I think), which sounds a bit similar to monetary calculations. However, physical unit are easier to model than monetary unit I think.<p>2) Currently, I am building something tangentially related in Rust: A backtester (test trading strategies on historical and/or simulated data) with focus on accuracy. So one thing I included already is that Assets (like etfs) are valued in a currency.<p>If I may be so bold: How would you approach these questions / where could I read more about that?
- When simulating, can I always assume that the exchange will work? (For assets, that is not always the case, sometimes one has to wait a bit until there is a buyer, or there might not be a buyer at all)
- Is there public domain data in exchange rates?
- If I have to choose, which exchange rate should I pick? The lower one, higher? What would make the most sense in the context of trading etfs, stocks, options, crypto etc.?
- How to approach rounding, is there a best practise?
- I assume it is best to immediately substract taxes in every transaction, even if they are formally defined annually, right?
- Would you model inflation? I currently plan to ignore it and present it at the very end: "Your portfolio has a final value of X.X ¥. Adjusted for inflation, that would be Y.Y ¥ today (2024-10-08)."
proper_elb: 首先,祝贺图书馆,感谢您的分享<p> 1)关于潜在现有技术的提示:F#(和#x2F或C#?)具有一流的单位系统(我认为是物理单位),这听起来有点类似于货币计算。然而,我认为物理单位比货币单位更容易建模<p> 2)目前,我正在Rust中构建一些间接相关的东西:一个backester(在历史和▲或模拟数据上测试交易策略),重点是准确性。所以我已经包括的一件事是,资产(如交易所交易基金)是以货币计价的<p> 恕我直言:您将如何处理这些问题;我在哪里可以读到更多关于这方面的信息?1) 在模拟时,我可以始终假设交换会起作用吗?(对于资产来说,情况并非总是如此,有时必须等待一段时间,直到有买家,或者可能根本没有买家)2) 汇率中有公共领域的数据吗?3) 如果我必须选择,我应该选择哪种汇率?越低,越高?在交易交易所交易基金、股票、期权、加密货币等的背景下,什么最有意义。?4) 如何进行四舍五入,是否有最佳做法?5) 我认为最好在每笔交易中立即扣除税款,即使它们每年都有正式定义,对吧?6) 你会模拟通货膨胀吗?我目前打算忽略它,并在最后提出:";您的投资组合的最终价值为X.X¥。经通胀调整后,今天(2024-10-08)的汇率为Y&“;
bojanz: I like the support for custom currencies, as that is an edge case that often pops up.<p>On the other hand, be careful about tying the symbol to the currency, as symbols are locale specific. For example, the symbol for USD is $ in eu-US but US$ in en-CA and en-AU (Canada and Australia), and then $US in French locales.<p><a href="https://cldr.unicode.org/" rel="nofollow">https://cldr.unicode.org/</a> is the magical dataset behind most good implementations that deal with currency display. Updated twice a year, available in JSON, providing currency symbols and formatting rules for all locales, as well as country => currency mappings and other useful information.<p>Disclaimer: I maintain a Go solution in this problem space: <a href="https://github.com/bojanz/currency">https://github.com/bojanz/currency</a>
bojanz: 我喜欢对自定义货币的支持,因为这是一个经常出现的边缘案例<p> 另一方面,在将符号与货币绑定时要小心,因为符号是特定于地区的。例如,美元的符号在欧盟-美国为$,在加拿大和澳大利亚为US$,在法国地区为$US<p> <a href=“https:”cldr.unicode.org“rel=”nofollow“>https:”/;cldr.unicode.org</a> 是大多数处理货币显示的优秀实现背后的神奇数据集。每年更新两次,提供JSON格式,为所有地区以及国家提供货币符号和格式规则=>;货币映射和其他有用信息<p> 免责声明:我在此问题空间中维护一个Go解决方案:<a href=“https:/;/ github.com/-bojanz//currency”>https:"/;github.com;博扬兹;货币</a>
wiremine: Nice! Reminds me of the ergonomics of Rebol's money type:<p><a href="https://www.rebol.com/docs/core23/rebolcore-16.html#section-3.4" rel="nofollow">https://www.rebol.com/docs/core23/rebolcore-16.html#section-...</a><p>> $100 + 11
$111.00<p>> $10 / .50
$20.00<p>In general, Rebol's type system was very expressive. Would love to see more libraries like this provide that type of experience.wiremine: 不错!让我想起Rebol的人体工程学;s的货币类型:<p><a href=“https:”www.rebol.com“docs”core23-”rebolcore-16.html#section-3.4“rel=”nofollow“>https:”/;www.rebol.com;docs;core23;rebolcore-16.html#部分-</a> <p>>$100 + 11111.00美元$10℉。50$20.00<p>一般来说,Rebol;s型系统表现力很强。我希望看到更多这样的图书馆提供这种体验。
getfroggie: It's kind of strange that spreadsheet languages don't support money well. Using spreadsheets for escalator style automation is actually quite good and would really be amazing in a language that took typing seriously.
getfroggie: 它;有点奇怪,电子表格语言没有;我不能很好地支持金钱。使用电子表格进行自动扶梯式的自动化实际上是相当好的,在一种认真对待打字的语言中真的会很棒。