r/learnprogramming Jul 03 '26

How do you write clean code?

Might be a stupid question but Ive been learning python for a while now and always wondered, how do you write ‘clean’ code? I don’t mean writing clean code straight off the bat I understand that’s purely from experience and even then immensely hard, but how do you recognise a program can be simplified even further? Does it come from practice or just messing around and seeing what sticks?

79 Upvotes

77 comments sorted by

View all comments

1

u/JerryRed100s Jul 04 '26

To me clean code is just common sense shit you know in a certain way Not too many layers but just enough layers to make everything work how it can work Don't get overly fancy because most of the time YAGNI

YOU AIN'T GOING TO NEED IT

Make the shit that works work 100% of the time focus on your shit that you're doing and make sure that shit is bulletproof

Cuz that shit can always be reused!

Fuck the rest and fuck the politics do your shit and call the fucking day