Hacker News new | ask | show | jobs
by TimorousBestie 17 days ago
> Claude and Codex are now generating all my code for me now, and I see them spitting out SVD code frequently -- often for very special cases.

I find this so annoying. I had to PR some Claude-generated gaussian elimination routine last month and making sure it got the pivoting logic correct was a waste of my time.

3 comments

How big of an advantage was it, to have the code developed specifically for your project? These AI tools are pretty impressive, but why not have it generate a call to BLAS or PARDISO or something?
There are cases where you don't want the footprint of bringing in another framework / library or that is not even an option.
Yeah, I’m curious what put them in that case here, though. There are high quality open source linear algebra codes out there, so I’m surprised that they needed something generated. (But, just surprised and curious to hear more, not saying they are wrong or anything like that).
Here is an example. I wrote a MacOS app in Objective-C++/C++ that used Eigen's JacobiSVD solver at one point. A colleague of mine use Claude to port it into a web tool that used JavaScript. I scrolled thru the JS code and saw that is wrote is own Jacobi SVD solver. So I assume it did this match the exact behavior of the MacOS app -- using a 3rd party solver may not accomplish this. SVD solvers can behave differently in different use cases. What are the options for JS?
Not sure, I’m not familiar with the web ecosystem. Not familiar at all, so my next question will probably be stupid. Would it have been possible to compile your C++ library to WebAssembly?
I am sure it probably was - a bit heavier option. There other mobile / VR / XR apps that I had to port to a variety of platforms using languages like Swift and Kotlin -- each platform has its own vector library. These don't necessarily provide SVD routines. Apple has their Accelerate framework, but is very unnatural to use IMO -- and Swift and C++ don't play that well together regardless of what folks say (that is why I tend to still use Obj-C++ when I have a choice).

There was another app where I had a 3x3 shear transformation that I needed to decompose into a rotation * scale * rotation which is exactly what SVD does (see https://tinyurl.com/384mkdvh). No need to bring in a full linear algebra package just for that.

Solution of linear system is one of those problems that you should program yourself to learn the methods. But there are so many edge cases and details that you have to rely on libraries for production.
You are doing it wrong. Have Claude generate the test code and log test data that it can feed back into itself. Claude can generate tests and verify the code better than humans now. I don't trust humans to get things right anymore -- I have a PhD and Claude knows all the math and libraries better than me.
> You are doing it wrong.

I didn’t write any of it. I occasionally get assigned PRs written (or not, in this case) by other devs.

> Claude can generate tests and verify the code better than humans now.

It certainly didn’t do that in this case.

> I don't trust humans to get things right anymore -- I have a PhD and Claude knows all the math and libraries better than me.

If it knows all the libraries so well, why did it add a bespoke implementation?

If you're getting code without tests to review in a PR, that should be an instant reject without even looking at the code.
> If you're getting code without tests to review in a PR, that should be an instant reject without even looking at the code.

Management didn’t like that the last time I was assigned a AI-gen PR and I like my job otherwise.

Go ahead and have claude add and run units tests for you as part of the PR review process.
Claude is absolutely terrible at writing unit tests, this advice continues to perplex me. Coding agents usually slam you with hundreds of lines that do little more than “test” what is obvious. Maybe it’s good for an API revision or such. But for linear algebra where errors might not manifest unless suitably chosen inputs are generated based on expert knowledge, that’ll be useless.
Have you used Claude lately? It definitely will outperform a human at this task now.
That's on the submitter of the PR to do. Don't put that burden on the reviewer.
No problem for claude. In fact I would have claude do the PR and go have lunch.
I don’t get paid to do my job and then also the submitter’s job.