Most of the code you write, has probably been written before. Why not reuse it?
11–20 of 28 posts
Re: Most of the code you write, has probably been written before. Why not reuse it?
#12Not a very well thought out product.
Re: Most of the code you write, has probably been written before. Why not reuse it?
#13I think it's difficult to search a functionality by words. For example, if I want to fund matrix multiplication, the function name could mulmat, matrixProduct .... could be anything. second, even code is found, building requires lots of work. missing dependency, mismatching interfaces, unsupported os...
Smalltalk had a neat solution to this. You gave some arguments and a result, then it tried all the methods with the right types, and listed the ones that gave the result. Searching for '(a b c) and 'a would tell you what car is called in Smalltalk.
for example, in the case of matrix multiplication, A * B is valid, B * A could be invalid. How to pass the parameters in right order for searching?
Re: Most of the code you write, has probably been written before. Why not reuse it?
#14Re: Most of the code you write, has probably been written before. Why not reuse it?
#15I think it's difficult to search a functionality by words. For example, if I want to fund matrix multiplication, the function name could mulmat, matrixProduct .... could be anything. second, even code is found, building requires lots of work. missing dependency, mismatching interfaces, unsupported os...
Smalltalk had a neat solution to this. You gave some arguments and a result, then it tried all the methods with the right types, and listed the ones that gave the result. Searching for '(a b c) and 'a would tell you what car is called in Smalltalk.
Re: Most of the code you write, has probably been written before. Why not reuse it?
#16Re: Most of the code you write, has probably been written before. Why not reuse it?
#17I think it's difficult to search a functionality by words. For example, if I want to fund matrix multiplication, the function name could mulmat, matrixProduct .... could be anything. second, even code is found, building requires lots of work. missing dependency, mismatching interfaces, unsupported os...
Smalltalk had a neat solution to this. You gave some arguments and a result, then it tried all the methods with the right types, and listed the ones that gave the result. Searching for '(a b c) and 'a would tell you what car is called in Smalltalk.
To answer OP's question, the reason people rewrite is that it's "faster" to write a new one than find what's out there
OR
I don't want an entire house when all I want is a faucet. Today if you want a faucet. you might have to do something such as house = new House(); faucet = house.getFaucet(); So you have to tear apart/copy and paste the code, if it's loosely coupled enough, you find yourself dealing with all the dependencies.
This is a question lots of people have been asking tho, checkout this talk from the creator of Erlang asking the same question https://www.youtube.com/watch?v=lKXe3HUG2l4
Re: Most of the code you write, has probably been written before. Why not reuse it?
#18I think it's difficult to search a functionality by words. For example, if I want to fund matrix multiplication, the function name could mulmat, matrixProduct .... could be anything. second, even code is found, building requires lots of work. missing dependency, mismatching interfaces, unsupported os...
type interface is usually enough https://www.haskell.org/hoogle/
In Haskell's case, due to the particulars of the type system, something like Hoogle is _relatively_ straightforward. More importantly, the same system that makes Hoogle possible also enables safe code exploration and reuse.
Eschewing simpler examples for something a little more production-y, I dug up something that came about after a conversation a few weeks back:
( MonadIO m
, PersistEntity val
, PersistEntityBackend val ~ SqlBackend
) => m [Entity val]
Line by line, the signature (roughly) encodes the following [1]:1) The context `m` must provide the ability to perform I/O
2) `val` must have some representation understandable by the Persistent ORM [2]
3) `val` must have some backend within the Persistent ORM [2] that satisfies the `SqlBackend` constraint
4) The function provides a list of `Entity val`, where `Entity` is a Persistent-specific implementation detail, within some context `m`.
IMO, this is incredibly useful for searchability because it encodes everything I said above (and more precisely, at that!). Further, these terms can be pulled apart, rearranged, and composed to form more, or less, specific concepts in a query.
This is _also_ useful for code reuse, as seeing these specifications can help identify points of repetition, and encourage higher levels of abstraction.
Apologies if this got a little away from the heart of the discussion and turned into a bit of a brain-dump towards the end :)
[1] I'm not using the most precise wording here, mostly due to my own incomplete understanding of things
[2] Persistent isn't exactly an ORM, but it's the closest analogy I can think of given how comprehensive it is
Re: Most of the code you write, has probably been written before. Why not reuse it?
#19Re: Most of the code you write, has probably been written before. Why not reuse it?
#20I love code reuse! However... License matters. Control matters (what if I need to make a change to fit a certain scenario? How does that happen? Is it propagated upstream? How/when?) Searchability matters. How do I know what I am looking for, especially across domains and companies?
The Code Seeker feature would not actually apply changes, it will allow you to import into whichever IDE you are using and the mechanism or VCS you currently use will still apply. Does this make sense or am I not understanding the Control matters part?
Indexing and Searchability are going to be interesting to implement. I use IntelliJ and Rubymine and at times the indexing is too heavy handed and they are only indexing the current project.