zlacker

[parent] [thread] 15 comments
1. speedg+(OP)[view] [source] 2021-10-27 18:43:23
It does the boring code for me.

If I want to throw an exception if an object is null or undefined, Co-pilot will do the if and the exception throw using the right error class, and a more meaningful error message that what I usually came up with.

If want to map some random technical data table to something useful in my programming language, I can copy paste the data from the documentation in pdf or html into a comment block, give an example, and co-pilot will write everything in the format I want.

If I want to slightly refactor some code, I can do it once or twice and co-pilot can help me a lot to refactor the remaining.

If I want to have a quick http server in nodejs, I don't have to Google anything.

It's a lot of tiny things like this.

replies(1): >>TaupeR+G4
2. TaupeR+G4[view] [source] 2021-10-27 19:05:07
>>speedg+(OP)
This is the kind of thing I would need to see in real time, because I simply can't believe that it does any of these things in a way that is reliable and doesn't involve having to search through and make sure it hasn't made any mistakes, taking just as much time as if you did it by hand.
replies(3): >>gfosco+G9 >>Polycr+Eb >>baby+Cf
◧◩
3. gfosco+G9[view] [source] [discussion] 2021-10-27 19:28:57
>>TaupeR+G4
Likewise skeptical, but I have been super impressed with it. I just got in to the technical preview, and worked through a specific task I needed to do (involving mongoose, a mongo aggregate query, a few loops, some date functions) and started by adding a comment above each line. It helped a lot actually, felt like a collab.

I'll reproduce a generic example I sent a friend.

Prompt:

    const redis = require('redis');

    // Create a redis client
Copilot suggested:

    const client = redis.createClient();
I accepted it and moved 2 lines down, prompt:

    // Get the current count from redis
Copilot suggested a start to the operation:

    client.get('count', (err, count) => {
I accepted it, and Copilot continued:

      if (err) {
        console.log(err);
        return;
      }

      // If there is no count, set it to 0
      if (!count) {
        count = 0;
      }

      // Increment the count
      count++;

      // Set the new count in redis
      client.set('count', count);
  
      // Log the new count
      console.log(count);
    }
replies(3): >>aaaaaa+Sb >>foepys+Ec >>matsem+Rl
◧◩
4. Polycr+Eb[view] [source] [discussion] 2021-10-27 19:37:23
>>TaupeR+G4
It's _very_ good at "learn by example" with some twists. It _does_ make mistakes, and I do double check it, but it still definitely saves time. I used it to write the bulk of a new implementation of a new audio backend for a game engine yesterday - it filled out a lot of the "boilerplate" integration work (e.g. generating all the functions like "set volume/pan/3D audio position" that map over 1:1 to functions in the other library).

I will say, though, that it's also good at making up code that looks very believably real but doesn't actually work.

The ethics involved in Copilot are a bit strange, and I'm not sure I'll keep using it for those reasons, but it does a good job.

◧◩◪
5. aaaaaa+Sb[view] [source] [discussion] 2021-10-27 19:38:09
>>gfosco+G9
Why does it increment the count?
replies(1): >>gfosco+jd
◧◩◪
6. foepys+Ec[view] [source] [discussion] 2021-10-27 19:41:29
>>gfosco+G9
Redis has the INCR command that does this in redis without the additional round-trips (and race conditions). It also sets the value to 0 if the key doesn't exist.

So, I actually consider this to be exactly the bad behavior that people accuse Copilot of.

replies(2): >>gfosco+Yf >>speedg+ch
◧◩◪◨
7. gfosco+jd[view] [source] [discussion] 2021-10-27 19:44:02
>>aaaaaa+Sb
I assume that in its training, incrementing a counter in redis is common.
◧◩
8. baby+Cf[view] [source] [discussion] 2021-10-27 19:55:23
>>TaupeR+G4
I was really skeptical at first, but after using it for a while omg it is just insane.
◧◩◪◨
9. gfosco+Yf[view] [source] [discussion] 2021-10-27 19:56:41
>>foepys+Ec
This was just one of its suggestions, but you're right of course.. it's all based on the training data and idioms used there. If it doesn't weight more modern code higher, if it's not aware of new versions and methods, it isn't going to be super intelligent.. but it can still give you some ideas.
◧◩◪◨
10. speedg+ch[view] [source] [discussion] 2021-10-27 20:03:32
>>foepys+Ec
Yes it's not very shinning there. I would also throw the error instead of printing the error to the console and returning undefined.
replies(1): >>ponyou+PC
◧◩◪
11. matsem+Rl[view] [source] [discussion] 2021-10-27 20:28:19
>>gfosco+G9

  // Create a redis client
Writing that probably takes a longer time than just doing it with the IDE help in jetbrains, though?

Press "r", press "." to autocomplete so it now says "redis.", then write "cC" and it suggests createClient (or write "create" or "client" if you're not sure what you're looking for). Now it says "redis.createClient()". Press ctrl+alt+v to extract a variable or write ".const" and press tab to apply the const live template. Ending up with your result in two seconds.

replies(1): >>anigbr+Io1
◧◩◪◨⬒
12. ponyou+PC[view] [source] [discussion] 2021-10-27 22:12:08
>>speedg+ch
You are in a callback there. Goodbye your error!
replies(1): >>speedg+6A1
◧◩◪◨
13. anigbr+Io1[view] [source] [discussion] 2021-10-28 05:31:27
>>matsem+Rl
The power of something like Copilot is in building out stuff you're not familiar with or don't have templates set up. It's probably not as helpful when you already have a clear idea of what you want to do and just need it rather than think about it.

+1 for the variable extraction thing, I've been using their IDE for ages and it never occurred to me to look for such a thing.

replies(1): >>matsem+jz1
◧◩◪◨⬒
14. matsem+jz1[view] [source] [discussion] 2021-10-28 07:25:03
>>anigbr+Io1
I use it especially much when writing old school java. Instead of writing "MyClass myclass = new MyClass()", I just write "new MyClass()" and get the typing for free. Even better when you do longer expressions and don't want to think about the type up front. Like working with streams or so.
replies(1): >>anigbr+iI1
◧◩◪◨⬒⬓
15. speedg+6A1[view] [source] [discussion] 2021-10-28 07:34:25
>>ponyou+PC
Oh right. I once made a layer on top of the redis client to use promises because callbacks are a pain to deal with.
◧◩◪◨⬒⬓
16. anigbr+iI1[view] [source] [discussion] 2021-10-28 09:02:57
>>matsem+jz1
Yeah this would be quite helpful for me as I tend to just experiment with things in the console (cleaning up messy datasets and the like) and then copy or rewrite into something more structured later. I feel like I'm only using about 20% of what Pycharm can do.
[go to top]