other-languages

quoll 2022-01-10T01:33:10.017200Z

Since I’m writing JavaScript, I’m using VSCode, and it has copilot. I’m getting freaked out by it.

2022-01-12T04:24:19.033900Z

That's neat. My feeling right now though is how often can it be wrong, and does it take me longer to validate it isn't wrong, or to just do it from scratch myself?

2022-01-12T04:25:14.034100Z

Like when you say you had to check it carefully, did that take you more time than it would have to convert it yourself?

Martynas Maciulevičius 2022-01-12T16:28:43.034500Z

It's code without tests. This is why it took time. I think it should be the same as reading a function written by another person and without tests.

quoll 2022-01-12T16:30:58.034700Z

It does take me longer to check it, and sometimes it’s wrong. Worse, sometimes it’s subtly wrong. But I’m amazed at when it gets it right

2022-01-13T04:54:34.034900Z

> I think it should be the same as reading a function written by another person and without tests. That often takes me longer then writing it myself haha

2022-01-13T04:56:17.035100Z

I guess maybe it would work really well in a TDD workflow though, since you'd write your tests first, then auto-complete the full implementation if possible and just see if it passes your tests

👀 1
Martynas Maciulevičius 2022-01-13T05:02:08.035400Z

I can already imagine having a seed for the generator and then only writing tests. And having a source directory which you can't ever edit... And for mutation testing... you only change the seed xD

2022-01-13T05:05:22.035600Z

That would kind of be crazy, in the future, programmers only write tests lol, Copilot writes all the implementation for you

Martynas Maciulevičius 2022-01-11T05:52:02.020900Z

I think this is a simpler version of the github's mechanism: https://en.akinator.com/ https://www.youtube.com/results?search_query=akinator

quoll 2022-01-10T01:38:08.017300Z

To explain… I have a constants that I declared:

const TWO_32 = 0x100000000;
const INT_MASK = 0xFFFFFFFF;
It’s 2^32, and it one larger than the largest number that can fit into an unsigned int (which is the INT_MASK value). ie. it has overflowed into the 33rd bit position. I also have a function called unsignedLonger, which converts a 32-bit number into a positive number, even if the top bit is set to 1 (which normally makes it negative). This means, for instance, that 0xFFFFFFFF will be returned as 4294967295 instead of -1.

quoll 2022-01-10T01:40:02.017500Z

With that in mind, I was about to port this Java code (which I’m sure that copilot has already seen and analyzed):

boolean carry = (sum >>> 32 != 0);
while (xIndex > 0 && carry)
    carry = ((result[--xIndex] = x[xIndex] + 1) == 0);
Copilot suggested this:
var carry = (sum >= TWO_32);
while (xIndex > 0 && carry) {
    sum = unsignedLonger(x[--xIndex]) + 1;
    result[xIndex] = sum & INT_MASK;
    carry = (sum >= TWO_32);
}

quoll 2022-01-10T01:41:20.017800Z

This is entirely correct. But I had to check it carefully, because… what the hell!