Live data from Hacker News

Writing code is easy, reading it isn't

idiallo.com

31–40 of 76 posts

Re: Writing code is easy, reading it isn't

#31

I am really bad at reading code to be honest (especially other people's code). Any tips on how I can go about becoming good at this like starting from baby steps?

Use an LLM. It's not a joke answer. This entire article is silly. LLMs are great for helping you understanding code.

Agreed!

Especially getting them to generate sequence / flow charts I find is a hack to figure out how everything fits together well.

Claude code is fantastic at quickly tracing through code and building visualisations of how code works together

Re: Writing code is easy, reading it isn't

#33
post #26
post #25

You need to be twice as smart to debug code as you need to be to write it. So if you write the smartest code you can, then you by definition are too dumb to debug it Just write simple code

what exactly is "the smartest code you can" :)

Actual quote:

Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?

Re: Writing code is easy, reading it isn't

#34

I am really bad at reading code to be honest (especially other people's code). Any tips on how I can go about becoming good at this like starting from baby steps?

Read code, read code, read code. You will get better.

When looking at a piece of code, keep asking questions like: what does this return, what are the side effects, what can go wrong, what happens if this goes wrong, where do we exit, can this get stuck, where do we close/save/commit this, what's the input, what if the input is wrong/missing, where are we checking if the input is OK, can this number underflow/overflow, etc

All these questions are there to complete the picture, so that instead of function calls and loops, you are looking at the graph of interconnected "things". It will become natural after some time.

It helps if you read the code with some interest, e.g. if you want to find a bug in an open source project that you have never seen the code for.

Re: Writing code is easy, reading it isn't

#35
post #26
post #25

You need to be twice as smart to debug code as you need to be to write it. So if you write the smartest code you can, then you by definition are too dumb to debug it Just write simple code

what exactly is "the smartest code you can" :)

In this case, it sounds like "The code that will most impress your parents"

Re: Writing code is easy, reading it isn't

#36
post #25

You need to be twice as smart to debug code as you need to be to write it. So if you write the smartest code you can, then you by definition are too dumb to debug it Just write simple code

Thank you, I will be using this.

Not sure if there is actually data for the assumption to be twice as smart to debug than to write code, but it sounds about right.

And also, if you write the smartest code you can, while you are at your peak, you also won't be able to read it, when you are just a bit tired.

So yes, yes, yes. Just write simple code.

(I also was also initially messed up a bit by teachers filling me up with the idea to aim for clever code)

Re: Writing code is easy, reading it isn't

#37

I am really bad at reading code to be honest (especially other people's code). Any tips on how I can go about becoming good at this like starting from baby steps?

For me the trickiest part is getting how code is interconnected (class composition, abstraction with functions, module dependencies, etc.).

Code navigation should be instant and effortless. Get good tooling and train muscle memory for it.

Re: Writing code is easy, reading it isn't

#38
post #26

Earlier quoted context omitted.

what exactly is "the smartest code you can" :)

Actual quote: Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?

Known as Kernighan's Law.

Re: Writing code is easy, reading it isn't

#40
post #25

You need to be twice as smart to debug code as you need to be to write it. So if you write the smartest code you can, then you by definition are too dumb to debug it Just write simple code

Writing simple code is also much harder then writing complicated code. If you write some complicated code at the limit of your mental capabilities you can not debug it, but you might also not be smart enough to write the simple code.

I guess this means that one should solve the appropriate problems for a given skill level

Post reply on HN