Live data from Hacker News

Autocomplete from Stack Overflow

emilschutte.com

71–80 of 151 posts

Re: Autocomplete from Stack Overflow

#72

Earlier quoted context omitted.

What they really need is a way to rank github code by quality - so that a tool like this pulls in the good code (as opposed to code of lesser quality)

Perhaps instead of using StackOverflow "correct" answers, someone could create a site that has example of anti-patterns and code smells, which you could then use to analyze the code on Github and link to possible alternatives.

ESLint catches many

Re: Autocomplete from Stack Overflow

#73

I had a conversation with a coworker a few days ago where I jokingly suggested building an AI system that you give a failing test suite and it uses stackoverflow answers to make your tests pass. Sounds like we are one step closer to making that happen.

Have you heart of StackSort?

https://gkoberger.github.io/stacksort/

Re: Autocomplete from Stack Overflow

#74
Stackoverflow is an invaluable resource when you are a newbie or learning a new stack.

That said, the real value of stackoverflow is not only in the code but the surrounding explanation and the following comments which discuss the merits and demerits of each solution. So you get to read multiple solutions to the same problem and realize why the top answers standout from the others. In a way, you learn to smell good code and bad :)

So searching on StackOverflow can be a learning experience!

But these kind of developments might be the next step and who are we say?

One problem I foresee is, the highly rated solution could be for a specific version of the stack/software ( the latest stable or the obselete, unmaintained one). In which case, you might end up with an error amplifying the mess.

Re: Autocomplete from Stack Overflow

#75
post #62

It still astounds me that we haven't solved reusable modules in 2016. Sure, we have libraries, apis, package managers etc. but every time I read a code base, there is always a utility function reinventing the wheel. Someone wrote it because it is still difficult to discover modular code and reuse it easily. It's pretty nuts when you think about it. Imagine mechanical engineers having to recreate the same CAD file bec…

But we have this in software. On the JVM, Maven repos are essentially an enormous repository of existing modules that you can pull in your project with a one line addition to your build file. This covers small utility libraries to manipulate strings or dates (like the one you allude to) to entire ecosystems like web containers and everything in-between.

I don't understand what part of this doesn't qualify as a "reusable module" to you.

Re: Autocomplete from Stack Overflow

#76
post #62

It still astounds me that we haven't solved reusable modules in 2016. Sure, we have libraries, apis, package managers etc. but every time I read a code base, there is always a utility function reinventing the wheel. Someone wrote it because it is still difficult to discover modular code and reuse it easily. It's pretty nuts when you think about it. Imagine mechanical engineers having to recreate the same CAD file bec…

But we have this in software. On the JVM, Maven repos are essentially an enormous repository of existing modules that you can pull in your project with a one line addition to your build file. This covers small utility libraries to manipulate strings or dates (like the one you allude to) to entire ecosystems like web containers and everything in-between. I don't understand what part of this doesn't qualify as a "reusa…

npm and maven modules are not easily discoverable

- How do you search for a function other than by description or name. Assuming the developer classified properly and you even happen to use the same domain language as the writer.

- When multiple modules are returned, similar packages, how do you compare and select efficiently without wasting hours reading the code, evaluating it, checking if it is still maintained and hoping there are no hidden bugs etc.

It is easy to share code. Package manager even facilitate updating code. But it is still a nightmare to find/discover code and reuse it

It's like building a lego set. You know the building block you want but if you have to spend hours looking for it, you give up.

I believe competent developers write shitty code not because they are lazy or inexperienced but because the cost of writing great code is very high.

Re: Autocomplete from Stack Overflow

#77
post #76

Earlier quoted context omitted.

But we have this in software. On the JVM, Maven repos are essentially an enormous repository of existing modules that you can pull in your project with a one line addition to your build file. This covers small utility libraries to manipulate strings or dates (like the one you allude to) to entire ecosystems like web containers and everything in-between. I don't understand what part of this doesn't qualify as a "reusa…

npm and maven modules are not easily discoverable - How do you search for a function other than by description or name. Assuming the developer classified properly and you even happen to use the same domain language as the writer. - When multiple modules are returned, similar packages, how do you compare and select efficiently without wasting hours reading the code, evaluating it, checking if it is still maintained an…

Hoogle helps for Haskell projects, as you can search by Type, and the Types are expressive enough that that actually finds what you're looking for most of the time.

Re: Autocomplete from Stack Overflow

#78
post #62

It still astounds me that we haven't solved reusable modules in 2016. Sure, we have libraries, apis, package managers etc. but every time I read a code base, there is always a utility function reinventing the wheel. Someone wrote it because it is still difficult to discover modular code and reuse it easily. It's pretty nuts when you think about it. Imagine mechanical engineers having to recreate the same CAD file bec…

Haskell has Hoogle[1], which allows you to search for functions using a type signature. This is surprisingly effective.

Let's say you want that `contains` function from the original post. You'd search for `(Eq a) => a -> [a] -> Bool`, which describes a function that takes two parameters and returns a boolean. The first result[2] is the `elem` function, which is exactly what we wanted!

This is a bit of a contrived example, but I have honestly been surprised by how effective searching by type signature is in Haskell. I wonder if it is possible for a language with a weaker type system, like JavaScript.

[1] https://www.haskell.org/hoogle/

[2] https://www.haskell.org/hoogle/?hoogle=%28Eq+a%29+%3D%3E+a+-...

Re: Autocomplete from Stack Overflow

#79

Earlier quoted context omitted.

> Now, if a programmer decides whether or not study and understand the pasted code has nothing to do with the quality of the final product. I deeply disagree with this and for such obvious reasons.

Why? A widely accepted answer(many points) is most likely correct/best practice/bug-free.

It may be bug-free, but it may not be the correct solution for the specific problem the programmer was trying to solve. It may also not do what is expected under different circumstances.

It may be a hammer when you're looking for a screwdriver.

Re: Autocomplete from Stack Overflow

#80
post #62

It still astounds me that we haven't solved reusable modules in 2016. Sure, we have libraries, apis, package managers etc. but every time I read a code base, there is always a utility function reinventing the wheel. Someone wrote it because it is still difficult to discover modular code and reuse it easily. It's pretty nuts when you think about it. Imagine mechanical engineers having to recreate the same CAD file bec…

Haskell has Hoogle[1], which allows you to search for functions using a type signature. This is surprisingly effective. Let's say you want that `contains` function from the original post. You'd search for `(Eq a) => a -> [a] -> Bool`, which describes a function that takes two parameters and returns a boolean. The first result[2] is the `elem` function, which is exactly what we wanted! This is a bit of a contrived exa…

Does the order of the parameters matter? It's been a while since I've touched Haskell, so maybe it's obvious that this isn't [a] -> a -> Bool for some idiomatic reason. I guess that would be `isContained` instead of `contains`, so it probably wouldn't be the first thing I search for, but there's at least some potential for ambiguity.
Post reply on HN