13 ms·
Autocomplete from Stack Overflow
- mrfusion 11y agoI don't understand how it works? It's just matching the function name?
- eschutte2 11y agoNo, 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.
- robinduckett 11y agoSeems to work very well for that one example, but I can't get it to work for anything else.
- ianstormtaylor 11y agoIt's not obvious, but because of the way it's programmed, you have to remove the example function, since it parses the entire code block for similarities.
- ryannevius 11y agoThis 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.
- swiley 11y agoI only have 50 stack overflow points /total/ (although I only very rarely post) so I would absolutely agree that it's way too high.
- sleepychu 11y agoAccepted answers are also included.
- eschutte2 11y agoThanks - 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.
- deleted 11y ago[deleted]
- rcarmo 11y agoPretty neat, although the "training set" probably doesn't comprise what most people would need. I'd like to see a version of this based, say, on React examples. Might save me some time :)
- nateabele 11y agoHaha, I love this. We're getting closer and closer to the ultimate conclusion of our industry: where we'll just type in a few keywords and generate full applications from StackOverflow code examples!
- pavs 11y agoSiri, make me a facebook clone.
- pc86 11y ago... but for cats!
- Uehreka 11y ago...12 hours of involuntary surgery later: There, now you're a facebook clone.
- mikeash 11y agoThis is close to a real pun it would do, and nearly just as dire. It's fixed in recent versions, but it used to not understand emergencies. If you said "Siri, call me an ambulance," it would come back with "OK, I'll call you 'an ambulance' from now on."
- AnkhMorporkian 11y agoThat's both tragic and hilarious.
- CamperBob2 11y agoI still remember searching on Apple Maps for "hospital," and getting a map with every emergency veterinary clinic within 50 miles. Really, Apple? Nobody thought of this use case? You shipped this thing with that little forethought?
- botw 11y agohaha:)))
- jnardiello 11y agoIf it's a joke "Ahah", if not it's just depressing. SO is a valuable resource to confront and understand concepts. Let's not encourage this copy/paste culture
- agumonkey 11y agohttp://rm.rf http://rm.rf
- asadlionpk 11y agoWhy not? If it gets the job done (probably faster too). I would even suggest that be realistic and allow copy/paste during interviews too!
- blueblob 11y agoI think it forgets to include a license for all of the snippets that you use.
- jaflo 11y agoAll StackOverflow "user contributions licensed under cc by-sa 3.0 with attribution required"
- joslin01 11y agoSo that interviewers can gauge your ability on searching & referencing code examples from the web? Who's being realistic?
- hobs 11y agoWhen I hired people for a very entry level position, this was 100% on the list of things you had to be able to do (use google effectively.) Its amazing how many people cant.
- wanderingstan 11y agoBeing able to search and use online code examples is a key skill in software development. The web has become the collective knowledge base for all of us.
- WithTeeth 11y agoCool idea, but kind of ironic that the example you used produces unnecessarily complicated stack overflow solutions. A JavaScript "contains" function is as simple as: var contains = function (needle, haystack) { return haystack.indexOf(needle) !== -1 }
- ne0phyte 11y agoOlder 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.
- CiPHPerCoder 11y agoOr just not support older IEs. http://browserupdate.org/ http://browserupdate.org/
- romanovcode 11y agoMaybe the likes of you someday will get a job and then understand that "what you support" does not depend on you.
- extrapickles 11y agoWhat I do, is provide nwjs to those on old versions, so they think they are getting the "application" version, but in reality, its Chromium hard coded to only goto the web application. So far its a win for both parties, since they are not installing another browser than can interfere with some silly IE6 only internal enterprise site and we get to use the latest browser features.
- dang 11y agoPlease don't post uncivil comments here.
- romanovcode 11y ago
- magic_man 11y agoWe can feed the SO data to a ml algorithm and pretty soon we won't even need software engineers. Go today self coding computers tomorrow.
- hzhou321 11y agoOf course we still need software engineers troll SO :).
- andgio 11y agoCan't really see this being useful if I'm honest. Here you are simply showing the code suggestions based on what the user is writing. You are completely ignoring both the context of the code being written by the user and of the code being suggested. These are key functionalities in order to actually be usable. With this you simply get hundreds/thousands of suggestions that are not related to what you are coding. And if by chance the suggested code is exactly what you want, then the variable names wouldn't even match. This is assuming that the suggested code is complete and functional.
- pavs 11y agoI don't think the point was to for it to be useful, it was something fun to do.
- blacktulip 11y agohttp://i.imgur.com/7SiQSD1.jpg http://i.imgur.com/7SiQSD1.jpg
- logicrook 11y agoWhere can you buy this book? I want it!
- schlowmo 11y agoNo need to buy it, it's free: https://www.gitbook.com/book/tra38/essential-copying-and-pasting-from-stack-overflow/details https://www.gitbook.com/book/tra38/essential-copying-and-pas... Found yesterday in this HN Story: https://news.ycombinator.com/item?id=11333448 https://news.ycombinator.com/item?id=11333448
- logicrook 11y agoOh, wow, thank you very much. It's funny because I thought "you can't just copy and paste SO, there's a number of things to think of to be able to do it correctly". Guess I'm not the only one who thought that. Anyway, most intellectual work is just applying known recipes (copy-paste, renaming a few variables), so it's just a matter of granularity and sources. The hate for SO copy-pasters owes a lot to the few beginners who don't understand that yet and take copy-paste literally.
- thegigaraptor 11y agoI came here to post this, you're a great person. This post fills me with dread, it's come to the point during code review that I have to be sure the shitty devs aren't coping the bad answers from stackoverflow... I hope they don't find this.
- grimmdude 11y agoI highly recommend this book to any front end developer.
- boksiora 11y agohahah :) someday we will say "Computer make me a program" and it will make it from SO posts
- MrPatan 11y agoBoss never wants a function, boss wants a solution to a problem, and your job is to know how to express that in functions. If you have the signature, 99% of your job is done. I know you know, I know they know, and I know you know they know. I just wanted to say it, ok?
- supergreg 11y agoRather than indexing StackOverflow, why not do this by indexing all the open source code out there? Sure StackOverflow answers are good, but they usually skip error checking for focusing on the question at hand. Code used in production applications surely is more sound.
- jonnycowboy 11y agoA good start would be for Github to host a package that contains the latest versions of each repo. However even they may not have that right (depends on TOS).
- ThinkCritically 11y agoWhat 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)
- drumdance 11y agoPerhaps 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.
- matt4077 11y agoThat's basically what linters do.
- lincolnbryant 11y agoESLint catches many
- TheOtherHobbes 11y agoThen you build a helper tool that analyses the differences between good code and bad code. Then you set it loose on its own source - and you have an AI that takes over the world. (Or at least github, which is more or less the same thing.)
- pka 11y agoInteresting. I was working on something similar [0] last year. Are you planning on publishing the code? [0] https://news.ycombinator.com/item?id=9954059 https://news.ycombinator.com/item?id=9954059
- bprosnitz 11y agoThere was some research from Stanford a few years ago with a similar idea http://hci.stanford.edu/publications/2010/blueprint/brandt_chi10_blueprint.pdf http://hci.stanford.edu/publications/2010/blueprint/brandt_c...
- falcolas 11y agoA great way to increase your liability in an automated fashion! Sure, the code on Stack Overflow is licensed as MIT... but what assurance is there that the code which was posted is original property that the poster owns copyright to? What assurance is there that the posters won't claim patents on the methods being used? The risk is low, but it's certainly not 0. Big companies caution their software developers to not even read code in SO answers to avoid lawsuits... how much risk do you bring to your company by copying and pasting (not to mention autocompleting) from SO? I am not a lawyer, etc. etc.
- mkobit 11y agoThere was recently talks around changing it, and most of the feedback was very negative. You can see the initial post here [1] and the follow up post here [2]. 1: https://meta.stackexchange.com/questions/271080/the-mit-license-clarity-on-using-code-on-stack-overflow-and-stack-exchange https://meta.stackexchange.com/questions/271080/the-mit-lice... 2: https://meta.stackexchange.com/questions/272956/a-new-code-license-the-mit-this-time-with-attribution-required?cb=1 https://meta.stackexchange.com/questions/272956/a-new-code-l...
- redblacktree 11y agoWhich big companies? I've never heard of such a policy.
- falcolas 11y agoMicrosoft and Oracle are two that I have direct experience with. Oracle has even refused to take a 3rd party's code and integrate it into their systems, even when all rights were assigned over.
- matt4077 11y agoIt's fortunately not _that_ easy to get a software patent. It'd be quite difficult to patent something that's the length of an average stackoverflow answer. There's also a lower limit on the length (and originality) for copyright which I doubt many answers reach.
- yitchelle 11y agoIf we put this in front of 1 million monkeys, would it generate the next killer app? Anyway, this gave me a little laughter today.
- eschutte2 11y agoGlad to hear it. That was my hope :)
- mananvaghasiya 11y agoCan somebody please make an Atom plugin for this? Oh wait...
- bawana 11y agoyes, but will this help a million monkeys smashing keyboards write the next great AI
- ajmurmann 11y agoI 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.
- Matetricks 11y agoHave you heart of StackSort? https://gkoberger.github.io/stacksort/ https://gkoberger.github.io/stacksort/
- conjectures 11y agoThat actually sounds realistic. A well defined test suite is probably a good target for AI. Main issue is no partial wins, which are needed for training, so you'd need to break all functionality down into absolutely minimal units.
- chillacy 11y agoAlso if you overfit, your code is going to look like: int add(int a, int b) { if (a == 1 && b == 1) return 2; if (a == -1 && b == 0) return -1; if (a == 13 && b == 7) return 20; return 0; } But at least it passes my unit test suite!
- firethief 11y agoJust rerun it with a lower target code complexity. You'll know you set it too low when it starts monkey-patching the test framework to avoid actually doing anything.
- creed0r 11y agoProbs for the idea. Nice thinking! I guess we as programmers should seriously think about the future of our craft. If, for example, we feel we are basically using the same building blocks over and over again, we should seriously think about organizing libraries and code snippets and questions asking for such snippets in an organized way and provide ways to transpile 1 solution in different languages etc.. We should not accept the current state of our craft as final and rather think about how to improve in general. If for instance something like StackOverflow has become the Wikipedia of Code then let's think hard about how to make into a full blown tool, with all the features and semantics we need. It was a nice project the way it started and grew but it doesn't have to stay like that forever!
- hbt 11y agoIt 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 because they can't find a component with the same functionality (which does happen but for other reasons e.g intellectual property). But we don't have the same intellectual property challenges and yet the best tools we have to discover and reuse code are 90s search engines that treat code as raw text with zero contextual understanding and often outdated code snippets. PS: I love your project btw.
- thoradam 11y agoThis is one of the best qualities of languages like Haskell, the type system promotes discovery and true reuse of code. There has even been research into specifying dependencies as 'something that implements this signature' rather than specific packages.
- harry8 11y agoYeah haskell is amazing. I'm still really looking forward to the day when somebody writes something actually useful in haskell. (Oh but pandoc, xmonad, shellcheck... in how many years?) ;-)
- Tau_Zero 11y agoOne big reason I've seen people "reinventing" small utilities and modules is to avoid external dependencies, both for licensing and management hassle.
- jandrese 11y agoThis is a big one. External dependencies are a liability, you need to be getting enough value out of them to offset their cost. For small one-off functions it's often better to just rewrite the thing than to pull in a library and have to worry about versioning or the library being abandoned or the API changing or the package manager on your target system not having that library or only having an old version or one that was compiled weirdly and doesn't have the function you need. There can also be interface friction between your code and the library--different syntactic style, or you have to convert the arguments from your native form into something the library can understand and then convert the result back. Don't get me wrong, libraries are wonderful and useful and you should be using them where appropriate, but like everything they have tradeoffs. I've seen way too many projects that try to just tie every single library they can find together without having to write any code. I know these projects because they're a nightmare to install and keep working and I end up spending way too much time trying to hack around all of the code rot to get them running again.
- braythwayt 11y agoI have a good feeling about this: https://vimeo.com/76141334 https://vimeo.com/76141334 This is exactly the direction we should be going. We build the world's most sophisticated engines for predicting human social behaviour, why are we stuck in the 1990s when it comes to autocomplete for a tightly scoped domain like writing software? Bravo!
- sharmi 11y agoStackoverflow 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.
- sabujp 11y agoSomeone please make this for eclipse, vim, intellij, emacs, sublime, etc
- lcfcjs 11y agoI just use lodash for things like this.
- creed 11y agoGreat idea, nice thinking! I guess we as programmers should seriously think about the future of our craft. If, for example, we feel we are basically using the same building blocks over and over again, we should seriously think about organizing libraries and code snippets and questions asking for such snippets in an organized way and provide ways to transpile 1 solution in different languages etc.. We should not accept the current state of our craft as final and rather think about how to improve in general. If for instance something like StackOverflow has become the Wikipedia of Code then let's think hard about how to make into a full blown tool, with all the features and semantics we need. It was a nice project the way it started and grew but it doesn't have to stay like that forever!
- jrbapna 11y agoIs there an atom extension for searching stack overflow snippets? if not, let's build one!
- jrbapna 11y agoit exists! https://atom.io/packages/ask-stack https://atom.io/packages/ask-stack
- mgalka 11y agoAwesome project! Nice work.
- byteface 11y agoi did something similar one night a few months back, using python as a sublime plugin, but scrapes the live site. it eventually gets blocked tho as doesn't use the official API. https://github.com/byteface/chode https://github.com/byteface/chode I considered hooking into a variety of other resources but haven't really bothered with it as have other things going on.
- nottednelson 11y agoSimilarly: 2014 Springer volume (http://www.springer.com/us/book/9783642451348 http://www.springer.com/us/book/9783642451348) and conference series that spawned it (https://sites.google.com/site/rsseresearch https://sites.google.com/site/rsseresearch).
- Finbarr 11y agoThis should exist for Wikipedia. Would be great to autocomplete sentences as well as code.
- daveheq 11y agoIt works great until it does something you don't want.