3 ms·
At the old place where I worked, I had a couple friends that just did porting work. I thought it was ridiculous porting basic things like string manipulations
by iamwil 19y ago
At the old place where I worked, I had a couple friends that just did porting work. I thought it was ridiculous porting basic things like string manipulations and stacks from one language to another. We simply did it, because languages evolve and needs evolve...and to use something, we often find it easier to rewrite the damn thing in another language.
However, you can't be sure that you did it right during the rewrite. This is where I figured unit tests, if it could be preserved somehow, between ports, would be useful. Then you can run the unit tests against the set of new code, then you can be pretty sure that your new code did what your old code did (at least the stuff you tested for). If there was somewhere, where this type of unit testing existed for basic stuff like stacks, linked lists, time converters, etc. was in a public repository of some sort...then you can run these unit tests every time you had a new piece of code.
Then taking it one step further, I thought then it'd be an interesting reason for humans to NOT write this type of code, since conceivably, you can use genetic algorithms for it. Because when you think about it, unit tests are basically evaluation functions (the environment) for a population of programs. Theoretically, people would ease themselves the burden of rewriting basic well-understood algorithms and data structures, like quicksort and red-black trees, etc.
But the thing I dislike about unit tests is really just how many of them there are. It's mostly because unit tests take one case at a time and test it...case by case. This is where I feel like rigors of mathematics is enviable. Math functions are basically generalizations of a lot of different, but related specific cases. A lot of math statements are succinct ways to declare all cases you'd care about across the board--the times it fails, is when you have piece-wise functions, then you get that funny big "{". If there was a more functional way to express unit tests, that would be an interesting avenue to explore--and save the rest of us on typing.
- michaelneale 19y agoI think your wish has been granted - conditionally. If you use haskell, you have QuickCheck, which is quite amazing. If you use scala - you can use ScalaCheck which is essentially a port of the same ideas to scala. Very cool stuff.