frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

LoC Is a Dumb Metric for Functions

https://theaxolot.wordpress.com/2025/10/18/loc-is-a-dumb-metric-for-functions/
18•Axol•4h ago

Comments

al_borland•4h ago
LOC is often a rough approximation for complexity. We once had an intern who made some useful things, but he didn’t know how to break anything down. One of them was a 1,000 line perl all as one function. I asked if it could be broken down into something more maintainable and he said no. There were several projects like this.

Knowing At a high level what needed to happen to accomplish what the code did, I know for a fact it could have and should have been broken down more. However, because of the complexity of what he wrote, no one had the patience to go through it. When he left, the code got thrown away.

While 10 LOC vs 50 LOC doesn’t matter, when commas enter the number, it’s a safe bet that things have gone off the rails.

manwe150•2h ago
Seems like the article missed an opportunity to talk about testing and MC/DC coverage. I don’t care if the PR is long or short, just show me that you have meaningfully tested how each branch can be reached with the full range of values and behaves correctly. Unit testing is easier with well chosen interfaces and worse without them, regardless of LOC.
mrheosuper•2h ago
>When he left, the code got thrown away.

Why even merging his code at first place. He was intern so i assume whatever he was working on was not mission critical.

al_borland•1h ago
They were one-off projects where he was the sole dev, not part of a larger project. While not mission critical, the 1k line Perl script was helpful at the time. When we ran into a specific issue it allowed for recovery in minutes vs hours. We eventually added safeguards which prevented the issue from happening in the first place.
jcranmer•1h ago
> While 10 LOC vs 50 LOC doesn’t matter, when commas enter the number, it’s a safe bet that things have gone off the rails.

There are times when even a 1,000 LOC function is the better solution. The best example I can think of involve a switch statement with a very high branch factor (e.g., 100), where the individual cases are too simple to break out into separate functions. Something like the core loop of an interpreter will easily become a several-thousand line function.

imoverclocked•1h ago
Cyclomatic complexity is not equal to LOC and cyclomatic complexity of a switch can be seen as adding just 1 to its enclosing function. Either way, LOC is still not a great metric while cyclomatic complexity approaches a better one.

In my experience, there are very few places where something can't be broken up to reduce cognitive overhead or maintainability. When a problem is solved in a way as to make it difficult to do then maybe it's better to approach the problem differently.

zdragnar•25m ago
Higher cyclomatic complexity requires more lines (barring bad code style like writing an entire program on a single line).

The inverse is not always true, but often is.

morshu9001•1h ago
That's a special case
kqr•24m ago
I would argue an interpreter that needs 1,000 lines for its core loop is probably a complex piece of software, comparable to other 1000-line projects I've made.
hu3•7m ago
> I asked if it could be broken down into something more maintainable and he said no.

This is something AI is good at. It could have shown the intern that it is indeed possible to break such function without wasting an hour of a seniors time.

000ooo000•2h ago
>Use your judgment, and don’t be bullied by people who prescribe specific line numbers.

Ironic way to end an article that repeatedly belittles the target audience.

klysm•59m ago
Use your judgement, don’t be bullied by people who prescribe using your judgment.
WillAdams•1h ago
For a longer, more detailed take on this see:

https://www.youtube.com/watch?v=bmSAYlu0NcY

which is for the book:

https://www.goodreads.com/book/show/39996759-a-philosophy-of...

schrodinger•28m ago
This needs more than just an upvote — that's one of the best software engineering books I've ever read!
morshu9001•1h ago
The whole point of a rule-of-thumb is to be dumb. There are very few good reasons for a 500 loc func, and the code reviewer won't want to verify it's as simple as you claim. You could still have a 50 loc func that's overly complex, and they'll complain about complexity instead of length.

One consideration is that about 40 loc will comfortably fit in one code split, and it's nice if one func will fit in 1-2 splits. Past that length, no matter how simple it is, the reader will have to start jumping around for declarations. That might be ok at first, but at some point the ratio of offscreen to onscreen code gets too big.

fragmede•1h ago
I wonder if there is a way to see how physical monitor quality and size improvements have led to more complicated code, nevermind moving off of punch cards.
morshu9001•1h ago
The type of monitor doesn't matter a whole lot because it's really limited by human eyesight. High-res monitor will enable rendering things tiny if you disable hi-dpi, but then it's unreadable. If you use a big 8K TV to display everything larger, you have to sit further away to comfortably view it. If you add more monitors, at some point it becomes too hard to look at so many things at once.

Personally, my setup has shown the same number of vim rows/cols on my 4K monitor vs my 1080p one (or whatever you call the 16:10 equivalents).

nine_k•11m ago
The effective resolution of the eye should be an angular value. I'd say that the smallest comfortable size of text characters for me is about 1/8° wide. I see the width of my 14" FHD laptop screen at about 30°, so the full width contains about 240 characters. This is a large upgrade from 80 columns of VT220 or VGA, and almost twice as much as the densest VT220 mode of 132 columns.

My 28" 4K monitor is exactly like four 14" FHD screens put together. It offers me 480 columns (a bit fewer, because window borders and scroll bars of multiple windows).

So indeed, better screens allow me to see much more text than poorer screens of old. There is a limit, but definitely it was not reached 30-40 years ago yet.

jandrewrogers•29m ago
Sometimes I write long functions because I do not have time to write a shorter function. Eventually, if I have time, I go back and refactor a much shorter and tidier version. While later versions may be somewhat more efficient computationally, it is mostly a no-op beyond the aesthetics.

What is the LoC for that function? The first implementation or the final rewrite? They express the same thing.

Entire Linux Network stack diagram (2024)

https://zenodo.org/records/14179366
19•hhutw•44m ago•0 comments

Novo Nordisk's Canadian Mistake

https://www.science.org/content/blog-post/novo-nordisk-s-canadian-mistake
285•jbm•7h ago•139 comments

Forth: The programming language that writes itself

https://ratfactor.com/forth/the_programming_language_that_writes_itself.html
67•suioir•3h ago•19 comments

Introduction to reverse-engineering vintage synth firmware

https://ajxs.me/blog/Introduction_to_Reverse-Engineering_Vintage_Synth_Firmware.html
13•jmillikin•1h ago•0 comments

Doing well in your courses: Andrej's advice for success (2013)

https://cs.stanford.edu/people/karpathy/advice.html
434•peterkshultz•11h ago•143 comments

Duke Nukem: Zero Hour N64 ROM Reverse-Engineering Project Hits 100%

https://github.com/Gillou68310/DukeNukemZeroHour
103•birdculture•7h ago•39 comments

QuickDrawViewer: A Mac OS X utility to visualise QuickDraw (PICT) files

https://github.com/wiesmann/QuickDrawViewer
39•ibobev•4h ago•13 comments

Gleam OTP – Fault Tolerant Multicore Programs with Actors

https://github.com/gleam-lang/otp
66•TheWiggles•5h ago•22 comments

Airliner hit by possible space debris

https://avbrief.com/united-max-hit-by-falling-object-at-36000-feet/
248•d_silin•10h ago•130 comments

Dosbian: Boot to DOSBox on Raspberry Pi

https://cmaiolino.wordpress.com/dosbian/
111•indigodaddy•8h ago•45 comments

Don't Force Your LLM to Write Terse [Q/Kdb] Code: An Information Theory Argument

https://medium.com/@gabiteodoru/dont-force-your-llm-to-write-terse-code-an-argument-from-informat...
4•gabiteodoru•6d ago•3 comments

Oskar Speck's 1932 Kayak Journey from Germany to Australia

https://nswskc.wordpress.com/2002/10/24/incredible-journey-50/
17•dividendpayee•1w ago•0 comments

Compare Single Board Computers

https://sbc.compare/
124•todsacerdoti•10h ago•51 comments

What's Behind the Mysterious Ancient Wall in the Gobi Desert?

https://news.artnet.com/art-world/the-hunt-gobi-wall-mongolia-2674588
30•derbOac•1w ago•15 comments

Nvidia has produced the first Blackwell wafer on US soil

https://www.xda-developers.com/nvidia-produced-first-blackwell-wafer-us-soil/
41•kristianp•2h ago•6 comments

From Hollywood to horticulture: Cate Blanchett on a mission to save seeds

https://www.bbc.com/news/articles/cwy7ekl4yl8o
24•RickJWagner•3h ago•2 comments

GNU Octave Meets JupyterLite: Compute Anywhere, Anytime

https://blog.jupyter.org/gnu-octave-meets-jupyterlite-compute-anywhere-anytime-8b033afbbcdc
117•bauta-steen•12h ago•33 comments

Look at how unhinged GPU box art was in the 2000s

https://www.xda-developers.com/absolutely-unhinged-gpu-box-art-from-the-early-2000s/
81•m-hodges•2h ago•34 comments

LoC Is a Dumb Metric for Functions

https://theaxolot.wordpress.com/2025/10/18/loc-is-a-dumb-metric-for-functions/
18•Axol•4h ago•19 comments

The Spilhaus Projection: A world map according to fish

https://southernwoodenboatsailing.com/news/the-spilhaus-projection-a-world-map-according-to-fish
104•zynovex•1w ago•14 comments

Deterministic multithreading is hard (2024)

https://www.factorio.com/blog/post/fff-415
70•adtac•18h ago•7 comments

Comparing the power consumption of a 30 year old refrigerator to a new one

https://ounapuu.ee/posts/2025/10/14/fridge-power-consumption/
136•furkansahin•5d ago•176 comments

Pawn is a simple, typeless, 32-bit extension language with a C-like syntax

https://www.compuphase.com/pawn/pawn.htm
15•unleaded•1w ago•3 comments

Carefully Educated to Be Idiots

https://www.hilarylayne.com/p/very-carefully-educated-to-be-idiots
11•DavidPiper•3h ago•6 comments

Discussion of the Benefits and Drawbacks of the Git Pre-Commit Hook

https://yeldirium.de/2025/10/09/pre-commit-hooks/index.html
7•hambes•1w ago•2 comments

The Cancer Imaging Archive (TCIA)

https://www.cancerimagingarchive.net/
40•1970-01-01•6d ago•3 comments

Replua.nvim – an Emacs-style scratch buffer for executing Lua

https://github.com/mghaight/replua.nvim
16•mghaig•5h ago•1 comments

Could the XZ backdoor been detected with better Git/Deb packaging practices?

https://optimizedbyotto.com/post/xz-backdoor-debian-git-detection/
84•ottoke•10h ago•69 comments

Infisical (YC W23) Is Hiring Full Stack Engineers

https://www.ycombinator.com/companies/infisical/jobs/0gY2Da1-full-stack-engineer-global
1•vmatsiiako•11h ago

The working-class hero of Bletchley Park you didn't see in the movies

https://www.theguardian.com/world/2025/oct/12/move-over-alan-turing-meet-the-working-class-hero-o...
100•hansmayer•1w ago•51 comments