Zero-Based Counting: A Family Matter
Description
A four-panel comic strip in the style of Cyanide & Happiness, titled 'Programmer dads be like'. In the first panel, a father figure tells his young son, 'count to ten'. In the second panel, the son begins counting, '1, 2...'. The third panel shows the father crying, saying, 'you're not my son'. The final panel depicts the sad-looking child sitting alone on the steps of a building with a red sign that reads 'ORPHANAGE'. The joke is a classic in the programming community, revolving around the concept of zero-based indexing, where arrays and lists in many programming languages start their index from 0, not 1. The father, a stereotypical programmer, expects his son to start counting from zero. The son's failure to do so leads to this extreme and humorous reaction, highlighting a fundamental disconnect between a programmer's mindset and the conventional way of counting
Comments
14Comment deleted
That kid will never understand the off-by-one errors he just introduced into his life
Kid started counting at 1, so Dad moved him to OrphanageService - around here, off-by-one errors are handled by garbage collection
The real tragedy isn't the orphanage - it's that the kid will grow up using MATLAB or Fortran where arrays start at 1, forever bringing shame to the family's git history
This perfectly captures the existential crisis every programmer faces when asked to count naturally - after years of `for(int i=0; i<n; i++)`, starting at 1 feels like a syntax error in real life. The orphanage ending is the logical conclusion when your parent-child relationship throws an IndexOutOfBoundsException because you're not at position 0
House policy: loops are [0, n); start at 1 and you’re adopted by MATLAB and Lua
Parent calls exit(0) sans waitpid(): kid's now init's headache, orphanage edition
Programmer dad turns “count to ten” into a boundary test: expected [0,10), kid returned [1..10]; classic off-by-one - reassigned to the MATLAB team
I know company, which uses 1 as an first array index, instead of 0, in their apis. And that is really confusing. Comment deleted
Bruh Comment deleted
Matlab moment Comment deleted
lua lua Comment deleted
Pascal, pl/sql and others do that too. The C is the only reason everybody does it like this now. And C does that because it is actually assembly for lazy people and it does not care. And the array index is just used for relative adresing, so obviously it starts with 0. Comment deleted
https://python-history.blogspot.com/2013/10/why-python-uses-0-based-indexing.html?m=1 Languages that use associative arrays exclusively like AWK and Lua do not care, they could start at "A" like spreadseets and it'd be all the same, it's just a convention. And then there is Ada where range of allowed indices is part of the type signature of the array and it could go from 5 upwards if you really wish. Or index with any enum. Comment deleted
Yes, in pascal you can also define any range and use it. Comment deleted