Periodic reminder: The only way to write good code is to write tons of shitty code first. Feeling shame about bad code stops you from getting to good code.
@hadleywickham this, and also you can sub in "make good art" or "write good stories"
@mrcompletely @hadleywickham OMG this applies to so many things. We prove this every year in the hospital with new interns. Being a good doctor takes so much practice.
@mrcompletely @hadleywickham Adam Grant said exactly that about art (make lots of art and show it in lots of places), with Bruce Springsteen as an example.
@hadleywickham I was thinking about that quote today (I am still in the process of writing shitty code)
@hadleywickham my first ever software design (pre OO) was an absolute spaghetti mess. I went to the IEE library and pulled out books by Coad Yourden - learnt about structured design - coupling and cohesion. Rewrote the app (in C at the time) - far cleaner, modularised with interfaces. Yourden's writing actually resonated with me because I had experienced the the poor way of tackling the problem. It took that experience to really understand why coupling and cohesion were so important.
@hadleywickham thanks for this. We need more periodic reminders 🙏🏽
@hadleywickham on of my earliest code was when, for reasons that defy logic, I was given the task to design a phone company web portal in JSP.
Had never heard of Java Server Pages. Had heard of Java but never tried it.
Had ever only done PHP in my extensive 1+ years as a programmer.
Why the company took the contract when the only free resource was me, beggars belief.
And this was before quality programming books and tutorials were available online.
I tried my best, and it “kinda” worked.
@hadleywickham but those kinds of stories are what define the dot-com bubble I guess.
@hadleywickham Applies to photography too. In the film era, the big advantage a pro photographer had was, a pro could take a lot of pictures and only print the good ones.
@hadleywickham Conversely, no shame about bad code also leads to bad code. The key is to write the bad code, and then feel bad enough about it to improve.
@bigfishrunning @hadleywickham There's no need to feel bad about it at all. In fact, you can feel great about it, if it does what needs to be done at the time. As you learn, you can simply look back with understanding that you did your best with what you knew at the time. We all deserve a fair shake :)
@hadleywickham you know what, I needed to hear this, thanks man
@hadleywickham
This is very true.
It’s very easy to look at a finished pull request and wonder how they did that… but a PR doesn’t show you all the false-starts and fuck-ups that happened along the way.
I reckon I throw away _at least_ half of the code I write, and I’ve been doing this for 30 years.
@hadleywickham Jokes on you, I'm just gonna stop at the "write tons of shitty code" and then stop!

@hadleywickham

Yeah, one gets tired of cleaning stuff up or fixing bugs that could have been more easily found or avoided.

But you have wade through that to understand it and develop better habits.

@hadleywickham thank you for posting this. I've been doing this 30 years but this is exactly what I needed reminding of today.

@hadleywickham If you've got the time then playing "refactor the crap 'til it's good" is fair play - even if there's a deeper reason it can't be good code to fix (I don't roll my own crypto for a reason), turd polishing is still practice at polishing!

The standard advice to artists about recognising that you're developing taste and probably developing it faster than you develop skill very much applies with code too.

@hadleywickham @flippac

So basically the llm overlords are right on track

@daut @hadleywickham Not even slightly. Humans learn by doing. LLMs turn to shit when fed on each others' output because they have no taste of their own: they're just trying to pass for an entity like those producing the data they're trained on.

I fully intend to teach people I've learned from a thing or two down the line, and on a friendly basis have done so...

@flippac not sure the first part of that "fed each others output" ... #academafia does a good approximation... #twitter did a good approximation. lol.

But I agree. Learning by doing is the way. Other ways... in a different category.

@[email protected] A good argument for not using ChatGPT, Github Copilot, or related technology. They effectively convert a coding problem into a reading comprehension problem, which is a different task cognitively. You won't learn to solve coding problems you lean on these tools for because by using the tools you're not challenging your brain in the ways that trigger learning.

@hadleywickham

I started my final career stage doing a Y2K rewrite of a gigantic ball of mud. The “programmer” had literally died on the job.

Large set of program libraries. MVS390. Nested macro calls to nowhere. Defunct code throughout. No style. No documentation. Single author. In PRODUCTION. 😱

Taught me a few things!

@hadleywickham I'd say that strategy applies to anything we want to become good at 😊

@hadleywickham yes 💯 yes and!

Accept and encourage the shitty code of others —- when or if you are given the gift of critiquing another’s code, remember to be compassionate, and encouraging, not cruel or discouraging (which is *very* easy).

I feel that the highest art is to make it crystal you are critiquing the code while encouraging the coder.

(Harder still: to remain open that your “wise” (hard won) criticism may even be very misguided/out of date)

@secretgeek @hadleywickham in a different direction, Toastmasters teaches you to be compassionate and understanding while evaluating a speech given by a (possibly very nervous) public speaker.

@hadleywickham

Or, you know, git gud at Googling! 😂

@hadleywickham Addendum to Hadley's law: if the AI writes the code for you, you will never write good code.
@hadleywickham how to become a potter: throw lots of clay.
@hadleywickham many young AIs feeling really validated rn
@hadleywickham I can unequivocally state that my code is awful most of the time. It's always getting the syntax right that stumps me. 🤷‍♀️
@hadleywickham I am starting a tidyverse course, and this was the first slide for my students today.
@hadleywickham That goes with everything. I think the generalization goes something like "if you want to be good at something, you must accept being bad at it"
@hadleywickham that works for any kind of writing. Nothing starts off polished.

@hadleywickham I got my first synthesizer in 1980. And now, finally, I’m really good at it LOL

Wasn’t in the beginning of course, but maybe five years ago I just kind of noticed I’d not been worried about that for a while. It just takes time. And work.