Beta

Slashdot: News for Nerds

×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

How Mainstream Can Code Scavenging Go?

ScuttleMonkey posted more than 6 years ago | from the unwanted-easter-eggs dept.

Programming 139

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?

cancel ×

139 comments

scavanging turds is mainstream (-1, Troll)

Anonymous Coward | more than 6 years ago | (#21541571)

A few years ago, while browsing around the library downtown, I
had to take a piss. As I entered the john a big beautiful all-American
football hero type, about twenty-five, came out of one of the booths.
I stood at the urinal looking at him out of the corner of my eye as he
washed his hands. He didn't once look at me. He was "straight" and
married - and in any case I was sure I wouldn't have a chance with
him.

As soon as he left I darted into the booth he'd vacated,
hoping there might be a lingering smell of shit and even a seat still
warm from his sturdy young ass. I found not only the smell but the
shit itself. He'd forgotten to flush. And what a treasure he had left
behind. Three or four beautiful specimens floated in the bowl. It
apparently had been a fairly dry, constipated shit, for all were fat,
stiff, and ruggedly textured. The real prize was a great feast of turd
- a nine inch gastrointestinal triumph as thick as a man's wrist.

I knelt before the bowl, inhaling the rich brown fragrance and
wondered if I should obey the impulse building up inside me. I'd
always been a heavy rimmer and had lapped up more than one little
clump of shit, but that had been just an inevitable part of eating ass
and not an end in itself. Of course I'd had jerk-off fantasies of
devouring great loads of it (what rimmer hasn't), but I had never done
it. Now, here I was, confronted with the most beautiful five-pound
turd I'd ever feasted my eyes on, a sausage fit to star in any fantasy
and one I knew to have been hatched from the asshole of the world's
handsomest young stud.

Why not? I plucked it from the bowl, holding it with both
hands to keep it from breaking. I lifted it to my nose. It smelled
like rich, ripe limburger (horrid, but thrilling), yet had the
consistency of cheddar. What is cheese anyway but milk turning to shit
without the benefit of a digestive tract?

I gave it a lick and found that it tasted better then it
smelled. I've found since then that shit nearly almost does.

I hesitated no longer. I shoved the fucking thing as far into
my mouth as I could get it and sucked on it like a big brown cock,
beating my meat like a madman. I wanted to completely engulf it and
bit off a large chunk, flooding my mouth with the intense, bittersweet
flavor. To my delight I found that while the water in the bowl had
chilled the outside of the turd, it was still warm inside. As I chewed
I discovered that it was filled with hard little bits of something I
soon identified as peanuts. He hadn't chewed them carefully and they'd
passed through his body virtually unchanged. I ate it greedily,
sending lump after peanutty lump sliding scratchily down my throat. My
only regret was the donor of this feast wasn't there to wash it down
with his piss.

I soon reached a terrific climax. I caught my cum in the
cupped palm of my hand and drank it down. Believe me, there is no more
delightful combination of flavors than the hot sweetness of cum with
the rich bitterness of shit.

Afterwards I was sorry that I hadn't made it last longer. But
then I realized that I still had a lot of fun in store for me. There
was still a clutch of virile turds left in the bowl. I tenderly fished
them out, rolled them into my handkerchief, and stashed them in my
briefcase. In the week to come I found all kinds of ways to eat the
shit without bolting it right down. Once eaten it's gone forever
unless you want to filch it third hand out of your own asshole. Not an
unreasonable recourse in moments of desperation or simple boredom.

I stored the turds in the refrigerator when I was not using
them but within a week they were all gone. The last one I held in my
mouth without chewing, letting it slowly dissolve. I had liquid shit
trickling down my throat for nearly four hours. I must have had six
orgasms in the process.

I often think of that lovely young guy dropping solid gold out
of his sweet, pink asshole every day, never knowing what joy it could,
and at least once did, bring to a grateful shiteater.

Re:scavanging turds is mainstream (-1, Offtopic)

Anonymous Coward | more than 6 years ago | (#21541593)

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

Re:scavanging turds is mainstream (4, Funny)

YrWrstNtmr (564987) | more than 6 years ago | (#21541839)

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

Indeed...we need a -5 Asshole.

IP Laws? (3, Interesting)

gambit3 (463693) | more than 6 years ago | (#21541585)

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

Re:IP Laws? (2, Funny)

thegrassyknowl (762218) | more than 6 years ago | (#21541591)

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

Re:IP Laws? (5, Insightful)

caffeinemessiah (918089) | more than 6 years ago | (#21541613)

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.

Don't we call that "refactoring"? (1)

khasim (1285) | more than 6 years ago | (#21541647)

You write program A ... eventually you refactor it and turn parts of it into cleaner modules.

You can then use those modules in other programs.

Re:Don't we call that "refactoring"? (1)

caffeinemessiah (918089) | more than 6 years ago | (#21541719)

You write program A ... eventually you refactor it and turn parts of it into cleaner modules. You can then use those modules in other programs.

short answer: yes. and even before "refactoring" came into vogue, there were other names for it. hence, TFA is not really a FA.

Re:Don't we call that "refactoring"? (5, Funny)

Anonymous Coward | more than 6 years ago | (#21542707)

TFA is not really a FA.


It leaves us only "the". Which is an article. Liar.

Re:Don't we call that "refactoring"? (1, Interesting)

Anonymous Coward | more than 6 years ago | (#21542161)

well it's not that bad an idea. In my job I often have to come up with one-off shell scripts and whatnot. I have thought many times "this must have been done before, why am I doing it again"? The problem I have is, where does one look?

I google and look through various scripts and stuff on linux boxes and can piece stuff together but by the time I do that I might as well have just written it. Often times I do after giving up. To have a place to pick through, even just for ideas, is not a bad thing at all. For the record I am an admin but not a programmer.

Re:IP Laws? (5, Interesting)

sootman (158191) | more than 6 years ago | (#21541785)

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. [joelonsoftware.com] Bonus reference: "Lego" is mentioned in the second paragraph of this article [wired.com] 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. [slashdot.org] 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, 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.

Re:IP Laws? (1)

tuomoks (246421) | more than 6 years ago | (#21542123)

A good comment! And the IP part is important, you just can't take any code you see, you can read it and code the solution yourself in most cases but there are some darn patent issues - stupid laws patenting algorithms !
Another good point in comment "every good programmer should take the time to create a really good library" And this should go without saying, build your own library of templates and snippets you carry as long as you do coding, often saves a lot of time. Some companies which use SM/CM ( source/configuration management ) have ready made / canned templates, snippets, etc already bound to editors, IDEs, and so on. Unfortunately very few.
Just don't get too hooked to those, some day you are in environment where the only tools are notepad or vi and a compiler, how to start now? And usually in those systems all the help files, man pages, etc are nonexistent.
Also, be careful, code may be written to specific platform, OS, compiler, etc. I'm tired of fixing for example code written to PPC when compiling for x86 or 32 bit code going to 64. Did you think all systems have bytes in same order? Did you think all compilers and systems align same way? Did you think that all systems let you manipulate the stack? Did you think they are on same POSIX level? Did you think that objects with same names are equal? Well, you were wrong. Especially some Unix developers with fast cut and paste fingers have created millions of lines such code ( just my experience, sorry )
Another ( one of many ) issue, did the original code writer think security? Ouch - all the string functions, etc. Yes, even if the code comes from experienced developers and (currently) well behaving systems does not guarantee that it will work for you.
All that said, old code is a great source to learn especially if you are new and you have someone to explain it.

Re:IP Laws? (4, Insightful)

alex4u2nv (869827) | more than 6 years ago | (#21543867)

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.

END MODERATOR ABUSE (-1, Offtopic)

Anonymous Coward | more than 6 years ago | (#21542003)

I have again been the victim of moderator abuse http://slashdot.org/comments.pl?sid=366293&cid=21424075 [slashdot.org] [slashdot.org] [slashdot.org] MOD me up to correct this injustice.

Too many moderators use Insightful as "I agree". Too many moderators fall for unoriginal groupthink and mod it up. People complain about trolls, but the REAL line noise on slashdot comes from the posts modded +4 or +5 that contribute NOTHING to an intelligent discussion. You can't filter that out, and even if you have your thresholds set high, you still see all the stupid stuff that you've already seen. That's why digg sucks and will never be anything but a place for 1338 high-skool haxx0rs. And it's happening here. So I used this account to call shenanigans on sucky posts. I getted modded into oblivion for pointing out truth. I guess that's how it goes. Most of you are a bunch of mindless sheeple.

One way to fix this: I think Slashdot should give IQ tests to all would-be moderators. That would ensure most of the ramshackle pseudo-intellectuals who get mod points would be replaced by people who can actually read the moderator guidelines and adhere to them.

If someone wants to debate this intelligently, then post something meaningful in reply. Chiding me for "whining" won't get you anywhere. I thought the /. community was supposed to be smart?

Re:END MODERATOR ABUSE (0)

Anonymous Coward | more than 6 years ago | (#21542489)

Just do what I do: M2 frequently. And fairly. And by that I mean, if I don't see any insight in a comment that's modded Insightful, it gets metamodded Unfair. Etc. If it happens more than a few times to someone, they lose their mod privs.

Re:END MODERATOR ABUSE (1)

jericho4.0 (565125) | more than 6 years ago | (#21542943)

Get. A. Life.

Re:END MODERATOR ABUSE (0)

Anonymous Coward | more than 6 years ago | (#21543539)

I see that you have learned to post anonymously when you are about to be a douche. Congratulations, that is a bit of progress. Now all you have to do is refrain from being a douche while logged in long enough to get mod points of your own (it takes about 6 months) and you can start instituting your high standards of intellect on our moderation... except looking at your posting history (if you are Taco Meat), you really are a douche.

Re:IP Laws? (1)

iminplaya (723125) | more than 6 years ago | (#21542155)

...stealing other people's code.

Another great knee-jerk reaction. Since a revealed idea cannot rightfully be "owned" or controlled in any way by anyone. "Stealing" is a misnomer designed to incite more knee-jerk reactions to keep bad law on the books. Unfortunately it still works on a gullible public.

My reaction was different (1)

einhverfr (238914) | more than 6 years ago | (#21542177)

I think that in some rare cases, code scavenging is helpful. However, in most cases, it does not lead to solidly engineered software. Basically you get a piece of code, review your code, analyze the interface, prefactor, debug, postfactor, and now it is working well. By that time, you could have written a rough draft, debugged, and postfactored in less time and gotten a more consistent codebase out of it.

So I am not sure at all to what extent this code scavenging is sufficiently helpful to make formalize the process.

Re:My reaction was different (1)

chriseyre2000 (603088) | more than 6 years ago | (#21543279)

Unless the intent is to solve the problem in the same way as the (probably) undocumented code. This is quite often the case where the new application must do everything the old one does plus the following new requirements...

Re:IP Laws? (1)

d34thm0nk3y (653414) | more than 6 years ago | (#21542421)

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.

Exactly! You can visualize these modular chunks of code as actual objects actually. Each object could have a series of methods that you could manipulate to make it do things. I call this theory manipulation orientated programming (or MOP) and am filing for the patent presently. Prepare to hear from my laywer.

Re:IP Laws? (1)

ozone_sniffer (778249) | more than 6 years ago | (#21543615)

If that large program (mark I) wasn't built on top of a library (or somethin'), which in turn was designed for reuse, you'll get in trouble trying to reuse that code. Either: 1. You refactor the large program to reach that structure, or; 2. You start the new one from scratch. Scavenging is scavenging, be it code or corpses, and is a lowly thing to do no matter what. You want tools for that? Go grab some cutlasses and shovels, they've been around for quite some time.

Re:IP Laws? (1)

ILuvRamen (1026668) | more than 6 years ago | (#21541851)

in the case of visual basic for example, Microsoft made almost all the functions and objects used so you can't do some little code snippet using them and say somehow now you own it. That's like a company making cars and they sell one to you and you patent demolition derbies because you discovered a new thing to do with their tools. Now big, long programs or large, specialized modules that would have the same structure in any language and actually represent some logical idea that someone created are a different story. But if I go to vbforums.com and ask a good way to do something and someone shows me 20 lines for it and I use it, nobody should be complaining about me stealing someone's code. Yet, if I steal a DLL and use it for myself so I don't have to write any of it, that's different.
Now that that's established, to answer the final question posed on the summary, it's caleld the MSDN library and it failed miserably. Its main purpose isn't this, but it does in fact strive to have a realistic example of how every function and object would be used...and it's gigabytes of un-navigateable garbage that doesn't tell you anything 95% of the time.

Re:IP Laws? (1)

cromar (1103585) | more than 6 years ago | (#21542389)

Dude... your example of derby demolition is a really good one. That appeals to a lot of people because everyone knows what it is. (A good car analogy on Slashdot?!!) WWE! :) (And I honestly mean that with all sincerity!)

P.S. MSDN docs do often suck... luckily their IDE and Google results are OK.

P.P.S. A fi bun mi sensi.

Re:IP Laws? (1)

RobBebop (947356) | more than 6 years ago | (#21542107)

Some code cannot be copyrighted. HTML, for instance, cannot be locked away and hidden in a vault because it relies on being there so the browser can render it at the time of the download. Those, HTML is a great "scavenger" language, because it is easy to learn new techniques by poking around the "View Source" code.

Other code that cannot be copyrighted is copylefted. The GPL expressly guarantees that code can be used, studied, modified, and redistributed.

Now... formalizing a lesson plan to teach students of computer science the ins-and-outs of GPL code would be a wonderful thing. I would graciously sign up for that course.

Re:IP Laws? (1)

Dogtanian (588974) | more than 6 years ago | (#21543331)

Some code cannot be copyrighted. HTML, for instance, cannot be locked away and hidden in a vault because it relies on being there so the browser can render it at the time of the download.
Just because you can easily view it doesn't mean that it's not copyrighted. What on earth made you think otherwise?!

Realistically, of course, there's the question of how far you can copyright many (small) HTML fragments and techniques anyway, but that's not the point you were making.

Re:IP Laws? (1)

cromar (1103585) | more than 6 years ago | (#21542363)

I, for one, .... always check the licence of snippets I use :)

Re:IP Laws? (1)

mollymoo (202721) | more than 6 years ago | (#21543715)

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

You're highly unlikely to run afoul of trademark laws and absolutely guaranteed to run afoul of patent law in the US, or virtually guaranteed not run afoul of patent law elsewhere. So you must have meant copyright. Why didn't you just say copyright? Lumping copyrights, patents and trademarks together is futile for most purposes and calling them "property" is dangerously misleading.

I've been thinking of scavenging code from SCO... (4, Funny)

kclittle (625128) | more than 6 years ago | (#21541607)

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

In other news (1)

irtza (893217) | more than 6 years ago | (#21543251)

SCO recently announced a 3 trillion dollar law suit against the owner of the kclittle slashdot ID. When asked about the dollar amount, they said that the "three billion" number lost its glamor and is no longer taken seriously.

Vernor Vinge (4, Interesting)

boster (124383) | more than 6 years ago | (#21541615)

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

Re:Vernor Vinge (1)

Penguinisto (415985) | more than 6 years ago | (#21542047)

Not like it took deep thought to arrive at that conclusion - a look at the nearest sysadmin (myself just as guilty) and the wee habit of script-scavenging is sufficient to serve as a parallel.

/P

Re:Vernor Vinge (5, Insightful)

bcharr2 (1046322) | more than 6 years ago | (#21542189)

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.

Re:Vernor Vinge (1)

mochan_s (536939) | more than 6 years ago | (#21542947)

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.

I think you're wrong here.

In college, a lot of architectural designs have to be made and made quick. OK, they are for small projects but still those designs have to be made. Plus, you have the luxury of seeing what other people designed and how it worked out.

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.

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.

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.

Re:Vernor Vinge (2, Insightful)

Alphager (957739) | more than 6 years ago | (#21543035)

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.

Re:Vernor Vinge (1)

d34thm0nk3y (653414) | more than 6 years ago | (#21542427)

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

Thanks, I already know Python.

code repositories (2, Informative)

drfrog (145882) | more than 6 years ago | (#21541639)

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

semi-formalized (5, Informative)

mycall (802802) | more than 6 years ago | (#21541675)

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

Re:semi-formalized (1)

Peter Cooper (660482) | more than 6 years ago | (#21542063)

One of the good things about Snippets in particular is the taggability.. kinda like searching for stuff in del.icio.us. So.. I can just kinda guess some URLs and know I'll get something relevant (I hope!)

http://snippets.dzone.com/tags/ruby [dzone.com]
http://snippets.dzone.com/tags/ruby/http [dzone.com]
http://snippets.dzone.com/tags/python/windows [dzone.com]
http://snippets.dzone.com/tags/rebol [dzone.com]

And so on..

It's called a "subroutine library" (4, Funny)

Animats (122034) | more than 6 years ago | (#21541677)

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

Re:It's called a "subroutine library" (1)

calebt3 (1098475) | more than 6 years ago | (#21541711)

I don't even know how too code and I was thinking "library".
And to preempt those that like to pun: I mean the "DLL" kind. Not the "lots-o-books" kind.

Re:It's called a "subroutine library" (2, Funny)

visualight (468005) | more than 6 years ago | (#21541953)

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

Re:It's called a "subroutine library" (1, Insightful)

Anonymous Coward | more than 6 years ago | (#21542037)

Seriously though: welcome to CPAN.

Re:It's called a "subroutine library" (1)

Tablizer (95088) | more than 6 years ago | (#21542169)

Seriously though: welcome to CPAN.

When I was an intern for the US Geological Survey in the late 80's, they had pretty big FORTRAN libraries for graphing, charting, mapping, reporting, math, you name it. Being before open-source took off, they were expensive though.
     

Re:It's called a "subroutine library" (2, Funny)

Tablizer (95088) | more than 6 years ago | (#21542153)

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".
   

Re:It's called a "subroutine library" (2, Funny)

Comatose51 (687974) | more than 6 years ago | (#21542311)

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?"

Re:It's called a "subroutine library" (1)

joss (1346) | more than 6 years ago | (#21543177)

I don't think of inheritance and composition as *reusing* code,
thats more just *using* it afaiac so I guess I would have been
stumped by that question too. Lisp can double as knitting patterns
and I guess perl can be a decent approximation to line noise, python
can sometimes be read as intensely obscure haikus but its all a bit
of a stretch.

Re:It's called a "subroutine library" (1)

rah1420 (234198) | more than 6 years ago | (#21543483)

I would have hired him. These young whippersnapper programmers thinking that they are all that. What's wrong with 3GLs anyway?

At the end of the day, it's all ones and zeros.

Re:It's called a "subroutine library" (1)

j_l_cgull (129101) | more than 6 years ago | (#21542709)

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


Wasn't that WebServices and XML [kuro5hin.org] ?!

Re:It's called a "subroutine library" (0)

Anonymous Coward | more than 6 years ago | (#21543381)

I'm not very old, but in the old days ... 1990, we used to pay other companies for reusable code. They called them "Libraries" and came with unlimited redistribution of runtime licenses for no additional charge. Of course, it was easier then because any serious development team only shipped object code (.o, .a, .so, .dll) files with interface files (.h) - you know, header files? http://snippets.snippets.org/index.php [snippets.org]

Script-based languages make this just slightly less useful ... to the library vendor. OTOH, I had to use fidonet to find a copy of the C/C++ snippets all those years ago. The internet/google made that a trivial exercise this morning. Perl code has this. It is called a module - http://search.cpan.org/ [cpan.org]
    I suspect Java, PHP, Python, Ruby all have repositories of reusable code too. Google is your friend, but check the license and be certain your project/company can live with whatever restriction the author chose to use. Generally, I use the v2 LGPL for non-work stuff, myself. For non-core work stuff, BSD license is preferred provided the company doesn't keep it all as a "trade secret". I don't have problems with trade secrets, where they make sense. Company owners tend to want to protect everything for some reason.

Google Code (2, Informative)

TooMuchToDo (882796) | more than 6 years ago | (#21541689)

Re:Google Code (4, Informative)

daveb (4522) | more than 6 years ago | (#21541999)

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

foreheat meet desk (4, Funny)

Yath (6378) | more than 6 years ago | (#21541701)

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.

Re:foreheat meet desk (1)

jgrahn (181062) | more than 6 years ago | (#21542303)

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?

It might be a new idea for more people than you think. There is this ideal picture of people writing The Perfect Software from scratch, isolated from the rest of the world. And there is the other ideal, people assembling The Perfect Software from various Java frameworks with catchy names.

It is a good thing that somebody points out that it is OK to just cut-and-paste code; that you don't have to make it a bloody library with the perfect API first.

Re:foreheat meet desk (1)

Splab (574204) | more than 6 years ago | (#21542775)

Is it really?

Don't know about you, but I don't have the legal background to figure out what happens to licenses for the code when you copy and paste others code into your project.

Re:foreheat meet desk (1)

GunFodder (208805) | more than 6 years ago | (#21542379)

You said it. I think they have a name for reusing existing code, it's called "Software Engineering."

NIH is healthy. (0)

Anonymous Coward | more than 6 years ago | (#21541707)

Code reuse has been tried but cowboy programmers and the NIH syndrome strike every time. Besides algorithm reuse would be a better path to take.

Isn't this a library? (3, Funny)

poppycock (231161) | more than 6 years ago | (#21541721)

Isn't this, you know, a library?

"Scavanging"? (2, Funny)

Anonymous Coward | more than 6 years ago | (#21541739)

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

Unlikely? (3, Interesting)

SnoopJeDi (859765) | more than 6 years ago | (#21541747)

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 [blosxom.com] 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.

Eh? (1)

Angst Badger (8636) | more than 6 years ago | (#21541767)

Isn't that basically the point of a linkable library?

This is a great idea! (3, Funny)

AEton (654737) | more than 6 years ago | (#21541813)

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.

Re:This is a great idea! (1)

Penguinisto (415985) | more than 6 years ago | (#21542053)

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

Oh, c'mon! It has one potential use - It sounds like a munged pr0n version of something for Perl [cpan.org] . That alone would make the effort worth it, no?

/P

Re:This is a great idea! (1)

CTalkobt (81900) | more than 6 years ago | (#21542383)

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

Or alternativly, you could call it CCPPAN... but that sounds too much like the perl CPAN besides the fact that you'd have turret's jokes about it....

Today Slashdot jumped the shark. (2, Funny)

xxxJonBoyxxx (565205) | more than 6 years ago | (#21541831)

Today Slashdot jumped the shark.

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

Re:Today Slashdot jumped the shark. (1)

thatskinnyguy (1129515) | more than 6 years ago | (#21542041)

Really... I mean really... I would have honestly expected less "duh" out of a kdawson article.

Re:Today Slashdot jumped the shark. (0)

Anonymous Coward | more than 6 years ago | (#21542077)

No no no, you know your loosing your brain cells when you can't tell the difference between loose and lose.

Re:Today Slashdot jumped the shark. (1)

Tablizer (95088) | more than 6 years ago | (#21542179)

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

Ahah! Caught you reusing cliches.
     

And the title... (0)

Anonymous Coward | more than 6 years ago | (#21542595)

I think I lost even more braincells trying to grok the title. "How Mainstream Can Code Scavenging Go?". Wow, I thought! Is there a Scavenging version of the japanese game of Go? Can Mainstream ever be able to Code it? And How will they ever manage it? WTF!? What's with the capitalization of almost every word other than a few prepositions? Jeez...

Re:Today Slashdot jumped the shark. (1)

Rocketship Underpant (804162) | more than 6 years ago | (#21543569)

A more interesting story might be how Slashdot "scavenges" yesterday's stories for reposting tomorrow!

It's already been done. (2, Funny)

etnu (957152) | more than 6 years ago | (#21541921)

It's called Google.

Re:It's already been done. (1)

Penguinisto (415985) | more than 6 years ago | (#21542067)

And CPAN [cpan.org] .

(and half a bazillion other projects... Hell, not it's been going on before Microsoft decided they needed a working TCP/IP stack for Windows 2000 or anything...)

/P

A Brand New Idea (1, Funny)

Anonymous Coward | more than 6 years ago | (#21541929)

What a great new idea! Maybe we could put all of the scavenged code into a container and call it a "library". Wiyth brilliant ideas like this software is going to advance by great leaps and bounds. No more reinventing the wheel, or constantly rediscovering ancient ideas.

Wow (5, Funny)

smitth1276 (832902) | more than 6 years ago | (#21542007)

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?

Re:Wow (1)

libkarl2 (1010619) | more than 6 years ago | (#21542831)

Uh, no. We've shifted our focus towards a synergistic paradigmatic model better suited for the theoretical quasi-user experience. I have no idea what that means but the CEO loves it.

Good and Bad (0)

Anonymous Coward | more than 6 years ago | (#21542015)

It's smart to not have to reinvent the wheel unless you're going to do it better. On the other hand, if you just acquire the wheel, you might not actually understand the wheel. The last thing we need is more sloppy coding nevermind the speed it's produced at.

Ah, business versus pleasure (1)

holophrastic (221104) | more than 6 years ago | (#21542091)

It's a funny game, using plucked code. I do agree that when it comes to learning a new language, or learning to program for the first-ish time, nothing's better than stitching together mounds of existing code and watching things emerge.

When it comes to real business requirements, things are a little milky. I own and operate a small business, and there are a few problems with plucking code from the ether. The first is the notion of hiring a programmer to not write their own code. Getting the job done, and doing the job are two very different things. It pretty much hinges on a very simple notion.

I love CPAN, I think it's the greatest resource out there. When I'm looking for a Perl module to do something that I can't do myself, that's where I go, and I've never been disappointed. But I go there expecting a solution that does what it says it'll do. I use it the way it says it wants me to use it. And that's all that I ever expect of it. FTP, PDF, english numbers, whatever.

A while back, I asked one of my programmers to write a routine to dump out a Perl structure. I said I needed it in about a week. Lo and behold, it worked on-time and all was good.

A few months later, I noticed that it wasn't quite working the way that I had wanted it to. I needed a tiny thing adjusted. So I went to my programmer, and told him to make the change. I was greeted with the lovely response of "it can't do that like that". I of course was perplexed. I'm not asking it to do anything. I'm asking my programmer to do something on the clock.

Turns out, as any Perl expert here knows, my programmer simply took the Dump module, which dumps perl structures. I wanted to have the dump be a nice dynamic javascript html table thing, and my programmer told me no -- or rather that it would require him to do it from scratch, and of course now, a month later, we didn't have the time.

Ultimately, my point is that when you control every line of code, you aren't hampered by other people's restrictions. I would have been happy had my programmer written his own dumping code from scratch, but I also would have been happy had he started with the cpan dump code, searned from it, and created a derivative version. Hell, in this case, I'd have been happy if he had studied it to the point where he could have modified it easily.

Instead, I got a quick-'n'-dirty solution that prioritizes time over other benefits. Trouble is, in this case, we had extra time, and no extra benefits.

Re:Ah, business versus pleasure (1)

einhverfr (238914) | more than 6 years ago | (#21542217)

A while back, I asked one of my programmers to write a routine to dump out a Perl structure. I said I needed it in about a week. Lo and behold, it worked on-time and all was good.
What is wrong with Data::Dumper? Or rather did you need something that worked with Data::Dumper?

Turns out, as any Perl expert here knows, my programmer simply took the Dump module, which dumps perl structures. I wanted to have the dump be a nice dynamic javascript html table thing, and my programmer told me no -- or rather that it would require him to do it from scratch, and of course now, a month later, we didn't have the time.
Having done a lot of work with Perl, I would say that Data::Dumper is the wrong thing to use for that. TemplateToolkit, OTOH, would allow you to quite quickly generate HTML based on your data structure. A competent Perl programmer shouldn't require too much time to do that, esp. if it is in a different document.

One more note (1)

einhverfr (238914) | more than 6 years ago | (#21542233)

Ultimately, my point is that when you control every line of code, you aren't hampered by other people's restrictions. I would have been happy had my programmer written his own dumping code from scratch, but I also would have been happy had he started with the cpan dump code, searned from it, and created a derivative version. Hell, in this case, I'd have been happy if he had studied it to the point where he could have modified it easily.
Sadly here is where you are terribly wrong. They key to doing what you want to do is to understand what you want from the beginning, do the requirements analysis up front, etc. and so forth. There is a *huge* difference between dumping a Perl object (the way Data::Dumper does) and creating a nice HTML document from it.

Your programmer, if he was smart, grabbed the CPAN module, wrote a little wrapper around it, and integrated it into your application. If you had known what you wanted up front, he would have done the same with TemplateToolkit. (LedgerSMB uses both so I have experience here!)

Even if your programmer wrote all the code from scratch, adjusting it to output valid HTML tables that Javascript would reliably work on would be more work than just starting over with TT.

Re:Ah, business versus pleasure (1)

usrcpp (1184447) | more than 6 years ago | (#21542249)

How do you not control every line of code when you reuse? Unless you're a code monkey, you'll most probably know how to write something, but just 1) not want to spend 20 minutes thinking about it when you get get it from somewhere in two, or 2) You're getting to grips with the language and so syntax is a bit of an issue. I think the point should really be that code monkeys shouldn't be trusted with writing critical components for the reason you pointed out.

I have found the most scavenged code on earth (2, Funny)

nerdyalien (1182659) | more than 6 years ago | (#21542095)

#include

using namespace std;

int main()
{
          cout "Hello World!";

          return 0;
}

oops (2, Funny)

yoprst (944706) | more than 6 years ago | (#21543077)

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

Microsoft Popfly? (1, Informative)

im_thatoneguy (819432) | more than 6 years ago | (#21542125)

Isn't that what microsoft is trying to do with PopFly?

http://www.popfly.ms/Overview/ [popfly.ms]

Compare to other engineering materials (1)

peacefinder (469349) | more than 6 years ago | (#21542133)

How mainstream are SAE bolts? How mainstream is 18 gage 304 stainless sheetmetal? How mainstream is a CR2016 battery?

Standardized and well-understood components save a vast amount of effort in other engineering fields and help produce results that are more easily verified to be good.

Why not apply the same approach to software engineering? Isn't that the greatest promise of open source?

Re:Compare to other engineering materials (1)

einhverfr (238914) | more than 6 years ago | (#21542239)

That is basically what libraries are, right?

That is very different than taking a bunch of code, stitching it together, and building a system out of it.

Re:Compare to other engineering materials (1)

grumbel (592662) | more than 6 years ago | (#21543219)

### That is basically what libraries are, right?

Not really, libraries are an implementation, not a ISO/ANSI/DIN/whatever standard, so their behavior is defined for most part by implementation, not by specification. So you don't find an independent implementation of GTK or QT or most other stuff, aside from a few libraries that clones other libraries (i.e. lesstif vs motif, Wine, etc.), but even there its not following a defined standard but just cloning things as best as you can.

The only part of programming that follows standards is the core language itself, but those often solve only a very tiny fraction of what you need to write real world programs.

I think that is a huge problem, not only are the standard libraries to small, but they are often also terrible buggy and outdated, i.e. string handling in C is a total garbage, you have function like gets() which will cause buffer/heap overflows no matter what you do, you can't use that function correctly. And the alternatives like fgets() and such are cumbersome to use so that everybody ends up building its own little string library. I think in a day and age where security updates are installed on a weekly basis it would really help a lot to extend the standards a little more often instead of just every ten years, so that often used parts are more easily available and don't have to be reinvented each and every time. This would also help a lot in making libraries more compatible to each other, since you wouldn't need to convert forward and backward between types that are basically identical in their design.

The Title (1)

hpavc (129350) | more than 6 years ago | (#21542299)

The title of this article seems to have been 'code scavenged' ... it makes no sense and wasn't proof read. 'How far can can code scavenging go in the mainstream?' perhaps

indie code scavenging (1)

screamphilling (1173499) | more than 6 years ago | (#21542361)

indie code scavenging, indie code scavenging, indie code scavenging

mod do3n (-1, Troll)

Anonymous Coward | more than 6 years ago | (#21542553)

The reuse of old code... (2, Informative)

adamkennedy (121032) | more than 6 years ago | (#21542573)

So... the formalised use of old code... you mean like CPAN [cpan.org] ?

Objects anyone? (1)

olddotter (638430) | more than 6 years ago | (#21542675)

One of the selling points of object oriented coding was it was supposed to formalize this and make it easier. In theory all objects were to be designed to be generic and reused from day one. In practice it rarely works that way. Especially under tight dead lines and lean development teams.

Re:Objects anyone? (1)

grumbel (592662) | more than 6 years ago | (#21543247)

I don't think this has all that much to do with deadlines and more with objects being just as inflexible as what we did before them, i.e. as soon as an object wants to do anything useful beside very basic stuff it has to interface with some other object and unless you happen to have an object that has that interface you are dead in the water.

Where objects help is in keeping related code together, but that is more syntactic sugar for stuff you would expect in a clean program anyway.

This reminds me of another book ... (2, Interesting)

James Youngman (3732) | more than 6 years ago | (#21543061)

... 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 [wikipedia.org] book, but checking the plot summaries on wikipedia, it looks like it was somebody else. Can anybody remember the book I'm thinking of?

Yay CodeProject (1)

paulxnuke (624084) | more than 6 years ago | (#21543363)

I sympathize with the attitude that one has more "control" by doing everything from scratch, but I don't have the luxury of a huge team or reasonable deadlines. I get burned regularly by using third party code, paid for or not, but given the source code it can usually be made to work, or scrapped early if it clearly won't. One non-developer exec bought us a bunch of code from some third world outfit: we junked it all and rewrote when we realized that would be faster than fixing it.

Everyone I know uses http://codeproject.com/ [codeproject.com] , especially for oddball MFC controls. It's usually necessary to do significant debugging and extending, but you get ready-to-go starter code with most of the skanky MFC issues and gotchas already handled, plus usually a demo project, for less effort than writing from scratch.

One coworker was an advocate of third party ActiveX controls: after one disaster too many I finally ActiveX entirely and we've almost completely replaced what we had. The issue, aside from extreme ugliness and painfulness to use, is that most commercial ActiveX is closed or unusable source, and is at least as incomplete/buggy as CodeProject source code.

search is the problem (1)

fuliginous (1059354) | more than 6 years ago | (#21543503)

like just finding the right application amongst zillions the problem (to something most I'm sure would otherwise consider doing) is finding it.

Yes you might want to save time through such reuse, but first you have to somehow find possibilities and then you have to decide which one of those suits best. And that time consuming process is why so much ends up getting written from scratch so often.

Solving that problem is itself a problem though. At the moment there is such a diversity because of that. Take away the diversity and you move toward a narrowed less populated eco system, which I think for many (hopefully) obvious reasons is best avoided.

Extremely Simple example (1)

Deliveranc3 (629997) | more than 6 years ago | (#21543683)


int Tree( Char ***Node1, char **data)
Sort a-z
return height

int retreive (char **return, char **searchfor, int length)
return found

For simple functions it works well, for open source code it works great.

Between those levels lies the question, why aren't you using their code anyway?

First-class Copy & Paste for Code Reuse (1)

naasking (94116) | more than 6 years ago | (#21543747)

Like most problems, textual code reuse has via copy & paste has already been studied, and a language based on first-class copy & paste is being developed [subtextual.org] ; it's called the Subtext [subtextual.org] language. See a more detailed discussion of it on lambda-the-ultimate [lambda-the-ultimate.org] . Academia is not so far remove from everyday programming as people seem to think!
Load More Comments
Slashdot Account

Need an Account?

Forgot your password?

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>
Create a Slashdot Account

Loading...