Bing, Microsoft’s search engine, is making it easier for developers to discover exactly the code snippet they need for a particular project.
When developers type in a specific query such as “covert case using a function in R” (which is the example used by Microsoft), Bing will display what it thinks is the right code snippet, sourced from a top-ranked webpage such as Stack Overflow, Github, or W3Schools.
In order to surface code snippets, Microsoft had to refine Bing’s search process. Specifically, it had to architect the system to differentiate between “coding” and “non-coding” queries; for example, whether a user is searching for “Java” as in the programming language, or “Java” as in the Indonesian island.
If a coding query is detected, Bing will examine all terms in the query to try and gauge user intent; search-box references to APIs, specific syntax, or commands certainly help in this regard. “To achieve this level of precision for query intent detection, Bing’s natural language processing pipelines for developers leverages patterns found in training data from developer queries collected over the years containing commonly used terms and text structure typical for coding queries,” explains Microsoft’s official Bing blog. “The system also leverages a multitude of click signals to improve the precision even further.”
Bing evaluates the content on the webpage against the original query in order to decide if a code snippet is relevant enough to surface. “The semantic score produced by the model captures the quality of match of the document snippet to the query,” the blog added. “During the next steps in the process the snippets are evaluated, ranked, and the best one is returned.”
Bing isn’t the first search engine to surface code snippets. DuckDuckGo does the exact same thing: look how it processes that “covert case using a function in R” example. Presumably, DuckDuckGo uses a similar type of semantic analysis to arrive at these results.
For developers—or even people learning to code for the first time—these code snippets can save lots of time and aggravation. It’s difficult to memorize every possible coding permutation, especially if you work with multiple programming languages; looking up code is an important part of a typical workflow. So the next time you need a lightning-quick answer to a code conundrum, look no further than DuckDuckGo or Bing; meanwhile, Google has become (slowly) better at recognizing code queries.