
Introducing Bing Code Search for C# - vwilson
http://blogs.msdn.com/b/visualstudio/archive/2014/02/17/introducing-bing-code-search-for-c.aspx
======
maresca
C# and .NET get a bad rap for being created by Microsoft. But one thing that
can't be ignored is how polished their development tools are. I absolutely
love coding in Visual Studio.

~~~
chrislomax
It pains me if I am honest. Our CMS is built on .NET and it's like an uphill
battle selling it as it's on IIS and it's .NET. I have played around with the
idea of reworking it into an open source language and open source database but
I would miss Visual Studio and the language a lot.

I don't get all the hate?

~~~
gisenberg
I think it's less about not wanting to use Visual Studio and more about not
wanting to have a Windows VM thrashing resources. I've worked with teams that
have migrated to ServiceStack just to avoid running Windows.

Assuming that running Windows is a non-issue, the parts that really, really
bug me are:

    
    
       - Background operations suddenly become foreground operations that stall the IDE with a dialog saying "A background operation is taking too long."
       - Misclicks spinning off long background tasks that stall the IDE. 
       - Automatic refactoring/code analysis that will stall the IDE.
       - Incredibly aggressive automatic reformatting.
       - The Microsoft Account agenda. VS2013 wants me to sign-in with my Microsoft account on so many different occasions: settings sync, Azure, Windows Developer account registration, auth refresh, etc... which wouldn't be so bad, but I'm signed in via Windows 8 already, adding insult to injury.

~~~
jasallen
\- Never had background to foreground stall IDE issue in VS2010 or up

\- Nor misclicks stall IDE

\- Nor automatic refactoring analysis stall IDE

\- Automatic reformatting is a once click option to disable and is not
terribly aggressive in VS 2010 up.

\- _wants you to_. Not forces. So, by the way, do JetBrains, NetBeans, Oracle
...

~~~
gisenberg
Not running into those issues must be really great for you, but does very
little to make the experience better for me. I tend to run VS under
virtualization with TFS, which is far from a pleasant experience, even on
modern hardware.

~~~
codelap
So on a local machine, in virtualization, you are running an IDE, SharePoint
Server, SQL Server, IIS, TFS. If you aren't running it from a separate SSD
drive then the problem has nothing to do with the IDE. You have an IO
bottleneck.

~~~
gisenberg
I'm not sure where you pulled SharePoint and SQL Server from, and running the
TFS client is a far cry from running the TFS server.

That said, my experiences with Visual Studio only serve to underscore the
point that my peers would prefer to avoid running a Windows VM altogether if
there are open-source alternatives that are good enough.

~~~
codelap
From your comment, you said TFS. TFS is the server, which include SqlServer,
Sharepoint, an OLAP cube, and the TFS server components. The TFS client
extension, (which is not TFS) has been baked in for the last 2 versions. So I
assume you're using VS 2010, and that is a much different beast. It has a lot
more issues, but it's a much improved IDE.

As far as virtualization, why are you working in a virtual environment? What
are your machine specs? What is the emulator? I'm genuinely curious, because I
haven't encountered any of those issues.

~~~
gisenberg
I was referring to Team Explorer which, as of VS2013, doesn't appear to be
included out-of-box. Apologies for the confusion.

Virtualization is kind of a red herring here, because as mentioned before,
this happens on an array of workstation-level hardware (quad-core Xeon/i7,
16-32GB configurations, SSD).

The point is that virtualization makes these already-painful existing issues
much more pronounced, such that my peers actively want to avoid spinning up a
Windows VM for a project. These experiences, whether agreed with or not, were
largely responsible for the immediate revulsion my team felt to Windows-based
solutions. I can't begin to explain how excited people were at the prospect of
not having to use Visual Studio anymore when ServiceStack rolled out at my
prior company.

My use case for virtualization is mobile development spanning iOS, Android,
Windows 8 and Azure-backed services. The last few companies I've been on-site
at outfit their employees with high-end MacBooks, with developers occasionally
using virtualized Windows under protest.

~~~
codelap
Team Explorer has been baked in for the last two versions. Regardless, most of
your points have little to do with Visual Studio, and a lot to do with Windows
and Virtualization. Besides, half your gripes can be turned off in the
settings.

If you have to work with the tools daily, then take the time to learn them.
You'll thank yourself.

~~~
gisenberg
I'm not sure if you're intentionally glossing over the "this happens with or
without virtualization" point, but I'm glad you're happy with the tools you're
using.

------
AlaShiban
If you want more info about the extension let us know. There's alot of cool
contextual and semantic pieces in there that makes it a smarter search

~~~
jervisfm
This is a pretty cool research project. I do not use Visual Studio but being
able to search for and use code-snippets inline can be quite the productivity
booster. Lord knows how many times I use google.

Have you considered perhaps including more data sources ? I'd imagine for
example a public code repository like Github or Codeplex will extend the range
of possible "How Do I" questions that can be answered.

On an unrelated note, I have almost always been disappointed by the search-
quality of Github. I know they have a lot of public code but they don't do a
good job of surfacing relevant code results. Imagine for example, how cool it
will be being able to type into Github, "How to compute MD5, C++" and seeing
the relevant code.

Actually, thinking about it, there is nothing preventing Microsoft Research
from taking this tech, and turning it into a natural language web code search
service. Now that would be awesome !

~~~
AlaShiban
There's alot more that can be done with the technology. We wanted to start
with a few core partners and drive the quality and relevancy up as we go - so,
can we? Sure. It's a matter continuously improving the service

And, agreed, MSR does some cool stuff :)

------
bruceboughton
It's interesting that the example code shown is so clunky. It uses try-finally
to manually dispose the resource when the idiomatic way would be to wrap it in
a using block:

    
    
      using (var file2 = new StreamReader(file))
      {
        while ((line = file2.ReadLine()) != null)
          Console.WriteLine(line);
      }
    

It's possible this is a badly picked example but it shows one big downside of
this -- the lack of discussion about the sample code that you would normally
get at e.g. Stack Overflow or a blog.

~~~
jmnicolas
But with a 'using' you can't catch an exception. So in production I end up
using ( ;-) ) try catch finally.

~~~
bluefinity
The using block compiles to the equivalent of a try-finally block. If you want
to catch an exception you can do it inside or outside the using block.

~~~
ifross
There are known issues with using "using". If the Dispose() call throws an
exception in the finally block, then any exception that occurred in the within
the using block is masked.

The easy solution is to make sure that your Dispose() calls don't throw
exceptions, unfortunately some of Microsoft's classes don't conform to this
(e.g. WCF clients).

The following MSDN article shows a case where they do not recommend using
"using", and instead suggest explicitly using try-catch-finally:
[http://msdn.microsoft.com/en-
us/library/aa355056.aspx](http://msdn.microsoft.com/en-
us/library/aa355056.aspx)

------
guiomie
Everytime something C# is posted it's all about MS and why some like or
dislike C# or .Net, rarely are the comments related to the actual article.

Personally, I think this new feature is cool, but I've come to realise that my
visual studio freezes way more then initially, I think this might be because
I've got a few addons installed (ex: Demon, Resharper ...etc) I wonder what
will be the overall performance impact of this.

~~~
kevingadd
ReSharper is an infamous hog. It makes VS freeze up, devours memory, and
devours extra CPU cycles with background threads.

It _is_ at least a really useful add-on...

~~~
d0
This. We just blew away 50 licenses because on our project it's a hindrance
even on our E5 Xeons with 24Gb RAM and SAS+SSD disks.

~~~
guiomie
I develop on an HP win 7 3 gig of ram... imagine my pain.

------
seanmcdirmid
Science fiction becomes reality:

[http://en.wikipedia.org/wiki/A_Deepness_in_the_Sky](http://en.wikipedia.org/wiki/A_Deepness_in_the_Sky)

> The Qeng Ho's computer and timekeeping systems feature the advent of
> "programmer archaeologists":[2] the Qeng Ho are packrats of computer
> programs and systems, retaining them over millennia, even as far back to the
> era of Unix programs (as implied by one passage mentioning that the
> fundamental time-keeping system is the Unix epoch:

> Take the Traders' method of timekeeping. The frame corrections were
> incredibly complex - and down at the very bottom of it was a little program
> that ran a counter. Second by second, the Qeng Ho counted from the instant
> that a human had first set foot on Old Earth's moon. But if you looked at it
> still more closely ... the starting instant was actually about fifteen
> million seconds later, the 0-second of one of Humankind's first computer
> operating systems.

> This massive accumulation of data implies that almost any useful program one
> could want already exists in the Qeng Ho fleet library, hence the need for
> computer archaeologists to dig up needed programs, work around their
> peculiarities and bugs, and assemble them into useful constructs.

~~~
pasbesoin
That book, and its partner, "A Fire Upon the Deep", are very much worth the
read. Many other things in there, that we already see coming true:
Computational and monitoring "dust"; biomagnetic manipulation of perception
and personality; etc...

And Vinge is an excellent storyteller.

There's actually a third title in the series out, now, that I also quite
enjoyed. But the first two, and especially "A Deepness in the Sky", really got
my attention.

------
rjzzleep
mandatory crossplatform cli alternative howdoi [1]

vim howdoi plugin [2]

one of the few emacs plugins [3]

not sure if there are any other plugins, but that should cover a decent
portion of interest here.

[1] [https://github.com/gleitz/howdoi](https://github.com/gleitz/howdoi)

[2] [https://github.com/laurentgoudet/vim-
howdoi](https://github.com/laurentgoudet/vim-howdoi)

[3] [https://github.com/arthurnn/howdoi-
emacs](https://github.com/arthurnn/howdoi-emacs)

EDIT: sublime version [https://github.com/azac/sublime-howdoi-direct-
paste](https://github.com/azac/sublime-howdoi-direct-paste)

------
Nate630
Visual Studio sure has lots of neat extensions that add tons of value.
[http://vswebessentials.com/](http://vswebessentials.com/) is my fav.

~~~
forgotAgain
They would add even more value if they were supported by the Express versions
of the product.

------
nrao123
What a co-incidence!

Fred Wilson posted on this very topic this morning.
[http://www.avc.com/a_vc/2014/02/inspired-by-
github.html](http://www.avc.com/a_vc/2014/02/inspired-by-github.html)

From his post:

"I was at a hackathon up at Columbia University last weekend and one of the
hacks was a development environment that automatically queried StackOverflow
and GitHub as you are writing code so that you always have in front of you the
answers to the questions you are most likely to ask. The developer who did the
hack introduced it by saying something like "programming these days is more
about searching than anything else". That reflects how collaborative the
sharing of knowledge has become in the world of software development as a
result of these cloud based tools for developers."

~~~
lugg
Hmm I wonder if I can make a sublime add on to do this for various languages.
I could probably do php pretty easy. Anyone keen to do a node module for it?
CSS?

~~~
jc4p
That sounds a lot like
[https://github.com/gleitz/howdoi](https://github.com/gleitz/howdoi)

------
curveship
As someone who has recently been hiring .NET engineers, I have to admit that
this inspires mixed feelings. On the one hand, I can see huge power from
combining AI and search with the structured context of programming. On the
other hand, a disappointing number of the people we interviewed weren't
software engineers, they were IntelliSync engineers. We'd give them a problem,
and their first instinct was to hit a period and start hunting through the
method options that IntelliSync gave them to see if one got them closer to
their goal. Instead of stepping back and thinking about the problem generally,
they'd try to solve it by stringing together IntelliSync suggestions, like
stepping stones across a pond.

~~~
Tarks
It's Intellisense. I might have a chip on my shoulder but if you were
competent and really were hiring .net programmers you should know that?
Especially if you're going to take the mickey.

You get those types no matter what role they hide in. Today I spent an hour
with a candidate that looked really promising on paper dodge every question
and switch from being "mainly backend" to "mainly frontend" when they couldn't
tell me the difference between an interface and an abstract class....

~~~
curveship
Hah! Yes, I am (or pretend to be) competent, just not when writing HN comments
;). Thanks for the daily serving of humble pie.

I do wonder if there's something about .NET and a business environment that
encourages this kind of behavior. When the organization's values are in their
business rather than mentoring programmers, when they tell their programmers
to "just get it done," you end up with IntelliSyn...Sense programmers? I've
worked in various different programmer ecosystems, and I've never seen this
pattern so strongly. There are of course excellent .NET programmers, I don't
mean to say otherwise. And I got the feeling that several of the people we
interviewed had basic talent, they'd just been trained, intentionally or not,
towards this kind of behavior.

We started putting VS in front of candidates precisely to deal with the kind
of fuzziness you mention. We started with whiteboarding code, but a lot of
candidates would have a wrong design, then add a line of pseudo-code that they
claimed magically made it work. By having them write actual code, it forced
them to be explicit and to deal with unexpected outcomes.

------
gesman
If for nothing else - it shows MSFT's commitment to the language, to the
platform and to the framework.

~~~
tomp
No, it shows MSFT's commitment to future revenue and profit. If they were
really committed to the language, they would open-source it.

~~~
diverightin63
So the only way to be committed to a language is to open-source it?

~~~
tomp
In this day and age, yes. At least if you want it to succeed. MSFT knows this,
too - they open-sources TypeScript.

------
asdf3
Having this for Monodevelop and Unity3d would be great. Even better if we have
community curated suggestions.

~~~
pritambaral
Having this for any Language/IDE pair would be great!

------
arikrak
This is the beginning of a practical StackSort:

[http://gkoberger.github.io/stacksort/](http://gkoberger.github.io/stacksort/)

A lot of programming can involve Searching, but it doesn't have to involve
searching with plain-text. One would have thought Google would work on this,
but they closed down their code search and haven't offered anything else.

------
bovermyer
Ignoring all of the comments ____*ing about the Microsoft stack, this is a
cool feature. Bravo, guys. I wish my IDEs had this kind of thing.

------
josephschmoe
I really, really want this for IntelliJ/Android Studio. Actually, everything,
can I get this for everything?

~~~
boyter
I am actually looking at doing this, but integrating it with the
searchcode.com API. At the moment its just a question of long it would take me
to build a plugin for IntelliJ/Eclipse/Visual Studio. I did look into
oursourcing the work but the price as a little high for me to swallow at the
time.

------
ykumar6
One problem with this approach is it requires a change in user behavior.
Unless Visual Studio can get a developer to an answer every single time, it
may not be sticky enough to form a habit.

Google search reliably produces an answer each time, regardless of what the
question or problem is

This is why search is very sticky (and habit forming). MSDN (and even
Stackoverflow or Github) suffer from this problem because they only have a
subset of content that developers want/need. Google brings all these sources
together into a single search.

~~~
ykumar6
On the other hand, sharing context could be powerful

------
danabramov
To those who insist this somehow encourages copy-paste style of programming,
think again. What would this so-called programmer do if they didn't have this
extension? They'd put this question in Google and copy the first example that
works.

This extension doesn't “spoil” programmers any more than Google does. And if
you hire this kind of programmers, this is very likely a problem of yours.

------
forgotAgain
Visual Studio could be so much more for Microsoft. Why do they need a phone?
Let them make Visual Studio cross platform and developers would come back to
Windows as their base platform. All other IDE's pale in comparison. Too bad
that advantage is being wasted as far as new developers go.

~~~
rjbwork
I'm a young professional developer who has been in the industry for just over
a year. I am absolutely in love with C#, .NET, MVC, and the MS ecosystem in
general. I'm even using Azure these days.

I honestly can't imagine going back to the dismal experience that was the
ecosystem I used in undergrad - Linux/Unix + Java/Ruby/Python/C/C++. The only
one of those I actually still enjoy working in is Python, and I can do that on
.NET in VS as well. Ruby/Rails isn't really that bad TBH, but these days it
just feels like a second rate dynamic version of MVC.

------
mallamanis
"Programming by example" is becoming an interesting trend these days. VS seems
to be the first to implement widely such a feature. This of course, suggests
that this small-scale reuse is very common. But could it be a "problem" of
modern languages like Java and C#?

------
rl3
It will be quite nice if this ends up yielding results for individual
JavaScript frameworks some day.

~~~
sqs
I'm one of the creators of Sourcegraph, which does have results for many
JavaScript frameworks. You can find examples from all across GitHub, and you
can search by function name or full-text documentation.

JS is hard to analyze, but we're working hard on getting better--and the
analysis code is open source[1].

[https://sourcegraph.com/github.com/joyent/node](https://sourcegraph.com/github.com/joyent/node)

[https://sourcegraph.com/github.com/jashkenas/underscore](https://sourcegraph.com/github.com/jashkenas/underscore)

[https://sourcegraph.com/github.com/caolan/async](https://sourcegraph.com/github.com/caolan/async)

[1]
[https://sourcegraph.com/github.com/sourcegraph/jsg](https://sourcegraph.com/github.com/sourcegraph/jsg)

~~~
seanmcdirmid
Have you looked into Dr. JS?

[http://www.ccs.neu.edu/home/dimvar/jstypes.html](http://www.ccs.neu.edu/home/dimvar/jstypes.html)

------
arianvanp
Wouldn't a with(file) statement (instead of a finally block) be much more
idiomatic in the example they give? Not to be be pedantic but I think it
illustrates a good criticism. How can you ensure quality code snippets that
are "idiomatic?"

------
arnie001
Would like to see this for C++ soon enough. Looks great in the demo.

------
codygman
This is _very_ cool, but I fear that many will label themselves as experienced
programmers with nothing but the knowledge of using this tool to piece
snippets together.

------
zamalek
And there-in lies the evils of code snippets. All of the snippets he selected
were evil.

------
banachtarski
This sounds like a great way to enforce bad programming practices.

~~~
AlaShiban
We're worried about that too. What we're hoping to do as we progress is to use
best practices as metrics. Because we can do semantic matching, and not just
textual matching, there's a world of possibilities to make results more
helpful

------
Navarajan
I will wait for "Google Code Search for C#"

------
leonidr
We no longer need developers we need good searchers.

~~~
AlaShiban
We'll always need fantastic developers and engineers :) The goal is to help
you find good samples, whether it makes sense and how its used is still very
much open to how good (or not) a developer is

------
k_bx
I want this for elisp/emacs!

------
kyberias
But... that is not test driven!

------
adventureloop
This is really cool, I find the microsoft documentation particularly terrible.

I always had a chuckle when the first result for a simple C# concept and the
result isn't a MSDN site. I also chuckle when the result is a forum post from
2005 that drops me into a link loop.

Thankfully I won't have to write C# for a long while. I can't say I will miss
the MVC stack or the legacy burden you get with forms.

