Live data from Hacker News

Most of the code you write, has probably been written before. Why not reuse it?

news.ycombinator.com

21–28 of 28 posts

Re: Most of the code you write, has probably been written before. Why not reuse it?

#21
post #16

Seems like it would encourage bad design. You should be keeping your code DRY by creating reusable functions in the first place. If it's across repos, then you should probably make one of the repos usable as a library.

Agreed - copy and paste can definitely be problematic.

DRY typically is discussed as it relates to a single project. What are your thoughts on this? Code reused across projects or repos is not the same. We can and should have duplicated code but why write it from scratch? For a simple example if I always want to have an Avatar in a navbar, why not make it easy to find and reuse in another project.

Re: Most of the code you write, has probably been written before. Why not reuse it?

#22
post #6

Earlier quoted context omitted.

type interface is usually enough https://www.haskell.org/hoogle/

Expanding on this a bit, the concept that Hoogle embodies is extremely powerful and I wish it were more widely available in other languages. 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…

This is great - checking out Hoogle now.

I love abstractions, although at times they become a barrier to edge use cases. I guess the art is determining how much to abstract.

Perhaps I am oversimplifying the way I was imagining the search. In my mind it could simply be a pattern match (including special characters) and return the results. Then the zoom in/out capability would allow you to determine if the result is applicable.

Re: Most of the code you write, has probably been written before. Why not reuse it?

#23
post #10

Earlier quoted context omitted.

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.

prolog does this too, but it's not enough. if you don't have enough data, you could find a match that will fail in the future. 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(…

The house analogy makes sense - I need to research Smalltalk and Prolog Checking out the video - thanks

Re: Most of the code you write, has probably been written before. Why not reuse it?

#24

Sounds great - where is it? Can I test it? I'm not sure what you mean by "next" and "previous", or what you mean by zooming in and out. How do I specify what I'm looking for? What level of granularity does it work at? What languages does it cover? How is this different from using libraries? How can I trust the code I find? Does it exist yet?

At this point just validating that the feature should be built. So nothing yet.

I will be posting some more details, videos... Which will give you more detail of how we think it should work.

Re: Most of the code you write, has probably been written before. Why not reuse it?

#26
99% of the code I write has already been written before.

99% of programs/apps already exist.

99% of things I say and do have already been said and done before.

Code reuse is not the solution. We must rethink software and communication as a whole. As far as I know, nobody is attempting anything close to this.

PMs are welcome.

Re: Most of the code you write, has probably been written before. Why not reuse it?

#27
99% of the code I write has already been written before.

99% of programs/apps already exist.

99% of things I say and do have already been said and done before.

Code reuse is not the solution. We must rethink software and communication as a whole. As far as I know, nobody is attempting anything close to this.

PMs are welcome.

Post reply on HN