This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-10
Channels
- # announcements (4)
- # babashka (40)
- # beginners (39)
- # calva (16)
- # cljdoc (1)
- # cljs-dev (8)
- # clojure (72)
- # clojure-europe (10)
- # clojure-losangeles (1)
- # clojure-nl (4)
- # clojure-spec (9)
- # clojure-uk (12)
- # clojurescript (16)
- # community-development (15)
- # conjure (5)
- # cursive (5)
- # datomic (26)
- # eastwood (1)
- # emacs (7)
- # events (1)
- # figwheel-main (15)
- # fulcro (27)
- # graphql (7)
- # gratitude (4)
- # introduce-yourself (1)
- # malli (4)
- # meander (4)
- # off-topic (2)
- # other-languages (13)
- # polylith (7)
- # reagent (5)
- # reitit (5)
- # shadow-cljs (27)
- # spacemacs (4)
- # sql (3)
- # tools-deps (6)
- # xtdb (13)
Since I’m writing JavaScript, I’m using VSCode, and it has copilot. I’m getting freaked out by it.
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.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);
}
I think this is a simpler version of the github's mechanism: https://en.akinator.com/ https://www.youtube.com/results?search_query=akinator
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?
Like when you say you had to check it carefully, did that take you more time than it would have to convert it yourself?
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.
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
> 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
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
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