Live data from Hacker News

Writing code is easy, reading it isn't

idiallo.com

41–50 of 76 posts

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

#41
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

My #1 belief about engineering, and one I harp on constantly, is that simplicity is harder than complexity.

I use it as a heuristic. If my work is getting more complex, it's a warning sign that I might be doing something wrong or using the wrong approach. If it's getting simpler it means I might be headed in the right direction.

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

#42
post #17

I have the opposite experience. After years in appsec and pentesting, I can read any codebase and quickly understand its parts, but I wouldn’t be able to write anything of production quality. LLMs speed the comprehension process up for me even further. I guess it comes down to practice, if you practice reading code, you get good at reading code.

reading production code that is known to work can be done with faith and skimming. You don't have to understand every function call because they've each been tested and battle hardened, so it's easy to get an overview of what is happening. LLM code is NOT like this at all, but it's like a skilled liar writing something that LOOKS plausible, that's what they're trained to do. People like you do not have the ability to…

Code is code, it's not a piece of art where we all can have different perspective about what it means or does, so from appsec perspective it doesn't matter who wrote it, just what it does. Also you seem to be interpreting "reading" as one would read a novel, but here "reading" is about finding and exploiting security flaws. So yeah, dunno what you are on about.

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

#44
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" :)

I guess this https://www.ioccc.org/

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

#45
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

This resonates so much with my upbringing.

When I was a kid learning programming, I would skim through the whole book teaching Python and type the code using as much keywords as I learned each day, just to boast on my parents and my non-programmers peers about the obfuscated mess that came after.

As I grew I started to contribute to other open-source projects and I came across every kind of unmaitanable spaghetti code, so that I just gave up contribuiting on said project, that is when I gained the consciousness about being zealous on keeping the code as simple as possible so that the next person who comes after me to change the code don't have as much trouble understanding the code, even myself when I revisit the code later.

That altruistic mindset about caring how others read your code, you don't acquire easily unless you get experience how your previous peers did feel.

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

#46
Makes sense. Once you become really good at writing code, it becomes increasingly obvious that the real challenge of software development is the social problem of pointing out subtle contradictions in requirements and suggesting resolutions/trade-offs in a way which earns you respect instead of hatred.

With some stakeholders, this is an almost impossible problem; sometimes this is because they lack vision and so their requirements are littered with impossible contradictions; other times, their ego is too big to accommodate any kind of push-back; even if you try to drip-feed the suggestions as gently as possible, they begin to resent you because they start to associate you with negative feelings such as self-doubt.

Schopenhauer explained this phenomena succinctly:

"A man must be still a greenhorn in the ways of the world, if he imagines that he can make himself popular in society by exhibiting intelligence and discernment. With the immense majority of people, such qualities excite hatred and resentment, which are rendered all the harder to bear by the fact that people are obliged to suppress — even from themselves — the real reason of their anger. What actually takes place is this. A man feels and perceives that the person with whom he is conversing is intellectually very much his superior. He thereupon secretly and half unconsciously concludes that his interlocutor must form a proportionately low and limited estimate of his abilities. That is a method of reasoning — an enthymeme — which rouses the bitterest feelings of sullen and rancorous hatred."

This is a really big problem because people who attain management positions are often very good at understanding and then manipulating what other people think about them; this is how they were able to rise to their current ranks. They are exactly the kinds of people who build these reflective mental maps/models of who thinks what about them; and they are good at plotting against those people who they believe may harbor negative thoughts about them.

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

#47
post #30

With LLMs you need to read well, they can introduce “later bugs”

"ChatGPT write me some unit tests for this piece of code you just generated"

"Proceeds to write tests that pass, but don't actually test the underlying functionality."

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

#48
post #17

I have the opposite experience. After years in appsec and pentesting, I can read any codebase and quickly understand its parts, but I wouldn’t be able to write anything of production quality. LLMs speed the comprehension process up for me even further. I guess it comes down to practice, if you practice reading code, you get good at reading code.

Maybe you are used to read high quality code. I suspect that the simple fact that you are auditing some code means that someone actually cares, making it higher quality than average.

High quality code is generally hard to write and easy to read.

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

#49
post #8

This is a challenge which I don't think AI tools like Cursor have cracked yet. They're great for laying "fresh pavement" but it's akin to being a project manager contracting the work out. Even if I use Cursor (or some other equivalent) and review the code I find my mental model of the system is much more lacking. It actually had a net negative on my productivity as it gave me anxiety at going back to the codebase. If…

but it's akin to being a project manager contracting the work out. And that's probably the difference between those who are okay with vibe coding and those who aren't. A leader of a company that doesn't care about code quality (elegant code, good tradeoffs, etc) would never have cared if 10 monkeys outputted the code pre-AI or if 10 robot monkeys outputted the code with AI. It's only a developer, of a certain type, t…

Or maybe if you are good at delegating and reviewing code and stepping in to do a deep dive by hand when needed to maintain understanding, then you can use LLMs to greatly increase your speed.

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

#50
I find reading code mentally much more draining than writing it. I admire open source maintainers who mostly handle pull requests from others. This must be very hard. Linux cones to mind here. I assume Thorvalds and the other maintainers don’t get to write much code themselves.
Post reply on HN