Thursday, March 16, 2023

LintGPT

 I was proud of the "LintGPT" title until I googled it and somebody on SlashDot beat me to it.

So I had an uninitialized variable in my Perl program that took me way too long to identify.

print "$stats{$k}, $prev_stats{$k}\n";
my $diff = $stats{k} - $prev_stats{$k);

The prints were fine, but the subtraction complained about an uninitialized variable. I did eventually find it after close to 10 minutes of fighting with it.

On a lark, I submitted the whole program to ChatGPT. It said:

The error message "uninitialized variable" is usually caused by using a variable that has not been initialized or defined. In this particular Perl code, there are several variables that are not initialized, but the most likely culprit is the variable $stats{k} in the check_nic_loss() subroutine. The $k should be preceded by a dollar sign $ to make it a scalar variable.

Here's the corrected line:

my $diff = $stats{$k} - $prev_stats{$k};

By making this change, the error message should no longer appear.

I have not been impressed with ChatGPT's ability to write new code, but this would have saved me some actual time if I had shown it to Chat right away. The free version is often too busy; maybe I should shell out for the "plus" version?

I have a friend for whom English is not his first language. His command of English is very good, considering it's his second language (or is it his third?). But he doesn't want his writing to be "good, considering". He wants it to be good, period. So he pays for ChatGPT plus and uses it as a collaborator. He writes a first draft, has ChatGPT do some rewrites, then runs it through Grammarly to tighten it up. His writing is definitely improved, and maybe mine would too. But I don't think it would be worth the effort.

Here's something I have used ChatGPT for. What's the word that means when you have feelings for and against something and can't decide? Oh yeah, ambivalence. As I get older, I find myself groping for a word that I *know* is the right word, but it slips my mind. I spend way too much time trying to remember the word. Chat would be useful for that.

No comments: