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 ↗)
    322comments
  2. Science Is Open Software(jepedersen.dk ↗)
    15comments
  3. SDCC – Small Device C Compiler(sourceforge.net ↗)
    6comments
  4. Cloudflare Quick Tunnels(cloudflare.com ↗)
    263comments
  5. Saving another 100TB of RAM(cloudflare.com ↗)
    58comments
  6. San Francisco Onion Futures Company(onionfutures.com ↗)
    discuss
  7. How OpenAI Used Its Own LLMs to Design Its Jalapeño Chip(ieee.org ↗)
    67comments
  8. How to Write with an LLM(sockpuppet.org ↗)
    296comments
  9. Why building a Rust LSP is hard(rust-glancer.github.io ↗)
    10comments
  10. Xcode 27.1 Beta Release Notes(developer.apple.com ↗)
    75comments
  11. Show HN: LiveWorld – Every 24/7 YouTube live camera on one globe(liveworld.info ↗)
    31comments
  12. Typesafe-computer-use drives a Mac toward a goal for 1/50th of a cent per step(github.com/awlevin ↗)
    discuss
  13. The first new cat species discovered in 100 years(nationalgeographic.com ↗)
    79comments
  14. Show HN: Cactus Needle 3: 8-29MB automation models can match DeepSeek V4 Flash(cactuscompute.com ↗)
    80comments
  15. Photon-Emission-Guided Laser Fault Injection Enables RP2350 Secure Debug(ledger.com ↗)
    61comments
  16. OpenJev(openjev.com ↗)
    249comments
  17. The Farnese letter(simonklee.dk ↗)
    5comments
  18. Cache-to-Cache: Direct Semantic Communication Between LLMs (2025)(arxiv.org ↗)
    12comments
  19. Goroutine Leak Profiles(go.dev ↗)
    discuss
  20. LispBM is a concurrent Lisp for microcontrollers with message passing(lispbm.com ↗)
    2comments
  21. Claude Code now reads AGENTS.md if there is no Claude.md(claude.com ↗)
    205comments
  22. Minimal Phone 2(minimalcompany.com ↗)
    199comments
  23. Cyclomatic Complexity in C#(ndepend.com ↗)
    15comments
  24. Alibaba open-sources AI model that can detect cancer and nearly 150 conditions(scmp.com ↗)
    9comments
  25. Warez: The Infrastructure and Aesthetics of Piracy (2021)(archive.org ↗)
    39comments
  26. How SpaceX streamlined the Raptor engine(construction-physics.com ↗)
    52comments
  27. Inside ZCode: Silently uploading your Git history to the cloud(ferstar.org ↗)
    94comments
  28. Flock Offers Employees Buyouts as Customers Flee(wired.com ↗)
    2comments
  29. The Implications of Linguistic Illegibility for LLM Security(arxiv.org ↗)
    22comments
  30. Two parallel neural ectoderm progenitors contribute to the developing brain(newscientist.com ↗)
    60comments

-2000 Lines of Code (2004)

210 pointsby 16y agofolklore.org
50 comments
16y agoHN ↗

I love the feeling after having rewritten some code part with the results of having it much shorter, much clearer, more stable and even faster. :) In almost all cases, it was worth it.

The strange thing is, sometimes there are multiple iterations of this on the same code part (sometimes by different people, sometimes even by my own).

Then I am thinking, maybe I just have gotten wiser, have learned my lesson or whatever. Stupid me that I haven't implemented it in the first place like this.

Also, I am always wondering, how much more iterations are there until I get to some final, perfect, optimal solution.

Or will I really end up with one single line of code in the end? :)

16y agoHN ↗

All code can be made shorter. But all code also has at least one bug. So eventually your code will be just one byte - but it will be the wrong byte :-)

16y agoHN ↗

If you look at programming as a knowledge acquisition activity instead of a code production activity, then you couldn't possibly have implemented it that way in the first place.

16y agoHN ↗

Exactly. Usually I don't have (or give myself) the luxury, but when I'm working on something small and I don't really have time constraints for it, I will write it, then rewrite it, then look at it from a different angle, and rewrite it again. Only after about three rewrites will I get something that looks good.

I'd like to bring this down to writing something good looking earlier, but it's like you say - I only learned it then and there.

16y agoHN ↗

There's this one: http://thedailywtf.com/Articles/Productivity-20.aspx

where a guy boosts his line count by writing a program convert loops into goto spaghetti (pretty much like the generated assembly, right?).

But has anyone here actually been evaluated in this way? I've never heard about it first hand - it almost seems like an urban legend.

16y agoHN ↗

Only wusses need comments in order to bloat their code. There are so many "effective" alternatives.

16y agoHN ↗

Oh yes, if I had it my way we'd all write for loops like so:

    int i = 0;
    int count = 20;
    
    while(
        (i < count)
        &&
        !(i > count)
    )
    {
        // some code
    }
16y agoHN ↗

Sure, but that goes either way and there is no tautology.

16y agoHN ↗

It's not infinite. It's equivalent to while(i<count). The right side of the && has no effect (for i<count, !(i>count) is always true, and it short circuits to false when i==count).

16y agoHN ↗

That would be because you don't see the body of the loop.

16y agoHN ↗

I did miss that out accidentally but I'm sticking like glue to your reason.

16y agoHN ↗

If you want to count lines of C you count semicolons.

16y agoHN ↗

The only thing better than writing code is deleting it.

16y agoHN ↗

“If we wish to count lines of code, we should not regard them as 'lines produced' but as 'lines spent'" - Edsger Dijkstra

16y agoHN ↗

I reported to a manager that attempted to measure our productivity fixing bugs by comparing the lines of code before and after the fix. Most fixes reduced the lines of code, so our numbers were usually either negative or close to zero. A couple weeks later the manager interrogated the team as to why we were so unproductive.

Another fun experiment is to measure developers using lines of code, and then switch to unit test coverage. For some reason, the code always seems to shrink.

Counting lines of code for maintenance work is a little like evaluating your mechanic based on the weight difference of your car before and after he fixes it.

16y agoHN ↗

Counting lines of code for maintenance work is a little like evaluating your mechanic based on the weight difference of your car before and after he fixes it.

I love this comment.

16y agoHN ↗

Measuring programming progress by lines of code is like measuring aircraft building progress by weight. - Bill Gates

16y agoHN ↗

I never saw this quote in the past, but apparently it's quoted a lot. And it's so true.

16y agoHN ↗

Too bad that it doesn't seem like Microsoft applied that philosophy to most of its products (at least not back when I used their products. Maybe they've started recently -- I've stopped following them a few years ago when I bought a Mac).

I wonder if any ex-Microsoft employee ever came out and said that they actually had the explicit goal of making each successive version of their main products (windows, office) much slower than the last so that people would upgrade to a new computer, making Intel happy, and leading to more "comes with the computer" licenses instead of pirating.

16y agoHN ↗

Apart from computers getting faster, Microsoft, Adobe and others should also keep up the artificial trade adequacy. If 20 years ago you'd gladly pay $400 for a software package that arrives on 20 floppy disks, the same amount today should be payed for a couple of DVD's to get the same level of emotional satisfaction. $400 for a 30-second download would be perceived as highly inadequate today, unfortunately.

16y agoHN ↗

"Never attribute to malice that which can be adequately explained by stupidity" - it's more likely that Microsoft's PMs and developers felt swayed by new features and possibilities and when the issue of performance came up, it was "meh, the average computer selling today can cope with it" and therefore little thought was given to performance on older tech or tech that has most of its performance diverted to other tasks.

16y agoHN ↗

Indeed, it could be that. But I'm still wondering if maybe it was more deliberate than that. After all, it would have been a way to make more money for both Microsoft and Intel, so there was an incentive there. And the downside was very small (what was the average Windows user going to switch to between 1995 and 2005?)

16y agoHN ↗

Ha! You might as well say Linus Torvalds was in the conspiracy too, since Linux required a 386 when the 286 was more common!

16y agoHN ↗

I am thinking that this comment came about in the era of the OS/2 Microsoft-IBM project. It was clear that IBM had a culture of kloc being a positive metric, and Microsoft did not.

I think it is useful to keep in mind that gobs of features sell, and (was it Joel Spolskey?) someone noted that any given user needs only 11% of a product such as a word processor, but another user needs a different 13%.

16y agoHN ↗

Since this is turning into a quote thread, I'll throw another one in:

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- Antoine de Saint-Exupery

16y agoHN ↗

Well, if we're really doing this...

"It's not the daily increase but the daily decrease. Hack away at the unessential." - Bruce Lee

Obviously not hack as in hack, but when it came to fighting he was a better hacker than any of us.

16y agoHN ↗

"The scholar seeketh daily increase of knowing; the sage of Tao daily decrease of doing. He decreaseth it, again and again, until he doth no act with the lust of result. Having attained this Inertia all accomplisheth itself. He who attracteth to himself all that is under Heaven doth so without effort. He who maketh effort is not able to attract it." - Tao Teh King, Chapter XLVIII (Crowley's translation)

16y agoHN ↗

Simplicity is harder to achieve than complexity. Try to solve problems by removing things, not adding them.

16y agoHN ↗

The key to performance is elegance, not battalions of special cases - Alan Kay

16y agoHN ↗

This was pure joy to read. Management asks for something foolish and counterproductive, and then one of the top techs pushes the absurdity right back in their faces -- take this: obvious big win, but a drastic opposite delta by your crude, misguided, metric!

My kids stared at me laughing very loudly for quite a few seconds :-)

16y agoHN ↗

It was if this is the first time you'd come across the concept. :D

16y agoHN ↗

I've seen this great folklore story hit the front page of HN more than a few times, but it is worth it every time. It is a good reminder for every programmer that verbose, complex solutions aren't necessarily good ones.

16y agoHN ↗

Code is the enemy. Code is weak. Code breaks. Coding is a last resort.

16y agoHN ↗

Counting the number of lines must be done after the algorithm is described. There are two roles: those finding the correct algorithm for a problem and those writing the code for implementing the algorithm.

16y agoHN ↗

This is one of those posts that periodically appears, but something that's almost never pointed out is that QuickDraw was written in assembly. So, by reducing the lines of code, not only did he reduce the complexity but he also directly made the code faster by being smaller.

16y agoHN ↗

he also directly made the code faster by being smaller.

Only if you assume that there are no jumps (loops) in that code.

16y agoHN ↗

A gear never breaks after it has been designed out of the machine.

16y agoHN ↗

Measuring lines of code is valid. The only caveat is that you must be intimately aware of whose lines of code you are counting.

16y agoHN ↗

Everybody here is having a great time beating this mostly-dead horse, but I know for a fact that I have more productive weeks and less productive weeks, and in those less productive weeks I usually write way less LOC.

What's more, if you just slightly adjust this metric to "patch size", as in count lines added as well as lines removed, you'll get a more accurate measure, and also make the linked story moot.

Measuring developer progress is incredibly hard, but we have to do it anyway, and "use your gut" cannot be the only advice on this. At the very least, comparing this metric for the same person over different periods of time can give you a clue as to how they're doing.

16y agoHN ↗

Not productive enough ;) "One of my most productive days was throwing away 1000 lines of code." -- Ken Thompson

16y agoHN ↗

"Je n'ai fait celle-ci plus longue que parce que je n'ai pas eu le loisir de la faire plus courte." - Blaise Pascal = "I would have written a shorter letter, but I did not have the time."