Live data from Hacker News

Autocomplete from Stack Overflow

emilschutte.com

91–100 of 151 posts

Re: Autocomplete from Stack Overflow

#91
post #80

Earlier quoted context omitted.

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.

It's almost a convention in Haskell. The idea is, since currying functions is easy and common, you stick the argument that you'd want the least in a curried version last. So if you wanted to find out if x was in ten lists, you'd just:

  map (elem x) [list1, list2, ..., list10]
or, for folds, the function is the one least likely to change, so you put it first, and the list is most likely to change, so you put it last:

  foldl (+) 0 [1,2,3]
  map (foldl (-) 100) [[1,2],[2,3],[4,19]]
Of course, it's always debatable if you can find some situation where you wanted to curry in a different order, but generally you pick in order to reduce forced named lambda parameters. As far as I can tell, that's how it's done.

Edit: if you saw the sneaky edit, you'll know that this particular convention isn't easy to follow!

Re: Autocomplete from Stack Overflow

#92
post #88

Earlier quoted context omitted.

What are you talking about? Every framework has reusable modules. Perhaps you mean package management?

I think that's part of the problem he's talking about. Why do new modules have to be made for a new framework? The framework should play nicely with standard modules written vanilla for that specific language. This way we're not staying over whenever a new framework is made.

Well there is CommonJS, and AMD modules. Many modules implement that in JS.

Re: Autocomplete from Stack Overflow

#93
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…

We've come a lot farther than you may realize. We've come far enough that, having removed a lot of the accidental complexities of importing external modules, we've discovered collectively than the essential complexity is non-zero. Bringing a module into your project is non-trivially expensive. Bringing multiple modules into your project grows in expense super-linearly. (Not "exponentially", but definitely something greater than linearly.)

There probably isn't a nirvana just waiting for That One Great Tool. Or, alternatively, if there is, it probably involves having to switch to something like a dependently-typed system or the very bleeding edge of where the Haskell community is right now, which is probably still not really quite where it needs to be yet for this. And that would still involve a lot of cost for that switch.

Oh, and this is one of those places where I perhaps may be justified in pointing out again that for all the sound and fury in software development, in reality our field does not move that quickly. There's a ton of package managers out there, but broadly speaking, they're the same set of features shuffled into various combinations. Nothing wrong with that, per se. Just a lot less innovation than may initially meet the eye.

Re: Autocomplete from Stack Overflow

#94
post #15

Earlier quoted context omitted.

Accepted answers are also included.

My understanding is that it's only using code from accepted answers with 50+ points tagged JS. So an accepted JS answer with 49 points would not be included, nor would a JS answer with 500 points that was not marked accepted.

Oh, you're right. That's crazy!

Re: Autocomplete from Stack Overflow

#95

This isn't working at all for me...Either I don't get what it's supposed to do, or the common functions I'm typing aren't common enough. On a related note, 50 StackOverflow points seems like a high number for something like this, and may reduce the results significantly enough that the example doesn't work for most common problems.

Thanks - you're absolutely right. I've been meaning to rebuild the index with a lower threshold. Right now I think there are only something like 140k fragments in there. I also plan to add a "score" slider so you can choose the quality of your autocompletions.

Re: Autocomplete from Stack Overflow

#98

I don't understand how it works? It's just matching the function name?

No, but I realize the demo doesn't make it very clear. It inspects the structure of the code up to the cursor position, based on the syntax tree, along with nearby variable and function names, and matches to similar constructs from SO. It could be greatly improved, but I haven't had a lot of time lately.

Re: Autocomplete from Stack Overflow

#99
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…

Maybe should add that as a feature to a reshare IDE - if it identifys functional identical code to library functions- it offers a refactoring.

Re: Autocomplete from Stack Overflow

#100

Earlier quoted context omitted.

Older IEs don't have Array.indexOf(). So you either have to extend the Array prototype or, you know, just implement it in a more compatible way.

Or just not support older IEs. http://browserupdate.org/

Maybe the likes of you someday will get a job and then understand that "what you support" does not depend on you.
Post reply on HN