Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. Android 17 is the first since 3.x to add new APIs without releasing to the AOSP(grapheneos.social ↗)
    263comments
  2. Cloudflare Quick Tunnels(cloudflare.com ↗)
    250comments
  3. Saving another 100TB of RAM(cloudflare.com ↗)
    43comments
  4. The Farnese letter(simonklee.dk ↗)
    5comments
  5. How to Write with an LLM(sockpuppet.org ↗)
    270comments
  6. Xcode 27.1 Beta Release Notes(developer.apple.com ↗)
    68comments
  7. Photon-Emission-Guided Laser Fault Injection Enables RP2350 Secure Debug(ledger.com ↗)
    53comments
  8. Show HN: Cactus Needle 3: 8-29MB automation models can match DeepSeek V4 Flash(cactuscompute.com ↗)
    78comments
  9. Cache-to-Cache: Direct Semantic Communication Between LLMs (2025)(arxiv.org ↗)
    12comments
  10. The first new cat species discovered in 100 years(nationalgeographic.com ↗)
    60comments
  11. How OpenAI Used Its Own LLMs to Design Its Jalapeño Chip(ieee.org ↗)
    58comments
  12. OpenJev(openjev.com ↗)
    245comments
  13. Claude Code now reads AGENTS.md if there is no Claude.md(claude.com ↗)
    182comments
  14. Cyclomatic Complexity in C#(ndepend.com ↗)
    15comments
  15. Show HN: LiveWorld – Every 24/7 YouTube live camera on one globe(liveworld.info ↗)
    4comments
  16. Minimal Phone 2(minimalcompany.com ↗)
    175comments
  17. The Implications of Linguistic Illegibility for LLM Security(arxiv.org ↗)
    19comments
  18. Warez: The Infrastructure and Aesthetics of Piracy (2021)(archive.org ↗)
    25comments
  19. Column built an issuer processor from scratch(column.com ↗)
    5comments
  20. Two parallel neural ectoderm progenitors contribute to the developing brain(newscientist.com ↗)
    54comments
  21. C++26: Trivial infinite loops are no longer undefined behaviour(sandordargo.com ↗)
    201comments
  22. Inside ZCode: Silently uploading your Git history to the cloud(ferstar.org ↗)
    91comments
  23. Alibaba open-sources AI model that can detect cancer and nearly 150 conditions(scmp.com ↗)
    4comments
  24. How SpaceX streamlined the Raptor engine(construction-physics.com ↗)
    40comments
  25. LispBM is a concurrent Lisp for microcontrollers with message passing(lispbm.com ↗)
    1comments
  26. A search-and-inference database from scratch in pure Zig(antfly.io ↗)
    16comments
  27. I vibed a proof of Conway's conjecture(overreacted.io ↗)
    186comments
  28. Size-Specialized Memory Allocation(go.dev ↗)
    3comments
  29. North Korean nuclear test sets off years of earthquakes(science.org ↗)
    151comments
  30. From Geometry to Algebra and Back Again: 4000 Years of Papers (2023) [video](youtube.com ↗)
    discuss

Cyclomatic Complexity in C#

34 pointsby 2d agoblog.ndepend.com
15 comments
4h agoHN ↗

Anyone using tools like ndepend or others to help guide agents in refactors?

Personally I have a some tools that build dependency graphs (C# and Python) and store the results in a local database. Agents seem quite good at poking at this and coming up with refactor ideas. Graph analysis tools are useful here, simple application will detect cyclical dependencies, but I encourage the agents to use more complex tools like clustering to poke at the data.

3h agoHN ↗

I've been feeding agents dependency graphs plus CC and coverage data from a local store, and it works well for spotting cyclical deps and high-CC hotspots

4h agoHN ↗

Is there research that show if and how much a low complexity improves security?

3h agoHN ↗

Weird question to ask, that is pretty obvious.

Worst things happen always when 2 or more systems are combined because each system might be simple on its own, yet a combination is always much more complex.

3h agoHN ↗

It’s not obvious to me because cyclomatic complexity is not a straightforward proxy for the number of systems that are being combined.

It’s also the case that some of the most common sources of vulnerabilities, such as SQL injection, introduce no additional cyclomatic complexity. Heck, buffer overflows are good for your cyclomatic complexity - those array bounds checks are all extra branches.

3h agoHN ↗

Buffer overflow checks are really only going to be a linear growth in CC. It's when things move towards exponential growth or higher that it gets really easy to introduce flaws of many kinds.

Now, it's probably not a direct correlation. I'd think security bugs are more likely from programmers that unintentionally raise CC without really realizing it. Aka, overreaching their own knowledge when simpler structures are avaliable.

3h agoHN ↗

Sure. It’s just that there’s also so much research that has found that cyclomatic complexity is theoretically ill-founded, and that it tends to underperform other ways of measuring complexity. Most notably, just counting lines of code. (Not per function, in total.)

Here’s an oldie but goodie: https://cs.du.edu/~snarayan/sada/teaching/COMP3705/lecture/p...

I’ve personally had better success thinking of it as more of a measure of readability than of quality.

2h agoHN ↗

Weird question to ask, that is pretty obvious.

For something the the prior statement it is never a weird question to ask of there actually evidence of this or just it seems like it should be true so we believe it.

There are tons of things that seem like they would obviously be true, but it turns out they aren't.

20m agoHN ↗

I'd argue that assuming something is obvious without any empirical validation is the root of a huge number of misconceptions that humanity has historically had. There's a reason science suddenly started moving a lot faster after we moved past Aristotle and started measuring things in experiments.

3h agoHN ↗

Overall cyclomatic complexity is a useful metric, but it does have one shortcoming when used with modern languages: it was invented before polymorphism really became a thing.

That means that it really only counts explicit branching. So, for example, in an OO language like C#, calling a virtual method doesn’t increment cyclomatic complexity even though the method invocation could go down many code paths. Potentially thousands if you’re dealing with a common interface like IEnumerable. If you’re working on a library then the number of potential code paths in this kind of situation is unbounded.

As an aside, it’s interesting to think how it might apply to a language like Smalltalk that doesn’t even have if or switch statements.

OO isn’t the only monkey wrench, either. Higher-order functions also introduce forms of branching that cyclomatic complexity doesn’t measure.

Again that doesn’t make it a useless metric. Just don’t think that a cyclomatic complexity limit in your codebase is some sort of maintainability panacea. Some of the least comprehensible functions I’ve deciphered had quite low cyclomatic complexities.

2h agoHN ↗

In reading the article, it did feel somewhat wrong in a way that I couldn't quite describe. But after reading this comment, maybe it just seems old and maybe obsolete.

Taking the example provided in the article, I don't feel like the new code is meaningfully less complex. In fact, since it added some additional indirection, I could argue it's slightly more complex.

The core code with the nested if statements is something that I would probably refactor in some other way entirely. Maybe by taking advantage of other language features. It is a toy example so it's hard to say but that's part that feels like it needs simplification and untouched in this example.

1h agoHN ↗

Agreed. I also don’t really agree that the refactored code is any easier to test. ProcessOrder’s behavior hasn’t changed, only its implementation details, so the minimal test surface is the same for both: just test ProcessOrder.

You could additionally test the three helper functions. But the original tests against ProcessOrder would still be needed for completeness, so they wouldn’t necessarily add much except in an Uncle Bob style, “He who dies with the largest burden of gratuitous micro-tests wins,” sort of way.

Now if I really wanted to make that code easier to test, I’d instead be looking into ways to make the whole thing less stateful. Temporal coupling is much more confusing than if statements.

1h agoHN ↗

Some of the least comprehensible functions I’ve deciphered had quite low cyclomatic complexities.

In agreement with your post, this research that measures cognitive load via EEG and time spent shows that the metrics we use for complexity and readability are only partial matches to what is going on: https://pmc.ncbi.nlm.nih.gov/articles/PMC9942489/

2h agoHN ↗

Fun story: at my previous aaaawful company CC was discovered as a thing to care about at about the same time as PMs and managers were encouraged to land code changes using the _then_ quite terrible AI tooling (this was a year or two ago). Cue an avalanche of completely unreviewable diffs.