GitHub Copilot explaining code and translating it from one language to another

GitHub Copilot is already the dog’s bollocks, but I just installed the GitHub Labs extension and my jaw is still open. Code explanation This one allows you to highlight a piece of code and get explanations of what it does: For example: async function downloadZipFile(downloadUrl) { await fs.remove(‘out/edge’); const file = fs.createWriteStream(‘edge.zip’); https.get(downloadUrl, function(response) { […]

GitHub Copilot is already the dog’s bollocks, but I just installed the GitHub Labs extension and my jaw is still open.

Code explanation

This one allows you to highlight a piece of code and get explanations of what it does:

Screencast showing the explanation feature in action

For example:


async function downloadZipFile(downloadUrl) {
await fs.remove(‘out/edge’);

const file = fs.createWriteStream(‘edge.zip’);
https.get(downloadUrl, function(response) {
response.pipe(file);
response.on(‘end’, async ()=>{
await fs.createReadStream(‘edge.zip’).pipe(unzipper.Extract({path: ‘out/edge/’}));
await fs.unlink(‘edge.zip’, () => {} );
const outdir = path.join(__dirname, ‘out’, ‘edge’);
console.log(`Edge files extracted to: ${outdir}`);
});
});
}

Turns into:

  1. We first delete the ‘out/edge’ folder.
  2. We downoad the Edge.zip file from the GitHub release page.
  3. We unzip the Edge zip file to the ‘out/edge’ folder.
  4. We print a message to the console.

Code translation

You can also highlight a piece of code and it gets translated to another language. For example, JavaScript to PHP.

Screencast of GitHub Copilot translating JavaScript to PHP

I am so looking forward to where this is all going!


Print Share Comment Cite Upload Translate
APA
Chris Heilmann | Sciencx (2024-03-29T05:44:38+00:00) » GitHub Copilot explaining code and translating it from one language to another. Retrieved from https://www.scien.cx/2022/06/07/github-copilot-explaining-code-and-translating-it-from-one-language-to-another/.
MLA
" » GitHub Copilot explaining code and translating it from one language to another." Chris Heilmann | Sciencx - Tuesday June 7, 2022, https://www.scien.cx/2022/06/07/github-copilot-explaining-code-and-translating-it-from-one-language-to-another/
HARVARD
Chris Heilmann | Sciencx Tuesday June 7, 2022 » GitHub Copilot explaining code and translating it from one language to another., viewed 2024-03-29T05:44:38+00:00,<https://www.scien.cx/2022/06/07/github-copilot-explaining-code-and-translating-it-from-one-language-to-another/>
VANCOUVER
Chris Heilmann | Sciencx - » GitHub Copilot explaining code and translating it from one language to another. [Internet]. [Accessed 2024-03-29T05:44:38+00:00]. Available from: https://www.scien.cx/2022/06/07/github-copilot-explaining-code-and-translating-it-from-one-language-to-another/
CHICAGO
" » GitHub Copilot explaining code and translating it from one language to another." Chris Heilmann | Sciencx - Accessed 2024-03-29T05:44:38+00:00. https://www.scien.cx/2022/06/07/github-copilot-explaining-code-and-translating-it-from-one-language-to-another/
IEEE
" » GitHub Copilot explaining code and translating it from one language to another." Chris Heilmann | Sciencx [Online]. Available: https://www.scien.cx/2022/06/07/github-copilot-explaining-code-and-translating-it-from-one-language-to-another/. [Accessed: 2024-03-29T05:44:38+00:00]
rf:citation
» GitHub Copilot explaining code and translating it from one language to another | Chris Heilmann | Sciencx | https://www.scien.cx/2022/06/07/github-copilot-explaining-code-and-translating-it-from-one-language-to-another/ | 2024-03-29T05:44:38+00:00
https://github.com/addpipe/simple-recorderjs-demo