Slashdot Mirror


How Mainstream Can Code Scavenging Go?

The time-honored tradition of code scavanging has long been a way for new programmers to "break in" to a new language or task that they may not want to build from the ground up. The re-use of old code, cleaned up and tweaked to a new purpose can help developers learn many useful skills and accomplish tasks quickly, especially for small tasks that aren't of vital importance. One blogger wondered if this process could be formalized and tools could be built to help foster and enable code scavanging on a mass level. Is this a viable option, or are there just too many things to consider?

32 of 139 comments (clear)

  1. IP Laws? by gambit3 · · Score: 3, Interesting

    So, how quickly would you run afoul of Intellectual Property laws doing this?

    1. Re:IP Laws? by thegrassyknowl · · Score: 2, Funny

      I want to be the first to welcome our new GPL overlord to the commercial software world.

      --
      I drink to make other people interesting!
    2. Re:IP Laws? by caffeinemessiah · · Score: 5, Insightful

      So, how quickly would you run afoul of Intellectual Property laws doing this?

      That's a great knee-jerk reaction. Without understanding the motivation behind the article, you assume that code scavenging means stealing other people's code. What they're really talking about is (legitimately) re-visiting code that you or other people have written, and then picking and modularizing bite-sized chunks. In other words, you would design a large program (mark I) and then go back and pick out useful parts, clean/debug them and have working modules (mark II) for the next project.

      Also, for people who haven't read TFA, it's 9 short paragraphs long and barely an article. They talk about a "formal approach to code scavenging" without even coming close to explaining what exactly that MEANS.

      --
      An old-timer with old-timey ideas.
    3. Re:IP Laws? by sootman · · Score: 5, Interesting
      They talk about a "formal approach to code scavenging" without even coming close to explaining what exactly that MEANS.

      Agreed. Reading TFS, I thought it was going to be yet another "we can make programming like Lego!" thing. (Which it ain't, and probably never will be. Bonus reference: "Lego" is mentioned in the second paragraph of this article about Steve Jobs/NeXT/WebObjects from Wired. God bless Wired and their eternally fucked-up CMS that can't serve images for any story in the archive and, this week, shows the actual HTML code that should be formatting the Question-and-Answer portion of the article.)

      Reading TFA, I really don't know much more than I did before. This is the best I could come up with:

      Code scavenging is seen as the most frequent and least complex way of re-using code and has been common practice at an informal level since programming first began. Programming is difficult to teach and most programmers learn their chops by looking at working code and using it as the basis for building their own programs. In other words, they "scavenge" the good bits and tweak them to a new purpose.

      The term scavenging appears to have first surfaced as a formal concept in a 1992 paper by Charles Krueger of Carnegie Mellon University. It was tested by academics in the 1990s but rejected because it yielded few gains for a lot of effort.

      According to Hackett, code scavenging is worth re-visiting because the Web makes it easier to find code and re-use it. He points to sites where massive amounts of existing code are available for potential scavenging such as Google code search, Sourceforge, Code Project, Microsoft's Codeplex, and O'Reilly's Code Search. Others include the Free Software Foundation (FSF), FreeVBcode.com, Freecountry and Freshmeat.

      So, code scavenging is... um, re-use? Can anyone make better sense of that than I can?

      "In other words, they 'scavenge' the good bits and tweak them to a new purpose."

      Um, no. You scavenge the pieces you need, not necessarily the good bits. Have you ever been looking for some code to do parse phone numbers, and while looking at source, said "Hey! This looks like a great way to compare two lists!" Probably not. You're only looking for formatting code, so that's all you see, so that's all you get. Looking at source is not like looking at produce at the food store, where you can walk by the tomatoes and they catch your eye because they're perfectly ripe and really, really nice-looking.

      Rather than searching Google, I think every good programmer should take the time to create a really good library. I don't mean take the time writing great code, I mean take the time to organize it into a proper library: make one, clean, well-commented version; put things into variables, ($tableName in queries instead of the actual table name, etc.) and pull code from that when you need it, rather than just copying-and-pasting from the last place you remember using it and then changing all the variable names, table names, etc.

      I plan to make mine Real Soon Now. :-)

      >> So, how quickly would you run afoul of Intellectual Property laws doing this?

      > That's a great knee-jerk reaction.


      No, that's just the first thing that popped into his head. (Pardon me if I'm putting words in your mouth, Mr. Gambit.) With that one sentence, he did not say (or imply) "The only people who would use this are thieves." He just put out that question for people to discuss. That topic came up here just a couple days ago. I highly recommend reading that discussion. There are some very good points; among them, that if you publish something with no licensing info, it is copyrighted to you by default. (In the US at least,

      --
      Dear Slashdot: next time you want to mess with the site, add a rich-text editor for comments.
    4. Re:IP Laws? by alex4u2nv · · Score: 3, Insightful

      These are the ideas that CPAN, PEAR and other code repositories are built on. So instead of trying to reinvent the idea, the author should have poked around a little more, and to learn more about what is available as opposed to trying formalize a "hackup job."

      The parent makes a good point here, where you should take the time to build a clean library base to work with. If one should have a well structured infrastructure, and should they need to implement a certain feature, more often is the case, that a generic library to facilitate the need already exists. If it's open source you're in luck, if it's commercial, you could license it. For example, take a peak into the game industry. A lot of those engines libraries are licensed out to many companies.

      Now I will assume 'bits and pieces' is nothing more than 1 class, or a function. So, If one should be looking for bits and pieces of codes, as a developer you should be able to develop at least that much.

      "Hackett makes some good points, but can scavenging for scraps really turn you into a master programmer, and is it possible - or even desirable - to institutionalize this "make-do" approach?...," TFA

      The short answer is No.
      This sort of programming will not make you a master programmer, it will make you a master scavenger.

    5. Re:IP Laws? by jc42 · · Score: 2, Funny

      [I]f you publish something with no licensing info, it is copyrighted to you by default. (In the US at least, and many other countries as well.) So even if you're looking at a site that is, say, clearly marked as a tutorial, that doesn't necessarily mean that you can use that code, unless the guy comes out and says the code is public domain/GPL/etc.

      Good point. I think I'll use it the next time someone comments about code of mine that is overly complex and convoluted.

      "You see, all the simple ways of doing it have been published in tutorials. This means that they're copyrighted by the author. If I used simple code, I'd almost certainly be violating some author's copyright, and since you hired me to write the code, they'd probably sue both of us. Wouldn't want that, would we?"

      (Only half-joking here. This is what the world's coming to. ;-)

      --
      Those who do study history are doomed to stand helplessly by while everyone else repeats it.
  2. I've been thinking of scavenging code from SCO... by kclittle · · Score: 4, Funny

    ...since they obviously aren't going to be using it for much longer...

    --
    Generally, bash is superior to python in those environments where python is not installed.
  3. Vernor Vinge by boster · · Score: 4, Interesting

    In A Deepness in the Sky, Vernor Vinge posited Programmer Archaeologists would replace all new development. http://everything2.com/index.pl?node_id=760521

    --
    Madness takes its toll. Exact change please.
    1. Re:Vernor Vinge by bcharr2 · · Score: 5, Insightful

      Code is basically an algorithm that solves a computational problem. So yes, you can cut and paste algorithms. If you want your application to be maintainable, however, you also have to solve the larger architectural problems, which is something you DON'T get when you cut and paste code.

      It is one of the most misunderstood concepts about programming. A programmer fresh out of college knows how to write algorithms really well, but has no idea that there are architectural and design land mines waiting for them just down the development road.

      Too many development shops will get an app "working" and think that is all there is to development, because no one has the depth of experience to look a year down the road and see that they will need to rewrite the entire app from scratch in order to make the simplest of changes.

      I'm sorry, but if your program is not extensible nor maintainable then you really haven't "succeeded" at anything. You've simply fooled yourself into thinking the process is simpler than it is while screwing your clients out of their development dollars.

    2. Re:Vernor Vinge by Alphager · · Score: 2, Insightful

      The method of assigning homework is to give 3 lines on what a program needs to do. For example, write an FTP client that you can use to download a file. The method of grading is if you can download a file or not. The decision on how to get the HW done with the least amount of time spent is an architectural challenge.

      Which is what the parent hates: people who only think about getting the product out of the door and who sacrifice things like maintainability.

      Even firefox and Mozilla did a few complete rewrites of the various parts. Rewrites are part of programming unfortunately. The nice thing about rewrites is that the programmers now have experience on how to do things better and are able to better compartmentalize the code. I wouldn't say rewrites are terrible things - though they do annoy management and people above to no end.

      Firefox & Mozilla are prime examples of bad codebases. We all know the disaster that was the last rewrite in-house at Netscape.
      _SOME_ re-writes are necesary and usefull, but a company where the usual way to add a new feature is a re-write of the whole software is doing somethign wrong.
  4. code repositories by drfrog · · Score: 2, Informative

    like cpan and ruby gems etc

    we scavenge code online w/e, find it needs to be used by a lot of people

    so we inherit the scavenged and put it in a nice module and tada!

    this is nothing new

    --
    back in the day we didnt have no old school
  5. semi-formalized by mycall · · Score: 5, Informative

    Some people are already doing this, such as koders, code fetch, codase, and snippets. Talk to them for formalizing as I'm sure they have some good input.

  6. It's called a "subroutine library" by Animats · · Score: 4, Funny

    The Web 2.0 crowd rediscovers subroutine libraries. Film at 11.

    1. Re:It's called a "subroutine library" by visualight · · Score: 2, Funny

      The poster you replied to is thinking the "lots-o-books" kind (I'm sure). As in, "a library of subroutines".

      --
      Samsung took back my unlocked bootloader because Google wants me to rent movies. They're both evil.
    2. Re:It's called a "subroutine library" by Tablizer · · Score: 2, Funny

      The Web 2.0 crowd rediscovers subroutine libraries. Film at 11.

      You gotta punch it up, PHB-ify it: "Reusable Enabling Action-Oriented Web Object Architecture Patterns".

    3. Re:It's called a "subroutine library" by Comatose51 · · Score: 2, Funny
      You joke but I've phone interviewed someone and asked him, "What are some ways of reusing code or implementation?" Inheritance or composition would have been okay. In fact, a lot of answers are acceptable.

      Instead, he answered "uh... cut and paste?"

      --
      EvilCON - Made Famous by /.
  7. Google Code by TooMuchToDo · · Score: 2, Informative
    1. Re:Google Code by daveb · · Score: 4, Informative

      for code scavenging try this instead / as-well
      http://www.google.com/codesearch

  8. foreheat meet desk by Yath · · Score: 4, Funny

    I guess this is slow news day. Using bits of code without writing everything from scratch - how novel! How controversial! Is there anyone who doesn't do this? What kind of skull-shattering boredom do you have to endure before you start writing blog entries about this?

    And the first article suggests that trusting the code is an issue, because you didn't write it. Well let's see - it's short, and you just pasted it into your program. But you're not going to bother to read it? You fail. Seriously.

    --
    I always mod up spelling trolls.
  9. Isn't this a library? by poppycock · · Score: 3, Funny

    Isn't this, you know, a library?

  10. "Scavanging"? by Anonymous Coward · · Score: 2, Funny

    Why don't you scavenge the dictionary to spell properly?

  11. Unlikely? by SnoopJeDi · · Score: 3, Interesting
    From TFA:

    You are unlikely to find what you want with a simple Web search


    Since..when? Recently I've picked up perl again, and I've found more than what I need to scavenge to make my own personal extensions to blosxom through google searches.

    I mean, granted, it depends on your definition of a bite-size task, but it's a blanket statement no matter which way you spin it.
  12. This is a great idea! by AEton · · Score: 3, Funny

    If only there were some computer programming language that had built-in support for some kind of a Comprehensive Archive Network, that would be the best.

    Maybe the C++ language could do it. Then you could just ... hmm ... "import" the things you need from the Comprehensive C++ Archive Network!

    Hmm, CC++AN sounds pretty dumb. It'd never catch on. Oh well.

    --
    We recently had heard in the office over one of the Yellow Machine that's made by Anthology Solutions.
  13. Today Slashdot jumped the shark. by xxxJonBoyxxx · · Score: 2, Funny

    Today Slashdot jumped the shark.

    Seriously. I'm starting to lose brain cells when I read the "articles" these days.

  14. Re:scavanging turds is mainstream by YrWrstNtmr · · Score: 4, Funny

    That sir, was a work of beauty. There should moderation other than -1 Troll for such art.

    Indeed...we need a -5 Asshole.

  15. It's already been done. by etnu · · Score: 2, Funny

    It's called Google.

  16. Wow by smitth1276 · · Score: 5, Funny

    That article used a lot of words to say absolutely nothing. But it got me thinking... perhaps we could group related snippets of code into units called "libraries", and then we could easily use those libraries to perform common tasks?

  17. The reuse of old code... by adamkennedy · · Score: 2, Informative

    So... the formalised use of old code... you mean like CPAN?

  18. Re:Don't we call that "refactoring"? by Anonymous Coward · · Score: 5, Funny

    TFA is not really a FA.


    It leaves us only "the". Which is an article. Liar.
  19. This reminds me of another book ... by James+Youngman · · Score: 2, Interesting

    ... of an SF book I read a few years ago, where all programs were written by a process of digging into 10,000 years' worth of computer programs in a sort of archaeological way, pulling out something that did more or less what you want and amalgamating it with what you had so far. I thought at first that it was a Vernor Vinge book, but checking the plot summaries on wikipedia, it looks like it was somebody else. Can anybody remember the book I'm thinking of?

  20. oops by yoprst · · Score: 2, Funny

    Apparently, slashdot has already scavenged angle brackets - they're gone. Truly the most scavenged code ever.