Slashdot Mirror


Immortal Code

ziani writes ""... Sometimes a piece of code is so elegant, so evolved, that it outlasts everything else." Nice article at Wired wondering how much great (and lousy) code is lost due to business failures."

21 of 354 comments (clear)

  1. Re:It's nice by Pieroxy · · Score: 3, Informative

    I think a hell of a lot of nice code will never be used. I remember in my former company (a dot-com), the only thing worth a look was the engineering team. Their very nice code (some of which is mine) will never be used considering the useless people in all the other parts of the company (CEO-VPs...)

    The company will probably be - according to the CEO himself - out of business in a couple of month. And all this beauty will be forgotten forever.

  2. Re:It's nice by DeadSea · · Score: 3, Informative

    The code that the article is about is neither concise nor elegant. The article is about Dragon speech recognition software which as miraculously survived several companies and failures. The article refers to it as "deep" code. Code that to hard to do over from scratch. The code in question is archived on 5000 CDs (the version control repository).

  3. Re:Oldest working code... by Blikbok · · Score: 2, Informative

    http://agents.www.media.mit.edu/groups/el/projects /spacewar/

  4. Re:Duff's Device by Anonymous Coward · · Score: 1, Informative

    This is pretty cool, jumping into an unrolled loop. I have seen this done in assembly many times before, but not in C. BTW, the division can be done with n >> 3 and the modulo can be done with n & 7.

  5. Numerical Recipes in C (NRC) library by obnoximoron · · Score: 5, Informative

    http://www.library.cornell.edu/nr/bookcpdf.html
    is a great example of long-lasting heavily reused library of frely available code. I have used the eigenvalue and matrix decomposition routines directly from NRC so many times I lost count.

  6. Re:Duff's Device by Anonymous Coward · · Score: 1, Informative

    PS: Yea, I do believe it beats the living crap out of memcpy() or BlockMove() or whatever other routine your using ;-)

    rep movsd used to be pretty swift. (in fact, I'm not sure why it isn't still the fastest method, the chip designers could make it just do cache line moves or whatever, couldn't they?)

  7. Re:Duff's Device by Anonymous Coward · · Score: 1, Informative

    Isn't there a quadword rep mov now? In any case, mov with a rep prefix will trash that little C trick on any Intel processor starting from about the 286. memcpy uses rep mov but does extra checking to make sure your blocks aren't aliased. If you know they aren't up front, an unchecked rep mov is about as fast as you can get.

  8. No! by Moonbird · · Score: 3, Informative

    NRC is (a) not free ... you'll have to pay a hell lot of money if you use the code directly and (b) shoddy code - at least the C code. I think it's just automatically converted Fortran code...

    --

    --
    All extremists should be taken out and shot.
  9. Re:Doubtful by Mr.+Slippery · · Score: 3, Informative
    Who doesn't keep a copy of their work, especially if it is good?

    Those who are afraid of being crushed by lawyers for violating NDAs, that's who.

    Last time I was job hunting I was asked for a code sample...all I could produce was a 2000 line Perl hack I did for my own amusement. Which was about all the Perl I've ever written, I'm a C/C++ guy. But I can't share anyone of the stuff I've done professionally, it's all copyrighted to my employers and trapped under non-disclosure agreements. (Well, some of the stuff I did back in grad school might be publically available somewhere.)

    --
    Tom Swiss | the infamous tms | my blog
    You cannot wash away blood with blood
  10. Re:It's nice by Anonymous Coward · · Score: 5, Informative

    >>or to change the API and then not tell you

    >I call BS. Can you give an example?

    Here you go:

    MSDN Library (which came with Visual Studio), ODBC 3.51 Programmer's
    Reference, API Reference for SQLGetDiagRec():
    BufferLength
    [Input]
    Length (in bytes) of the *MessageText buffer. There is no maximum
    length of the diagnostic message text. If the value returned in
    *MessageText is of a Unicode string (when calling SQLGetDiagRecW),
    the BufferLength argument must be an even number.

    Freshly downloaded Microsoft Data Access 2.6 SDK,
    same ODB 3.51 Programmer's Reference, API Reference for SQLGetDiagRec():

    BufferLength
    [Input]
    Length of the *MessageText buffer in characters. There is no maximum
    length of the diagnostic message text.

    It took me few days to figure that one out.
    Oracle ODBC call was corrupting heap.
    If length is in characters, no corruption.

  11. Re:Unbelievably depressing? by ronfar · · Score: 2, Informative
    I find these types of stories amusing in an ironic sense, much the way gallows humor is amusing (I mean amusing to the person who is about to die). Dragon (which was devoured by the company that later imploded due to massive fraud) gets added to the list of companies that were destroyed when they were transfered from people who had pride and love for what they do into the hands of people who saw them as revenue streams, like Atari, Infocom, TSR Hobbies, and so on.

    You can always understand why the people did it. Warner Brothers assured Nolan Bushnell he would still be in charge of Atari before they forced him out. Many of TSR's problems were caused by Gary Gygax's sneaky venture capital guys (not to mention his vindictive ex-wife and the widow of a former partner). Some of the people at the top of Infocom from the very start were only interested in big bucks and wanted to enter the lucrative business software field and leave games behind. The founders of Dragon thought they would have time and money to pursue other projects related to their interests.

    Another thing, any company with a successful software product needs to be worried about embrace, extend and extinguish, not just from Microsoft, but from other big software companies. Look at Bleem! versus Sony. You'll always have to look over your shoulder for big, politically connected competitors with an unfair advantage in our mercantilist legal system. Money can help here, money can get you through frivolous lawsuits designed not to be won but to drain the life out of you. Money can even help you when your well-heeled competitors use pressure tactics at retail locations if they stock your product instead of theirs. Face it, in software or videogames and in most other businesses small only remains an option if you manage to remain under the big comglomorates and monopolists radar.

    Even a small company can face a hostile take over if any of its operating or startup expenses come from outside sources.

    --
    All the creatures will die, And all the things will be broken. That's the law of samurai. (Jubai, 1605)
  12. Re:Duff's Device by Chocolate+Teapot · · Score: 2, Informative
    Moving 32 instead of 16 is nice, but IIRC the PowerPC can move 64 in one instruction (note this may take 2 cycles)? I cant' find any of my reference material anywhere, but I could have sworn the 604e and higher can move a double straight up
    In my experience, using the FP registers in this way did not yield any performance increase on the PPC. In some cases it was slower.
    I'm not familiar with PPC pipeline optimizations, know a good source of reference?
    I guess Google is the best place to start. Basically though, the PPC (currently) can perform up to four integer operations in parallel and one floating point operation (hence my suggestion that you use four src & dest pointers, adding 4 to each pointer every time round the loop). If your code requires the completion of a floating point operation before further integer operations can continue, then you could be delaying all four integer pipelines.
    AltiVec wouldnt' really offer very much unless you're doing mass mathmatical operations while transfering (add 0 and move 128 bits at once? or does the answer go to a register or the original memory location? can you access memory directly with AltiVec?). Might be nice for some kind of Geiss/G-Force type effects though. Again I'm not familiar with AltiVec in the least, except that it makes complex math fast because it's many mathmatical operations in parallel, and it's only availible on the G4 (and hopefully higher).
    AltiVec needs to obtain it's data from somewhere. Consequently, it has 128-bit load and store operations (last time I looked at BlockMoveData() in MacsBug, I noticed that it used them when available. Check out Apple's AltiVec HomePage for a bunch of useful information. It also covers cache optimisation and memory alignment techniques. This (off-topic) sub-thread has kind of assumed that we are only talking about memory copies. Many of the optimisation techniques discussed also apply to other operations on large blocks of memory (e.g. masked copies). We haven't even touched on overlapping memory blocks :)
    --
    Modest doubt is called the beacon of the wise. - William Shakespeare
  13. COPYRIGHT INFRINGEMENT by Anonymous Coward · · Score: 1, Informative

    This piece was actually written by Michael Surran, the man who was featured on Slashdot last week. It is available here

  14. Re:It's nice by theLOUDroom · · Score: 2, Informative

    They did announce that change- it was part of (I think) the transition from ODBC 2.x to ODBC 3. If the Devstudio docs still say the length is in bytes that's a documentation error since the API was changed and announced years ago.

    Now I call BS:
    If it's not in the API documentation, then it's undocumented.

    Maybe there's a note about it somewhere else, but things like changelogs are not an API reference. Documentation is meaningless unless it's in the right place. I'm not saying MS did this on purpose, but you've got to concede that he gave a valid example. You were just setting yourself up anyways. Did you really think that no one on /. would have a single example of an undocumented API change?

    Is it really that hard to believe that large software projects can have mistakes in their API documentation? It seems rather obvious to me. Whenever a project gets big enough, there are going to be a few bugs. OSS makes it easier to trace these bugs, because you don't have to blindly rely on documentation (which may be flawed). If something seems awry, you can look at the source. Then you know what you are actually calling.

    --
    Life is too short to proofread.
  15. The book is freely available, but not the code. by obnoximoron · · Score: 2, Informative

    Moonbird, thats true.
    http://www.nr.com/otherstufftop.html links to some of their public domain code such as wavelet routines, but the rest of the code is licensed. I ought to correct my post as 'freely available code documentation'.
    I had used the NRC routines about a decade ago (our univ department had licensed copies of it) and yes, they were not all gems of programming, but I could use them a basic recipes, starting points for brewing own code.

  16. Re:Oldest working code... by jstott · · Score: 3, Informative
    No doubt there are the zillions of line of code still kicking and screaming within industry, but I'm more interested with code that is out in the wild, and still being used somewhat actively.

    Any other contenders?

    Try www.netlib.org. It's all mathematical libraries, the old stuff is all in Fortran, and it does still get used even though some of it goes back to the late 60's and early 70's. Completely debugged code is hard to find, and when you get your hands on it, you hang on to it forever.

    -JS

    --
    Vanity of vanities, all is vanity...
  17. Another person who doesn't understand evolution. by aussersterne · · Score: 3, Informative

    As an anthropologist, I am always stunned by the misconceptions that some people have about evolution (primarily that it's just a one-time random snowstorm of debris that made man and beast out of nothing but mud).

    If you believe, as you seem to, that evolution is about producing something valuable from completely random events and matter, then you obviously have not studied evolution or the theories and hypotheses behind it, but have instead simply been listening to misinformation from the likes of Jerry Fallwell.

    Evolution does not function outside of one important context: the environmental context.

    Given this simple caveat to your post, we can now see that all programs are actually evolving.

    Consider this:

    A code snippet is written. But it doesn't function. What happens? It dies -- it is deleted, removed by its environment (i.e. the programmer and project) because it serves no purpose.

    Another code snippet is written. It works properly. Wow, it ends up in release 1.0! It has survived! It has a long and happy life on the retail shelf.

    But lo, another programmer comes along, sees the original code snippet, and adds to it so that it runs faster. Cool! Though 1.0 was very popular in its time, the 1.0 code snippet is removed and is never heard from again -- it has been out-competed by a new, more efficient snippet which works better.

    The new revision is so good, it becomes version 2.0! Soon it's everywhere; 1.0 is hardly ever seen any longer because 2.0 just works better and 1.0 keeps getting wiped and replaced by 2.0.

    Voila! Evolution.

    This exactly the way that natural selection (and by extension, macroevoluti) work on organic beings in the "real" world. Nature "proposes" a product by the mixing coding ideas (i.e. DNA) from different from individuals (i.e. SEX). If the result doesn't work -- if the code doesn't produce a functioning or an efficient product (i.e. individual) -- then the code dies and is never heard from again. If the code does work, then an efficient, functioning individual is born and survives into adulthood. The code lives! But now new ideas are infused into the code again (i.e. the new individual also has SEX!) and new DNA is born -- another new code snippet in the offspring. And yet again, if the code doesn't produce a viable product (i.e. individual), it eventually dies out -- removing it from the environment -- and it is never heard from again. But if the new code does produce a functioning, efficient individual, voila again! The code lives! Wash, rinse, repeat.

    Every time you or anyone else makes a baby, you are writing a new version of the code. Any time two whales mate, they are writing a new version of the code. The DNA is dancing, folks. If the new product works, it finds a place in the marketplace (the environment). It survives. If it happens to work better than anything else out there (Anna Kournikova, Natalie Portman), it dominates the marketplace and everyone wants a piece of it. As the generations pass, products with better code are better at survival -- getting food, getting attention, getting mates (and as a result, the good code doesn't die out).

    EVOLUTION.

    It's not random at all. It is actually an awful lot like software development.

    P.S...

    Voila! Voila! Voila! Voila! Voila!

    --
    STOP . AMERICA . NOW
  18. Unbelievably depressing! by giel · · Score: 2, Informative

    Yes. I find it very depressing. It's because of human nature. I'm not talking about you, me, or anyone in particular but individuals in general. It shows that we are a disgusting bunch of raping, stealing, exploiting, killing and reaping vultures. We do nearly anything if we might benefit from it. It doesn't really matter if it comes down to intellectual property, animals, geologic resources or just the power to rule. We consume and thereby destroy.

    Immortality might be achieved by sharing. Explain why widely published and available algorithms or OSS products and unpatented/copyrighted work outlasts all kind of proprietary and strongly protected software. If an individual gets lost, its properties get lost, just by getting forgotten or falling into the wrong hands, anyway it's lost for the public. In the end the public should decide what is usefull. That's good because only some (brilliant) individuals introduce new ideas and the (average) public should adopt or abandon. That's the way traditions and culture work.

    I'm not against copyright or patent. Copyright was invented only to share visions respecting the one who came up with them. Patents were invented only to prevent people with big resources to produce someones invention at large scale and so run away with the possible profit - correct me if I'm wrong; I always seem to confuse copyright, trademark and patent. Both are very good socialistic ideas, but in a liberal world they don't work. I could simply hire someone to 'steal' ideas. Put a copyright or patent on them before their creator does. And that's what happens at large scale, most contracts disown programmers/developers from their intellectual property involved during their employment.

    Nowadays copying and sharing of ideas has become very cheap. No wonder owners of valuable ideas are scared to share them. But... sharing them is the only way to let them become immortal. If - for example - Microsoft looses its strong ruler it will crumble. Nobody (except those who were involved) will know anything about the structure of the OS. There will be nobody able to adapt the products to new techniques and ideas, because they will be prevented by copyrights and patents.

    We have to deal with a new phenomenon, digital media. The current opinion on 'rights' will have to change in order to get software and information industrie really productive and continues.

    --
    giel.y contains 2 shift/reduce conflicts
  19. TEST before your POST by multipartmixed · · Score: 2, Informative

    On most machines of that era, you would overrun I long before the loop completed!

    Sheesh!

    Not to mention the fact that the program won't finish the first loop, as "** GREG WAS HERE **" is not a legal key word in BASIC!

    (Hint - look at the semi colon)

    --

    Do daemons dream of electric sleep()?
  20. Re:It's nice by JonK · · Score: 2, Informative
    Here's what's so great - consider:

    printf("%9d%23s%6.2f", int, str, float);

    which will, as you'd expect, print out an integer, a string and a number. Now, what happens when I type (by mistake) this:

    printf("%9d%23s%6.2f", str, int, float);

    The compiler's quite happy with it, isn't it. So, how about:

    printf("%9d%23s%6.2f", float);

    Again, the compiler's quite happy with it. So, that should be lesson #1: the compiler can't help you with printf() format strings. Instead you're on your own - better make sure you got them right. It becomes even more fun when the format string's being constructed elsewhere and then passed to you - better make sure that you and the guy who's coding the format string builder are singing from the same hymn sheet, 'cos otherwise it'll get messy.

    Secondly, what's the format specifier for a complex number?

    printf("%9d + %9di", myComplex.real, myComplex.imaginary);

    Not very pretty, is it? How about a matrix?

    Because you've overloaded operator << appropriately for your custom types, your types can behave the same way as the native C++ ones - this was, and is, one of BS's drivers for the C++ type system. printf() gives none of these guarantees, and imposes a whole heap of extra work on you - plus it's got this artificial model where emitting output to a file is different from emitting it to a buffer is different to emitting it to screen (yes, I know that the last one's not entirely true, but you get the idea). Then you get a second set of printf() functions to handle wide characters, such as you'd find in Unicode, or the MBCS encodings.

    Oh, and why are you using nine lines of couts - you can chain streams (operator << should always return a reference to a stream) so you get, instead of your example above:

    cout << setw(9) << myInt << myString.substr(0, 23) << setprecision() << setwidth() << myFloat;

    or even:

    cout << setw(9) << myInt << setw(23) << myString << setprecision(2) << setw(6) << myFloat;

    Take-home message: wake up in class and start thinking the C++ way - it's not C, and it's not Java either. It's a completely different language - it just so happens that most C programs are valid C++ programs too, and you can use C++ as a Better C, but you're missing out on all the fun...

    --
    Cheers

    Jon
  21. Re:It's nice by z01d · · Score: 2, Informative

    id like for someone to tell me what is just so great about cout (and its similar classes)

    by using cout, you can write the operator<<() for you own class, so the code looks a little bit more elegant than use printf():

    cout << instance;

    printf ("%s", instance.toString());

    and cout can prevent novice programmer to write printf (str); which may leads to unpredictable result.

    further more, cout is a instance of ostream, which means you can take the advantage of so called "polymorphism":

    ClassName::dumpTo (ostream &os);

    you can pass the cout as the parameter, you can use a ofstream too. well, i know you can use fprintf to do the job in C-style. but by write your own class which inherited from ostream, you can dumpTo socket/database/screen...you got the point.