The only times I’ve seen devs do inline comments in their code is when it’s been done by AI, and I can tell it’s AI because the comments are all useless and describing what’s happening, not why.
AI mostly learned it from programming tutorials and things like documentation and Q&A forums like StackOverflow. People often add comments in those cases to explain to somebody not familiar with code what is happening so they can learn from it.
In actual code written by people who write code for a living I’d hope the comments are much more useful and usually not as prevalent.
I actually got really clean, well commented code from Copilot earlier this week.
I have no experience with JavaScript to speak of, but realized a Bookmarklet would be a perfect solution for reformatting a particular arcuate for printing. I already had a head replacement with CSS to do all the formatting, and I was using a RegEx to strip all script tags.
Anyway, I asked Copilot to write the Bookmarklet to replace the header, with full contents explaining the training behind the code, and an explanation of how the script functions below. When I got an error, I asked if to fix the error and or identified that Bookmarklets work better as single lines, so it fixed it. Then I added the requirement about replacing scripts, and it did that too, but for commented and a clean one-line version.
The one-live versions even up getting truncated, so I need to copy/paste from earlier (correct) endings, but otherwise it was an incredibly smooth experience.
I spent longer writing the guide for how to use it than the time it took to vibe code it and test it. I was super impressed.
You claim no JavaScript experience, declare confident in the comments and include any examples.
All you’ve really said here is you vibed coded a solution to a problem using one of the most common languages without knowing the language. And made claims you do not attempt to prove.
I know enough to parse the code, especially with the comments. It was a logical algorithm, it worked, and it was just for reformatting a page to print cleanly, so there was basically no risk if it didn’t work. I code for work, I just don’t know JavaScript syntax or functions.
Anyway, I was impressed it actually worked. I’m an AI skeptic, which is why I thought it was noteworthy to get well documented, clean, functional code from vibe coding—even in such a trivial context as swapping a head tag and removing script tags.
a trivial context as swapping a head tag and removing script tags.
Very curious what it actually generated here because that sounds really basic but as coders we tend to downplay complexity when describing things (why our documentation is often bad) so maybe it’s more than just some trivial dom manipulation.
What the fuck is wrong with you Copilot? This piece of shit trying to hide all the errors. If I don’t know there are errors then there aren’t errors. Apparently
I wish to god Visual Basic was still around so Copilot et. al. could get infected with ONERRORRESUMENEXT statements. Or its under-appreciated but vastly more horrific cousin ONERRORRESUME.
I might make that my first coding project after I retire. I bet I can code up a global import that implements “ON ERROR RESUME” in a couple of modern languages…
// 🤦 You are totally right! Simply logging the 🚨 error to the console isn't proper error handling. 🫣 We now throw an exception instead. throw new ApplicationException(error);
Proper comments describe why… For example say you are using an api which requires guids and your application doesn’t care are collisions as much so just use int id’s.
You could add in a comment like
// creating a guid to interface with special api.
But just saying
// generate guid
Means nothing, your method should be generate_guid() or GenerateGuid(). Your comment is repeating.
Or this is probably going to hit my last company at some point, there was a system to read a serial number. They also wanted a “status” on the screen to verify the system was connected and running properly but both these values came over same signal wire. Depending on your exact ms timing sometimes you would read the status as the serial number. Another programmer wrote a check to verify the serial number did not start with OK. The comment added was
// add on 11/15/23 by Initials
With no other details. The serial numbers were 8 numeric digits. Someone won’t know the history and delete this seemingly useless check and cause a 10s of 1000s of dollars in loss
I used to write it all the steps I thought I’d need as these types of comments, then go back and write the real methods. But I usually replaced the comments with more detailed jsdocs style comments with as much detail about the parameters as returnvalues as possible.
The only times I’ve seen devs do inline comments in their code is when it’s been done by AI, and I can tell it’s AI because the comments are all useless and describing what’s happening, not why.
// Format user object function formatUserObject(user) {I’ve seen lots of such crap written by humans. I guess AI had to learn it from somewhere.
AI mostly learned it from programming tutorials and things like documentation and Q&A forums like StackOverflow. People often add comments in those cases to explain to somebody not familiar with code what is happening so they can learn from it.
In actual code written by people who write code for a living I’d hope the comments are much more useful and usually not as prevalent.
I actually got really clean, well commented code from Copilot earlier this week.
I have no experience with JavaScript to speak of, but realized a Bookmarklet would be a perfect solution for reformatting a particular arcuate for printing. I already had a head replacement with CSS to do all the formatting, and I was using a RegEx to strip all script tags.
Anyway, I asked Copilot to write the Bookmarklet to replace the header, with full contents explaining the training behind the code, and an explanation of how the script functions below. When I got an error, I asked if to fix the error and or identified that Bookmarklets work better as single lines, so it fixed it. Then I added the requirement about replacing scripts, and it did that too, but for commented and a clean one-line version.
The one-live versions even up getting truncated, so I need to copy/paste from earlier (correct) endings, but otherwise it was an incredibly smooth experience.
I spent longer writing the guide for how to use it than the time it took to vibe code it and test it. I was super impressed.
(Granted, that’s a pretty easy coding task…)
You claim no JavaScript experience, declare confident in the comments and include any examples.
All you’ve really said here is you vibed coded a solution to a problem using one of the most common languages without knowing the language. And made claims you do not attempt to prove.
I know enough to parse the code, especially with the comments. It was a logical algorithm, it worked, and it was just for reformatting a page to print cleanly, so there was basically no risk if it didn’t work. I code for work, I just don’t know JavaScript syntax or functions.
Anyway, I was impressed it actually worked. I’m an AI skeptic, which is why I thought it was noteworthy to get well documented, clean, functional code from vibe coding—even in such a trivial context as swapping a head tag and removing script tags.
Very curious what it actually generated here because that sounds really basic but as coders we tend to downplay complexity when describing things (why our documentation is often bad) so maybe it’s more than just some trivial dom manipulation.
// 🚨 Log error to console console.error(error);I once tried vibe coding a web app using GitHub Copilot. That motherfucker wrapped every single endpoint with
try: ... except Exception: return "An error occurred"What the fuck is wrong with you Copilot? This piece of shit trying to hide all the errors. If I don’t know there are errors then there aren’t errors. Apparently
It’s actually kind of hilarious how closely it mimics a human programmer who just sucks at it.
I wish to god Visual Basic was still around so Copilot et. al. could get infected with
ON ERROR RESUME NEXTstatements. Or its under-appreciated but vastly more horrific cousinON ERROR RESUME.I might make that my first coding project after I retire. I bet I can code up a global import that implements “ON ERROR RESUME” in a couple of modern languages…
// 🤦 You are totally right! Simply logging the 🚨 error to the console isn't proper error handling. 🫣 We now throw an exception instead. throw new ApplicationException(error);I sometimes suspect that I am actually an AI. I’ve always struggled with captchas and I comment my code exactly as you’ve just described.
Proper comments describe why… For example say you are using an api which requires guids and your application doesn’t care are collisions as much so just use int id’s.
You could add in a comment like
// creating a guid to interface with special api.
But just saying
// generate guid
Means nothing, your method should be generate_guid() or GenerateGuid(). Your comment is repeating.
Or this is probably going to hit my last company at some point, there was a system to read a serial number. They also wanted a “status” on the screen to verify the system was connected and running properly but both these values came over same signal wire. Depending on your exact ms timing sometimes you would read the status as the serial number. Another programmer wrote a check to verify the serial number did not start with OK. The comment added was
// add on 11/15/23 by Initials
With no other details. The serial numbers were 8 numeric digits. Someone won’t know the history and delete this seemingly useless check and cause a 10s of 1000s of dollars in loss
I used to write it all the steps I thought I’d need as these types of comments, then go back and write the real methods. But I usually replaced the comments with more detailed jsdocs style comments with as much detail about the parameters as returnvalues as possible.
Then I quit web dev and moved to the woods.
Yeah effectively using comments as psuedocode
yeah, I put rules to highly discourage comments entirely when generating code
deleted by creator