frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

Recursion is lying to you

https://blog.gaborkoos.com/posts/2026-05-09-Your-Recursion-Is-Lying-to-You/
9•theanonymousone•1h ago

Comments

RajT88•41m ago
CS 101, no? Recursion is easier to write, but less performant and more risky than iteration.
valleyer•31m ago
It's not CS 101 that JavaScript apparently sucks at TCO. That was surprising to me.
dnbfbfhf•20m ago
The CS 101 model of computing doesn’t have TCO… which makes it pretty accurate to the real world.
sras-me•30m ago
>Recursion is easier to write

And read..

veqq•28m ago
Risky?
makr17•18m ago
Presumably stack depth and overflow.
ventana•11m ago
A fun quote from the article, discussing a basic Fibonacci recursive implementation:

> Each call branches into two more calls, so the total number of calls grows as O(2ⁿ).

Well, no, not really. If anyone bothers counting how many recursive calls are actually made, the result is far from powers of two:

   n | result | # of calls
   1 |      1 |          1
   2 |      1 |          3
   3 |      2 |          5
   4 |      3 |          9
   5 |      5 |         15
   6 |      8 |         25
   7 |     13 |         41
   8 |     21 |         67
   9 |     34 |        109
  10 |     55 |        177
  11 |     89 |        287
  12 |    144 |        465
  13 |    233 |        753
  14 |    377 |       1219
  15 |    610 |       1973
  16 |    987 |       3193
  17 |   1597 |       5167
  18 |   2584 |       8361
  19 |   4181 |      13529
  20 |   6765 |      21891
A curious person will then calculate the actual ratio:

   n | result | # of calls |              ratio
   1 |      1 |          1 |                  1
   2 |      1 |          3 |                  3
   3 |      2 |          5 | 1.6666666666666667
   4 |      3 |          9 |                1.8
   5 |      5 |         15 | 1.6666666666666667
   6 |      8 |         25 | 1.6666666666666667
   7 |     13 |         41 |               1.64
   8 |     21 |         67 | 1.6341463414634145
   9 |     34 |        109 |  1.626865671641791
  10 |     55 |        177 | 1.6238532110091743
  11 |     89 |        287 | 1.6214689265536724
  12 |    144 |        465 | 1.6202090592334495
  13 |    233 |        753 | 1.6193548387096774
  14 |    377 |       1219 | 1.6188579017264275
  15 |    610 |       1973 | 1.6185397867104183
  16 |    987 |       3193 | 1.6183476938672072
  17 |   1597 |       5167 | 1.6182273723770748
  18 |   2584 |       8361 | 1.6181536675053223
  19 |   4181 |      13529 | 1.6181078818323167
  20 |   6765 |      21891 | 1.6180796806859339
and will notice that it gets close to φ = (1 + √5) / 2 ≈ 1.618033989, which makes the number of recursive calls O(φⁿ), which is much more fun than O(2ⁿ).
Chinjut•3m ago
Yes, because the number of calls in this setup is 2 * the next result - 1, and the Fibonacci sequence itself grows at this Θ(φⁿ) rate.
a-dub•6m ago
lol. i once interviewed with facebook and had some "senior" dev on the phone who was balking and grousing at my claim that iterative algorithms are faster than recursive ones. the minute i mentioned spatial locality, he went quiet.

more to the point, i feel like there should be a compiler switch or decorator style flag in modern languages that declare "this function is expected to optimize with tail recursion, throw a compiler or linter error at static analysis time if that doesn't work out."

senkora•3m ago
This exists in clang for C++ as the statement attribute [[clang::musttail]]

OpenAI just open-sourced Codex Security

https://github.com/openai/codex-security
69•bakigul•32m ago•5 comments

Substack writers, you need a website

https://elizabethtai.com/2026/06/10/substack-writers-you-need-a-website/
297•speckx•4h ago•162 comments

Steel Bank Common Lisp version 2.6.7

https://sbcl.org/all-news.html?2.6.7
144•tmtvl•4h ago•49 comments

Kimi K3 Architecture Overview and Notes

https://sebastianraschka.com/blog/2026/kimi-k3-architecture-notes.html
215•ModelForge•5h ago•24 comments

The iPhone Upgrade Program is being replaced by Apple Upgrade

https://www.apple.com/shop/iphone/iphone-upgrade-program
91•lkurtz•3h ago•154 comments

Delayed Gratification – Proud to Be 'Last to Breaking News'

https://www.slow-journalism.com/
185•speerer•5h ago•97 comments

MCP 2026-07-28 Specification: transport going stateless

https://blog.modelcontextprotocol.io/posts/2026-07-28/
68•Eldodi•2h ago•24 comments

The Fabled Flatbreads of Uzbekistan (2015)

https://www.aramcoworld.com/articles/2015/the-fabled-flatbreads-of-uzbekistan
45•jxub•4d ago•23 comments

Zig's Incremental Compilation Internals

https://mlugg.co.uk/posts/incremental-compilation-internals/
142•garyhtou•5h ago•106 comments

Interview with Boris Cherny [video]

https://www.youtube.com/watch?v=qyPCVqFUyDo
15•knighthacker•21h ago•3 comments

Discovering Cryptographic Weaknesses with Claude

https://www.anthropic.com/research/discovering-cryptographic-weaknesses
115•gslin•4h ago•63 comments

How Do I Profile eBPF Code?

https://naveensrinivasan.com/posts/2026-07-22-how-do-i-profile-ebpf-code/
95•snaveen•5h ago•6 comments

I sent Claude Opus 5 '–-' and it wrote me 5k tokens about a cartographer

https://austinsnerdythings.com/2026/07/28/claude-opus-5-dangling-document-effect/
15•auspiv•40m ago•6 comments

New HIV vaccine shows unprecedented success in preclinical study

https://www.lji.org/news-events/news/post/new-hiv-vaccine-shows-unprecedented-success-in-preclini...
483•codebyaditya•8h ago•219 comments

Show HN: How far do I have to go to run into 100k people?

https://imjasonh.github.io/playground/population-rays/
12•ImJasonH•4d ago•8 comments

Kimi Linear: An Expressive, Efficient Attention Architecture (2025)

https://arxiv.org/abs/2510.26692
253•ronfriedhaber•10h ago•109 comments

Show HN: XY – A Fast, composable, GPU-accelerated interactive plotting library

https://github.com/reflex-dev/xy
87•apetuskey•5h ago•32 comments

Harmony Explained: Progress Towards a Scientific Theory of Music (2012)

https://arxiv.org/abs/1202.4212
78•surprisetalk•6h ago•61 comments

Recursion is lying to you

https://blog.gaborkoos.com/posts/2026-05-09-Your-Recursion-Is-Lying-to-You/
10•theanonymousone•1h ago•11 comments

WOFF 1.0: a milestone on W3C's journey of fonts on the web

https://www.w3.org/blog/2026/woff-1-0-a-milestone-on-w3cs-journey-of-fonts-on-the-web/
49•hn_acker•4h ago•2 comments

Now Is the Time to Give LLMs Access to the ACM Digital Library

https://cacm.acm.org/opinion/now-is-the-time-to-give-llms-access-to-the-acm-digital-library/
86•rbanffy•6h ago•64 comments

Anthropeum – Where in the world, and when, does this human artifact belong?

https://anthropeum.com/
119•bookofjoe•6h ago•34 comments

Una GPS smart watch – Repairable, USB-C charging, developer-friendly

https://unawatch.com/
93•pimterry•6h ago•62 comments

How to survive boiling water

https://taxa.substack.com/p/how-to-survive-boiling-water
410•cainxinth•4d ago•90 comments

Uv 0.12.0

https://github.com/astral-sh/uv/releases/tag/0.12.0
76•hallvard•1h ago•33 comments

Stop Killing the Internet: No Digital ID and No Age Verification

https://citizens-initiative.europa.eu/initiatives/details/2026/000011_en
404•doener•6h ago•122 comments

DMARC has been public since 2012 but most company domains still don't enforce it

https://ciphercue.com/blog/dmarc-enforcement-gap-rua-fragmentation-2026
160•adulion•11h ago•100 comments

Hulios: An eBPF-powered, transparent Tor gateway for Linux

https://github.com/ghaziwali/Hulios
11•ghaziwali•1h ago•0 comments

The most advanced robotic servicing satellite–that we know about

https://arstechnica.com/space/2026/07/this-is-the-worlds-most-advanced-robotic-servicing-satellit...
26•GlenTheMachine•4d ago•1 comments

So, you want to make a game engine (2023)

https://lisyarus.github.io/blog/posts/so-you-want-to-make-a-game-engine.html#part-3
49•kugurerdem•5h ago•30 comments