Live data from Hacker News

Holding a Program in One's Head (2007)

paulgraham.com

41–50 of 114 posts

Re: Holding a Program in One's Head (2007)

#41
A good way to keep a program in your head:

Break it up into a few or several smaller programs that interact through clean interfaces. Then you can keep one smaller, simpler program in your head at a time, then integrate them at the end once all the smaller programs are working.

Re: Holding a Program in One's Head (2007)

#42

A good way to keep a program in your head: Break it up into a few or several smaller programs that interact through clean interfaces. Then you can keep one smaller, simpler program in your head at a time, then integrate them at the end once all the smaller programs are working.

Those are called functions.

Re: Holding a Program in One's Head (2007)

#43
A great article that accurately describes the challenges I've faced over the past 12 years while creating the best project for programmers and the various attempts to find work and funding, observing all the madness in the organizations It seems like the best of it was left in 2007, from which we still draw inspiration and knowledge, while since 2008 we've been living in a new world of marketing and wars. The insatiable interests of faceless systems are destroying everything alive in this great science of "programming".

Re: Holding a Program in One's Head (2007)

#44

A good way to keep a program in your head: Break it up into a few or several smaller programs that interact through clean interfaces. Then you can keep one smaller, simpler program in your head at a time, then integrate them at the end once all the smaller programs are working.

[deleted]

Re: Holding a Program in One's Head (2007)

#45

> […] bottom-up programming, where you write programs in multiple layers, the lower ones acting as programming languages for those above I like to explain this as “hide the bad parts behind a good API”. Anything interesting is going to require “bad parts”, which just means the low-level, difficult work. From there, compose up and up until a high level orchestration is achieved. It works so much better than the bad pa…

"Hide the bad parts behind a good API... It works so much better than the bad parts being distributed everywhere!"

This doesn't work for the "bad things" I know of. All of the low-level bad parts which are truly bad/mucky, are bad because they can't be entirely hidden. They are leaky abstractions and by that fact, they ... leak. They impact every part of the system so they are "distributed everywhere" in the sense that the maintainer of a large program has to consider them everywhere even if they only directly show up in a few places.

Just as an example, programming languages are abstractions over the complex structure of "raw" memory. Pythons hide this abstraction more than for example c but once you reach a certain scale the use of python, you have to consider the details of its use of memory. And that's memory in general, which people work at to make reasonably regular as well as fast.

That's not saying you can't have an API that makes the low-level problems less.

Re: Holding a Program in One's Head (2007)

#46
post #21

I once watched a presentation by Dan North where he said that a microservice should never be bigger than your head. What he meant was that all the code for the microservice should fit on your screen and you should be able to put your head against the screen and it should cover the code. Yes, this was in the microservices-heyday.

Anything you create in software should be able to fit in someone else's head. I.e., you should be able to think of it as a tractable arrangement of abstractions that let you reason about it in a precise, non-leaky way. Those abstractions don't just poof into existence after the project is complete, though. You have to design them into the system and communicate them to the people who need them. The abstractions also…

Unfortunately, all the market giants follow this destructive practice to rewriting 95% of all code every five years to multiply added value.

Re: Holding a Program in One's Head (2007)

#47
IMO this is one of the most important skills for a developer to have. In an age of Github Copilot and similar systems, it's both far more viable (because, per OP's #1, you won't get distracted by the "side quests" of implementing utilities you need, when you can just tab-complete to get them) and far more vital (because with that productivity increase comes an increase in the complexity of problems you'll be asked to tackle at any given level of seniority).

My advice on this would be: never be afraid, and even force yourself to, follow the chain of how a certain function is implemented in third-party libraries you are using. Set up your IDE to be able to click into functions, make that muscle memory, and perhaps even have a dedicated project you can bring up for your site-packages or node_modules. Don't just rely on documentation, see how things actually work a few levels deep. You'll gain a deeper understanding of the code you're using, as well as incredible practice for when you need to do this on an existing first-party codebase.

Oh, and if you can, get one or more large 4k monitors, and split your IDE into 4 quadrants! It's certainly possible to hold a codebase in your head on a small laptop screen, but being able to see the code you're working on alongside its dependencies and dependents makes this far easier!

Re: Holding a Program in One's Head (2007)

#48

> You never understand other people's code as well as your own. No matter how thoroughly you've read it, you've only read it, not written it. There is certainly some truth to this. On the other hand, it's possible to become blinded to defects in code you've written yourself. You see what you intended for the code to do rather than what it actually does. Reading someone else's code, it can be easier to see what's real…

I believe that is the source of "the worst code I have seen is code I wrote six months ago" feeling. It has been long enough that the code has fallen out of your memory, making you less blind to the defects. You can now see it as an outsider would see it.

Re: Holding a Program in One's Head (2007)

#49
post #12

"Use succinct languages" is somewhat at odds with "Write rereadable code." There's a point beyond which making your code more succinct makes it more difficult for a human to parse. This can be somewhat mitigated by comments but I'd rather just read more readable code than more succinct code.

You always have comments. I’ve always been fascinated by GitHub repositories like "odd-even" where the code is just a few lines, but the README takes up several times more text. I even started a small collection of these fun React modules :)

Re: Holding a Program in One's Head (2007)

#50
post #42

A good way to keep a program in your head: Break it up into a few or several smaller programs that interact through clean interfaces. Then you can keep one smaller, simpler program in your head at a time, then integrate them at the end once all the smaller programs are working.

Those are called functions.

imagine having the brain to synthesise every function across a codebase , most humans gotta settle for interfaces :p
Post reply on HN