Hacker News new | ask | show | jobs
by BubRoss 2294 days ago
I'm not going to integrate LAPACK for a single line expression.
1 comments

LAPACK is the underlying library behind most linear algebra packages in other languages and furthermore it was just an example. My guess is that you probably don’t have just one line of matrix manipulation ever, in which case using a well established library is a good idea. If not, then sure. Do it yourself. But that’s still more code that you have to maintain now.
> But that’s still more code that you have to maintain now.

10 lines of code is easier to maintain than a whole dependency.

That's arguable, because 10 lines of code almost never just stays 10 lines of code, and my point in the first place was more contesting that the dependency is hard to choose, or that there aren't solid proven libraries for this.
A counterargument:

1 large, complex dependency (plus the 20 lines of wrapper code to transform your program's internal data to initialise and call the library) almost never just stays as 1 large, complex dependency (plus 20 lines of ...).

If you're truly just doing a 2x2 matrix manipulation once in the codebase, then I concede. I guess I'm blanking on situations where that would be the case though, or where more generalized capabilities wouldn't be useful.
That's fair enough.

But I was really just wanting to show, via irony, that the structure of the original argument is self-annihilating.

That is, "X almost never stays as just X therefore X is bad" applies to both branches reasonably, and is therefore invalid as an argument in support of one branch.

> If you're truly just doing a 2x2 matrix manipulation once in the codebase

That is the precise premise of the hypothetical.

This is why it's important to add a comment to those 10 lines describing the choice, and urging future contributors to reevaluate the situation.

(Of course, one should always reevaluate the situation when making changes to code, but we all need a nudge sometimes when we're afraid of doing the wrong thing.)

Now that, I can wholeheartedly agree with :)
> 10 lines of code almost never just stays 10 lines of code

This is only true when you implement business logic, not when you implement algorithms.

The difference between those two things is often blurry from a distance. Business logic is algorithmic too, it's just a question of how specific and complex the algorithm is.
Business logic changes and grows more complex over time, how to invert a matrix doesn't. Trust me, I implement algorithms for a large library for a living, they very rarely change or grow.
Not really, the individual STL algorithms haven't changed. Partition is still a one line loop. Some things can be left alone.