Sina Khalilisinakhalili.com

how to code easily

How do you code easily, well?

By coding bad. Take a statement. print('hello'). We can see something. Good. Run it again with more code. Use a ton of if statements. Write the same line at the end of each of them. Make a huge switch case. Copy paste the same four lines over and over. Use flag variables. Don't be bogged down by good coding. Usually bad coding feels good.

Ah, it feels nice to see some output!

Then eventually it feels bad, so take it out. Pull the common statement out of the loop. Extract out that switch case to dispatch out to mini cases. Then mini parsers. Put the nine copy pasted lines into it's own function. Usually this also feels good.

Ah, it feels nice to see the code get smaller!

Things that feel bad are usually doing these out of order. Being organized to start: too much friction. Being messy in the endgame: impossible to reason.

To code well, go towards the direction of maximal pleasure. This advice, I feel, can apply to any field you have achieved a certain level of literacy in.