News for hackers. Stuff that matters.
Re:Autocomplete Using Markov Chains by stewbrew on Wednesday February 20, 2019 @04:58AM (#19206836)
I wonder what the result would look like if this were applied to source code. IMHO a probabilistic algorithm for code completion could turn out interesting.

Most code completion algorithms work deterministic by deducing the set of completion candidates from the receiver's type/class or a list of keywords. Given that people/teams tend to name variables in a certain fashion, a probabilistic completion algorithm could make use of this and adapt to team/project-specific conventions. Given a team's code base one could probably build a pretty good code completion algorithm without any knowledge about the programming language.

likelycomplete[1] tries to do this in a dilettantish ad-hoc way for vim. It rates completion candidates (that are gathers from previously seen code) on the basis of context information. It's hampered by the limited performance of vimscript though. A full fledged solution would require an external server.

[1] https://www.vim.org/scripts/script.php?script_id=4889

Re:Autocomplete Using Markov Chains by xkapastel on Wednesday February 20, 2019 @08:25AM (#19207583)
> I wonder what the result would look like if this were applied to source code. IMHO a probabilistic algorithm for code completion could turn out interesting.

Neural program synthesis is similar to what you describe, here's a sample paper:

> We consider the task of program synthesis in the presence of a reward function over the output of programs, where the goal is to find programs with maximal rewards. We employ an iterative optimization scheme, where we train an RNN on a dataset of K best programs from a priority queue of the generated programs so far. Then, we synthesize new programs and add them to the priority queue by sampling from the RNN. We benchmark our algorithm, called priority queue training (or PQT), against genetic algorithm and reinforcement learning baselines on a simple but expressive Turing complete programming language called BF. Our experimental results show that our simple PQT algorithm significantly outperforms the baselines. By adding a program length penalty to the reward function, we are able to synthesize short, human readable programs.

https://arxiv.org/abs/1801.03526

Re:Autocomplete Using Markov Chains by venuur on Wednesday February 20, 2019 @05:55AM (#19207015)
A product called Tabnine[1] was discussed on Hacker News recently that supposedly does this.

[1] https://news.ycombinator.com/item?id=18393364

Re:Autocomplete Using Markov Chains by ThoseWhoDied on Wednesday February 20, 2019 @07:48AM (#19207409)
This exists as a startup called Kite: https://kite.com/
Re:Autocomplete Using Markov Chains by agumonkey on Wednesday February 20, 2019 @08:03AM (#19207484)
The day a completer can fix a Y situation I'll be damned