TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

I have been using Mixtral everyday for coding and I think it has saved me days

3 点作者 bthornbury大约 1 年前
Recently, I&#x27;ve been working on a new project in golang, which I haven&#x27;t worked with in a couple years.<p>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.<p>Usually, Mixtral gives me a direct answer to my question that requires no actual adaptation.<p>However, I found, frequently the code is not quite correct and seems to be a blend of programming languages.<p>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.<p>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.<p>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&#x27;m not sure the time saving would be so dramatic, but I&#x27;m impressed nonetheless.<p>Now, this post wouldn&#x27;t be complete without mentioning that it hasn&#x27;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.<p>Here&#x27;s one of the tests it generated:<p><pre><code> func TestChunkSlice(t *testing.T) { testCases := []struct { name string input []any chunkSize int expectedChks [][]any }{ { name: &quot;Empty Input Slice&quot;, input: []any{}, chunkSize: 3, expectedChks: nil, }, { name: &quot;Input Slice With Zero Chunk Size&quot;, input: []any{1, 2, 3}, chunkSize: 0, expectedChks: nil, }, { name: &quot;Single Element Input Slice&quot;, input: []any{1}, chunkSize: 1, expectedChks: [][]any{{1}}, }, { name: &quot;Small Input Slice&quot;, 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(&quot;Expected %d chunks but got %d chunks.&quot;, len(tc.expectedChks), len(actualChks)) } for idx, exp := range tc.expectedChks { if len(exp) != len(actualChks[idx]) { t.Errorf(&quot;Expected chunk #%d to have %d items but found %d items.&quot;, idx, len(exp), len(actualChks[idx])) } else { for jdx, val := range exp { if !reflect.DeepEqual(val, actualChks[idx][jdx]) { t.Errorf(&quot;Mismatch between expected (%v) and actual (%v)&quot;, val, actualChks[idx][jdx]) } } } } }) } }</code></pre>

2 条评论

bthornbury大约 1 年前
Note that I had to remove two of the test cases to fit in the HN character limit:<p><pre><code> { name: &quot;Large Input Slice&quot;, input: []any{&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;, &quot;E&quot;, &quot;F&quot;}, chunkSize: 3, expectedChks: [][]any{{&quot;A&quot;, &quot;B&quot;, &quot;C&quot;}, {&quot;D&quot;, &quot;E&quot;, &quot;F&quot;}}, }, { name: &quot;Remaindered Large Input Slice&quot;, input: []any{&quot;W&quot;, &quot;X&quot;, &quot;Y&quot;, &quot;Z&quot;, &quot;1&quot;, &quot;2&quot;}, chunkSize: 4, expectedChks: [][]any{{&quot;W&quot;, &quot;X&quot;, &quot;Y&quot;, &quot;Z&quot;}, {&quot;1&quot;, &quot;2&quot;}}, },</code></pre>
mattfrommars大约 1 年前
What happens if you code base begins to be split between classes and they refer to each other.<p>How do you tackle the issue where you might needlessly copy file over and over again to provide Mixtral context