Non-programmers intro to AI for programmers
post by Dustin · 2022-04-05T18:12:08.337Z · LW · GW · 0 commentsContents
No comments
It occurs to me a lot of people are interested in AI but aren't programmers themselves.
This quick post describes using an AI helper called Github CoPilot. It will do so via a short scenario wherein CoPilot helps me write a bit of code. It will be almost completely non-technical (or, at least, as non-technical as is possible). The aim is to describe the experience and practicalities of using this technology.
Since this is aimed at non-programmers, a piece of background information is in order:
Programming is mostly not about remembering how to do specific things. It's more about knowing how systems work so you know what to look up when you want to do some specific thing. (Of course, the more you do a specific thing, the remembering comes along.)
On to the scenario...
Say I need to write some code to check if some content on a web page is larger than it's container on a web page. You've seen this before when some content on a page has its own scroll bars in addition to the main scroll bar on the side of your browser.
I've done this kind of check before, and I know how web browsers work, and I know basic logic. However, I don't remember off-hand the specific ways to access the information I need.
A piece of code that would tell me if some content was bigger than it's container might be called isOverflowing
, so let's try that:
(Don't worry, you don't really have to read or understand any of that if you don't want to. Again, we're just describing the experience.)
The green text that appears is what CoPilot is suggesting I use as the code for the function...and it's exactly what I want. I know it is what I want because it prompts my memory for things I already knew. So, I pressed Tab
and the suggested code became real code in my editor.
This is one of the benefits I get out of CoPilot: I don't have to go searching on the web for the names of the information I need, CoPilot just knows them for me. Here it probably saved me 5-10 minutes of Googlin'.
In this instance, as soon as I saw them, I remembered that scrollHeight
, clientHeight
, etc. are the right tools for the job I needed done. However, if I was less familiar with what I needed, I would hit up documentation and/or Google to make sure this code was correct because sometimes what I want and what CoPilot thinks I want don't match up.
CoPilot helps with other types of problems as well:
- Drudge work. If there is some sort of pattern to the type of code I'm writing CoPilot often picks it up after just a couple of examples and does it all.
- Comment writing. Instead of writing comments first, sometimes I explore an idea by writing code and when I'm done I start writing a descriptive comment for future reference...and CoPilot writes almost all of it for me.
- Code writing. It also does the reverse of the previous point. I can write a comment describing what I want to do and CoPilot will write the code. This often works, but I find this is where I have to be most vigilant in making sure CoPilot is writing the correct code.
I'll try to come up with some demos of the previous points if anyone is interested.
I think CoPilot saves me time, but a person also has to be vigilant. It can suggest code that looks good at first glance, but does the opposite of what you want or doesn't work at all or has security vulnerabilities.
0 comments
Comments sorted by top scores.