r/ProgrammerHumor • • Oct 26 '21

GitHub Copilot, the technology that will replace programmers. Also GitHub Copilot...

27k Upvotes

713 comments sorted by

View all comments

57

u/The--HackerMan Oct 26 '21 edited Oct 26 '21

Image Transcription: GIF


[Someone types a javascript comment, the camera follows the comment being written, it pans to the right.]

// convert num to string

[The camera unzooms, and follows the code as it is written. Github Copilot is typing a javascript function.]

const numToString = (num: number) => {
  if (num === 1) {
    return "1";
  }
  if (num === 2) {
    return "2";
  }
  if (num === 3) {
    return "3";
  }
  if (num === 4) {
    return "4";
  }
  if (num === 5) {
    return "5";
  }
  if (num === 6) {

I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

0

u/[deleted] Oct 26 '21

[deleted] — view deleted comment

7

u/The--HackerMan Oct 26 '21

Sorry about the return values, fixed those.

So the thing here is that Github-Copilot is listening to the comment, and writing the function itself, kind of a satire about copilot bad code?

3

u/reakshow Oct 26 '21

I personally think it's pretty helpful. It'd take a human a very long time to type out all those numbers.

1

u/Cidolfas2 Oct 26 '21

Apparently this is actually what copilot does if you train it on bad code to begin with, based on comments above. Haven’t tried it myself yet, I’m too scared 😱

3

u/TotoShampoin Oct 26 '21

You can type your functions in JS???!!

6

u/pet_vaginal Oct 26 '21

It's TypeScript.

2

u/TotoShampoin Oct 26 '21

I thought so

1

u/darkpaladin Oct 26 '21

But you should use Typescript. The only compelling reason I know of not to is laziness.

1

u/AquaeyesTardis Oct 26 '21

What’re the reasons to use it, other than streamlining writing functions/better debugging?

2

u/darkpaladin Oct 26 '21 edited Oct 26 '21

It makes it easier to onboard and find strange issues. I was converting a project over a few years ago. It was a SPA and while I was working through the router with the team I found a function that took a parameter. That parameter was supposed to be an object, but at some point someone modified it to accept a string or even a method instead. Asking why, no one knew, half the team didn't even know it could do that.

Typescript exposes such weirdness in your codebase, it also makes contracts clear so it's way easier to know what parameters you can use when consuming new code.

Edit: it's also a huge boon refactoring. Changing a signature from
(var1, var2, var3) => doStuff()
To
({var1, var2, var3}) => doStuff()

Typescript will light up all your code that doesn't match the signature, vanilla JavaScript will just break in strange and annoying ways.

1

u/TotoShampoin Oct 26 '21

Main reason I don't use TypeScript is because it converts back to JavaScript when rendering it, which makes it pointless in my opinion.

Also it requires things like babel to work, and... Well, no thanks, I like my plain web pages.

1

u/darkpaladin Oct 26 '21

Babel isn't that difficult to setup these days. I can't imagine writing vanilla JS anymore. The QoL improvements with Typescript/ES20XX are great and you don't have to worry about who's gotten around to supporting what. I guess if you don't write much JS and don't want to bother figuring out how to integrate into your build process.