6 ms·
AI 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
by kjksf 5mo ago
AI 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 5mo 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.