3 ms·
An important element that Willison left out of his definition of 'good code' is efficient! Software has an amazing multiplier effect. It can be copied to milli
by didgetmaster 6mo ago
An important element that Willison left out of his definition of 'good code' is efficient!
Software has an amazing multiplier effect. It can be copied to millions of machines and run billions of times each day. Code that wastes resources (time, memory, disk space, electricity, etc.) can become incredibly expensive to run, even if it was vibe coded in a day for a few dollars.
Has anyone taken a serious look at all the code being spit out by AI with regards to how efficient it is?
- kjksf 6mo agoAI is assisting you. It'll write efficient code if you guide it to write efficient code. You're not a hapless victim of ai written code. To give you a concrete examples. Recently pretext library made waves. I looked at the code and noticed that isCJK could possibly faster. So I spent 30 minutes TELLING claude to write a benchmark and implement several different, hopefully faster, versions. Some claude came up with by itself and some were based on my guidance. You can see the result here: https://github.com/chenglou/pretext/issues/2 https://github.com/chenglou/pretext/issues/2 The original isCJK, also written by AI (I assume), was fast. It wasn't obviously slow like lots of human JavaScript code I see. Claude did implement a faster version. Could I do the same thing (write multiple implementations and benchmark them) without Claude? Yes. Would I do it? Probably not. It would take significantly longer than 30 min. and I don't have that much time to spend on isCJK. Would I achieve as good result? Probably no. The big win came from replacing for .. of with regular for loop. Something that didn't occur to me but Claude did it because I instructed it to "come up with ideas to speed it up". I'm an expert in writing fast code but I don't know everything and I all good ideas. AI knows everything, you just need to poke it the right way.
- didgetmaster 6mo agoWhat worries me is that good, efficient code will no longer be widely shared like before. Everyone will just write their own inefficient version of a general purpose function or library because Claude or some other AI coder made it cheap and easy.