3 ms·
"AI" generated code often has a number of styles in the same functions or modules. In an "AI" generated bash program I recently reviewed, the code had both "if
by bediger4000 11mo ago
"AI" generated code often has a number of styles in the same functions or modules. In an "AI" generated bash program I recently reviewed, the code had both "if [ testtesttest ]" and "if [[ testtesttest ]]" styles along with different styles of testing lexical equality.
It also had a globbing test I'd never seen before, something like "if [[ $X = *"string"* ]]". It works, but wow, ugly.
The new bash program looked old, like someone with a distinct set of preferences wrote it years ago and 2 or 3 maintainers had hacked on it, being less careful to keep a consistent style.
That sort of thing would be judged low quality legacy code 5 years ago. It's harder for a human to understand, and since it just might depend on a peculiarity of "=" vs "==" vs "-eq", people make minimum changes or maybe no change at all. That's one way "low quality" you seek is exhibited.
- chaidhat 11mo agoThank you for the reply and the well thought-out example. This is a good point on garbage in => garbage out as someone else said. Interestingly, the opposite may be true for newer languages: I wrote my frontend in dart over three years in a very C way where getters and setters are just functions. However, after introducing LLMs to my codebase, it started using `get`s and `set`s keywords (which is the newer way). I have a question on personal preference: as an engineer yourself and you were in my shoes, would you prefer newer style > consistency (i.e., I should refactor my 50k LOC codebase) or the opposite (i.e., correct the LLM to use my style)?
- bediger4000 11mo agoFor something that size, I'd prefer consistency, unless the original style is too idiosyncratic, like the fabled "writing Fortran in Perl".
- chaidhat 11mo agoThank you! Never heard that idiom but caused me to go into a rabbit hole researching Fortran haha