←back to thread

925 points dmitrybrant | 3 comments | | HN request time: 0.6s | source
Show context
codedokode ◴[] No.45165982[source]
LLMs are also good for writing quick experiments and benchmarks to satisfy someone's curiosity. For example, once I was wondering, how much time does it take to migrate a cache line between cores when several processes access the same variable - and after I wrote a detailed benchmark algorithm, LLM generated the code instantly. Note that I described the algorithm completely and what it did is just translated it into the code. Obviously I could write the code myself, but I might need to lookup a function (how does one measure elapsed time?), I might make mistakes in C, etc. Another time a made a benchmark to compare linear vs tree search for finding a value in a small array.

It's very useful when you get the answer in several minutes rather than half a hour.

replies(1): >>45166025 #
codedokode ◴[] No.45166025[source]
Also I wanted to add that LLMs (at least free ones) are pretty dumb sometimes and do not notice obvious thing. For example, when writing tests they generate lot of duplicated code and do not move it into a helper function, or do not combine tests using parametrization. I have to do it manually every time.

Maybe it is because they generate the code in one pass and cannot return back and fix the issues. LLM makers, you should allow LLMs to review and edit the generated code.

replies(5): >>45166074 #>>45166289 #>>45166391 #>>45166596 #>>45170444 #
1. jlei523 ◴[] No.45166074[source]

  Also I wanted to add that LLMs (at least free ones) are pretty dumb sometimes and do not notice obvious thing. For example, when writing tests they generate lot of duplicated code and do not move it into a helper function, or do not combine tests using parametrization. I have to do it manually every time.
Do you prompt it to reduce duplicated code?
replies(1): >>45167916 #
2. codedokode ◴[] No.45167916[source]
I can prompt anything but I would prefer it not to make obvious mistakes from the start.
replies(1): >>45168033 #
3. jlei523 ◴[] No.45168033[source]
"Use DRY coding". 3 words can solve this problem. Maybe put it in the parent prompt.