Recently, I’ve been working on a new project in golang, which I haven’t worked with in a couple years.
I have almost completely replaced the time I usually spend searching stackoverflow for the simple, routine stuff (like how to easily filter a list in golang like I can in python), and then adapting whatever answer I find with a simple query to Mixtral.
Usually, Mixtral gives me a direct answer to my question that requires no actual adaptation.
However, I found, frequently the code is not quite correct and seems to be a blend of programming languages.
To get around this, I started asking Mixtral for a test for whatever code it generates, and this was a game changer. To state it simply, the tests are pretty good, and require very little tweaking to get running. With the tests I have confidence in the code it generates.
Once, I even asked it to write a test for one of my own functions and it said it could do that but first I needed to know about a bug in the code, AND IT WAS RIGHT.
All of these little ventures to stackoverflow add up and I am convinced that using Mixtral has saved me one or two days just for this project that took about a week. For a project where I was more familiar with the programming language, I’m not sure the time saving would be so dramatic, but I’m impressed nonetheless.
Now, this post wouldn’t be complete without mentioning that it hasn’t all been roses. A couple times it needlessly complicated the code, and once it was even wrong (trying to parse scientific notation), but it still saved me a ton of time.
Here’s one of the tests it generated:
func TestChunkSlice(t *testing.T) {
testCases := []struct {
name string
input []any
chunkSize int
expectedChks [][]any
}{
{
name: “Empty Input Slice”,
input: []any{},
chunkSize: 3,
expectedChks: nil,
},
{
name: “Input Slice With Zero Chunk Size”,
input: []any{1, 2, 3},
chunkSize: 0,
expectedChks: nil,
},
{
name: “Single Element Input Slice”,
input: []any{1},
chunkSize: 1,
expectedChks: [][]any{{1}},
},
{
name: “Small Input Slice”,
input: []any{1, 2, 3, 4, 5},
chunkSize: 2,
expectedChks: [][]any{{1, 2}, {3, 4}, {5}},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
actualChks := ChunkSlice(tc.input, tc.chunkSize)
if len(actualChks) != len(tc.expectedChks) {
t.Fatalf(“Expected %d chunks but got %d chunks.”, len(tc.expectedChks), len(actualChks))
}
for idx, exp := range tc.expectedChks {
if len(exp) != len(actualChks[idx]) {
t.Errorf(“Expected chunk #%d to have %d items but found %d items.”, idx, len(exp), len(actualChks[idx]))
} else {
for jdx, val := range exp {
if !reflect.DeepEqual(val, actualChks[idx][jdx]) {
t.Errorf(“Mismatch between expected (%v) and actual (%v)”, val, actualChks[idx][jdx])
}
}
}
}
})
}
}
Comments URL: https://news.ycombinator.com/item?id=39751674
Points: 1
# Comments: 1