Math Not Required (2023)

https://news.ycombinator.com/rss Hits: 4
Summary

I want to be very clear: this article is examining whether or not math is essential background knowledge for programmers. It is not arguing that math is not important or valuable.I believe that most people can benefit from learning some math! You are absolutely affected by math in your day-to-day life, whether you understand it or not.For example, many adults have a credit card. Credit cards typically come with an Annual Percentage Rate (APR), which is pretty confusing since most cards calculate daily compound interest. Compound interest could be considered the eighth wonder of the modern world and, when you compound it daily, it's simply terrifying. It's vital to understand at least the magnitude of how this grows if you carry a significant balance.However, if you don't know this, programming might be able to save you! Let's build a model for credit cards: defmodule CreditCard do defstruct balance: 7_279.0, apr: 24.45, daily_periodic_rate: nil, minimum_percent: 0.02, minimum_floor: 27.5, last_due: nil def new(fields \\ []) do fields |> Keyword.put_new_lazy(:last_due, &Date.utc_today/0) |> then(&struct!(__MODULE__, &1)) |> then(fn card -> %__MODULE__{card | daily_periodic_rate: card.apr / 100 / 365} end) end def payment_schedule(card, overpayment \\ 0) do Stream.unfold(card, fn %__MODULE__{balance: 0.0} -> nil card -> payment = CreditCard.Payment.new(card) |> CreditCard.Payment.advance_due_date() |> CreditCard.Payment.accrue_interest() |> CreditCard.Payment.apply_payment(overpayment) {payment, payment.card_after} end) end endThis code above is mostly just a data structure. The defaults you see came from Google:The CreditCard.payment_schedule/2 function provides a public interface for repeatedly making payments, until the balance reaches zero. A payment involves a few steps, but the keys bits are that interest is accrued for days past and then a payment is applied to the new total. A minimum payment is always made, but we can choose to pass an overpayment amount.The ...

First seen: 2025-08-24 21:11

Last seen: 2025-08-25 00:11