J
jacob navia
There is an interesting discussion running in Slashdot now, about code
reuse.
The thema of the discussion is here:
< quote >
Susan Elliot Sim asks: "In the science fiction novel, 'A Deepness in the
Sky,' Vernor Vinge described a future where software is created by
'programmer archaeologists' who search archives for existing pieces of
code, contextualize them, and combine them into new applications. So
much complexity and automation has been built into code that it is
simply infeasible to build from scratch. While this seems like the
ultimate code reuse fantasy (or nightmare), we think it's starting to
happen with the availability of Open Source software. We have observed a
number of projects where software development is driven by the
identification, selection, and combination of working software systems.
More often than not, these constituent parts are Open Source software
systems and typically not designed to be used as components. These parts
are then made to interoperate through wrappers and glue code. We think
this trend is a harbinger of things to come. What do you think? How
prevalent is this approach to new software development? What do software
developers think about their projects being used in such a way?"
< end quote >
I think it would be an interesting discussion for us. We all do code
reuse, but somehow, it is supposed that code reuse is only done with
"advanced" languages with OO programming and what have you.
C, as a language, we are being told, doesn't encourage code reuse, it is
too "low level".
But I am anticipating. I have actually read "A deepness in the Sky",
and it made a lasting impression, it is a wonderful novel.
That part about software reuse made me think that actually this has
already happened a LONG time ago already since actually nobody starts
from scratch. We all reuse what other people have created for us.
When I start writing a new software in C, I reuse the compiler system,
the editor, and obviously all the software and hardware needed to create
the processor, the computer, etc. Nobody starts from scratch.
That scene in the book made also realize the LAYERED nature of
software. When we reuse a bit of software we make a new LAYER of
code, hopefully a layer that allows us getting higher quicker and
doesn't represent a risk of letting us down and crumbling when we climb
to it
Code reuse in C takes many approaches, but probably the most common is
cut/paste.
We take a piece of software from some other software, that doesn't even
have an explicit interface and wasn't even intended to be reused at all.
We just reuse the algo.
Mostly we reuse a function, or a piece of a function doing a simple
task. For instance today I was wondering if I could write a rationals
package (numbers like 2/3, 3/4 etc), specifically a least common
multiple algorithm (lcm). So I started looking around
(software archeology) and remembered that I wrote already such a package
for a lisp interpreter back in 1989 that already did that. After several
hours looking around in the pile of old floppy disks, I found it, and
it seemed reusable.
But I wasn't satisfied, there are maybe errors, even if the tests back
then never showed any errors in it.
Google.
Google has a feature called
http://www.google.com/codesearch
that will allow you search an extensive data base of public domain
software. I searched for lcm algorithm and found a hit in
gnc-numeric.c -- an exact-number library for accounting use
* Copyright (C) 2000 Bill Gribble
In the package "gnotime". I looked at the algorithm and it did almost
the same thing as I did, what was kind of reassuring.
Reuse today is done more or less like that. You search ("archeology")
a data base of old software and take pieces out of that software
incoporating them into the new one, more or less always with
some modifications.
Obviously there are many hidden assumptions when reusing software.
The most crucial one is that you can only reuse something if the
software environment that you are using is compatible with the old
software.
In the novel, Vernor Vinge supposes a stable society/environment of
millions of years, with human beings living several thousands of years.
Obviously that is an ideal reuse environment, what couldn't be absent
from the mind of Vinge, a software expert.
Software reuse can be done in this way in C since C offers a stable
software environment taht is now quite old, even if our whole field
(data processing) is comparatively new.
Other languages, due to their more recent origins, offer less
opportunities for software reuse in this way. C#, for instance,
being just a few yers old at most, will never have the same database
of code as C. A search with the same parameters yielded not a
single match for C#.
Here are the results for some languages:
C 9
C++ 3
Java 1
Ada zero
C# zero
Asm zero
Lisp zero
Smalltalk zero
Fortran zero
Delphi zero
Obviously there must be other algorithms where this is different,
because some languages are specialized in numerical calculations,
others in IA algorithms, etc etc.
These are just some thoughts to start a discussion.
jacob
reuse.
The thema of the discussion is here:
< quote >
Susan Elliot Sim asks: "In the science fiction novel, 'A Deepness in the
Sky,' Vernor Vinge described a future where software is created by
'programmer archaeologists' who search archives for existing pieces of
code, contextualize them, and combine them into new applications. So
much complexity and automation has been built into code that it is
simply infeasible to build from scratch. While this seems like the
ultimate code reuse fantasy (or nightmare), we think it's starting to
happen with the availability of Open Source software. We have observed a
number of projects where software development is driven by the
identification, selection, and combination of working software systems.
More often than not, these constituent parts are Open Source software
systems and typically not designed to be used as components. These parts
are then made to interoperate through wrappers and glue code. We think
this trend is a harbinger of things to come. What do you think? How
prevalent is this approach to new software development? What do software
developers think about their projects being used in such a way?"
< end quote >
I think it would be an interesting discussion for us. We all do code
reuse, but somehow, it is supposed that code reuse is only done with
"advanced" languages with OO programming and what have you.
C, as a language, we are being told, doesn't encourage code reuse, it is
too "low level".
But I am anticipating. I have actually read "A deepness in the Sky",
and it made a lasting impression, it is a wonderful novel.
That part about software reuse made me think that actually this has
already happened a LONG time ago already since actually nobody starts
from scratch. We all reuse what other people have created for us.
When I start writing a new software in C, I reuse the compiler system,
the editor, and obviously all the software and hardware needed to create
the processor, the computer, etc. Nobody starts from scratch.
That scene in the book made also realize the LAYERED nature of
software. When we reuse a bit of software we make a new LAYER of
code, hopefully a layer that allows us getting higher quicker and
doesn't represent a risk of letting us down and crumbling when we climb
to it
Code reuse in C takes many approaches, but probably the most common is
cut/paste.
We take a piece of software from some other software, that doesn't even
have an explicit interface and wasn't even intended to be reused at all.
We just reuse the algo.
Mostly we reuse a function, or a piece of a function doing a simple
task. For instance today I was wondering if I could write a rationals
package (numbers like 2/3, 3/4 etc), specifically a least common
multiple algorithm (lcm). So I started looking around
(software archeology) and remembered that I wrote already such a package
for a lisp interpreter back in 1989 that already did that. After several
hours looking around in the pile of old floppy disks, I found it, and
it seemed reusable.
But I wasn't satisfied, there are maybe errors, even if the tests back
then never showed any errors in it.
Google.
Google has a feature called
http://www.google.com/codesearch
that will allow you search an extensive data base of public domain
software. I searched for lcm algorithm and found a hit in
gnc-numeric.c -- an exact-number library for accounting use
* Copyright (C) 2000 Bill Gribble
In the package "gnotime". I looked at the algorithm and it did almost
the same thing as I did, what was kind of reassuring.
Reuse today is done more or less like that. You search ("archeology")
a data base of old software and take pieces out of that software
incoporating them into the new one, more or less always with
some modifications.
Obviously there are many hidden assumptions when reusing software.
The most crucial one is that you can only reuse something if the
software environment that you are using is compatible with the old
software.
In the novel, Vernor Vinge supposes a stable society/environment of
millions of years, with human beings living several thousands of years.
Obviously that is an ideal reuse environment, what couldn't be absent
from the mind of Vinge, a software expert.
Software reuse can be done in this way in C since C offers a stable
software environment taht is now quite old, even if our whole field
(data processing) is comparatively new.
Other languages, due to their more recent origins, offer less
opportunities for software reuse in this way. C#, for instance,
being just a few yers old at most, will never have the same database
of code as C. A search with the same parameters yielded not a
single match for C#.
Here are the results for some languages:
C 9
C++ 3
Java 1
Ada zero
C# zero
Asm zero
Lisp zero
Smalltalk zero
Fortran zero
Delphi zero
Obviously there must be other algorithms where this is different,
because some languages are specialized in numerical calculations,
others in IA algorithms, etc etc.
These are just some thoughts to start a discussion.
jacob