8 ms·
Analysing C# code on GitHub with BigQuery
- sAbakumoff 9y agoIt's always nice to see BQ-based research like this!
- matthewwarren 9y agoYeah BQ is basically magic, it's so impressive how much data is can process in 30 secs or less. (I know under-the-hood it consists of some very impressive algorithms/hardware/programming etc, as explained in https://cloud.google.com/blog/big-data/2016/08/in-memory-query-execution-in-google-bigquery https://cloud.google.com/blog/big-data/2016/08/in-memory-que..., but it feels like magic!)
- isp 9y agoSome good reading on BigQuery: https://medium.com/@thetinot/bigquery-required-reading-list-71945444477b https://medium.com/@thetinot/bigquery-required-reading-list-...
- matthewwarren 9y agoThanks for that list, I've seen a few of those, but quite a lot of new ones in there, reading my way through them now!
- isp 9y agoI'm glad it was helpful. I found this list (a very helpful list, with good posts!) during $DAY_JOB. Following your comment, I've shared this more widely here: https://news.ycombinator.com/item?id=15464921 https://news.ycombinator.com/item?id=15464921
- jimktrains2 9y agoAnd has excellent sql support, even before standard sql support was a thing.
- sAbakumoff 9y agoexactly. I also performed several researches back in days like this https://medium.com/@sAbakumoff/github-cancer-180db780d99d https://medium.com/@sAbakumoff/github-cancer-180db780d99d
- j_s 9y agoHN navel-gazing, BQ style: Top 100 Users on Hacker News by H-Index | https://news.ycombinator.com/item?id=11512455 https://news.ycombinator.com/item?id=11512455 (Apr 2016, 81 comments) and other social media: https://github.com/antontarasenko/smq https://github.com/antontarasenko/smq
- mulrian 9y agoInteresting to see 'var' isn't used as much as I thought it would be.
- matthewwarren 9y agoYeah, I thought the same. I now realise the better test of 'var' would be to compare it to how many times it's not used. That is count the times that 'var myClass = new MyClass()' is used v 'MyClass myClass = new MyClass()'. But my regex skills aren't good enough for that and I'm not even sure if you can do it purely in a regex? Also I imagine that 'var someNumber = 1' is used less that 'int someNumber = 1', but again, I'm not sure how to do the regex? I certainly only use 'var' when the same word is on both sides of the '=', so not in the case of int/double/decimal etc.
- mattmanser 9y agoI still use var in that scenario, because if you need different types you have to suffix numbers with an identifier anyway: var i = 1; //int var j = 1f; //float var k = 1m; //decimal var l = ""; //string var m = ''; //char
- matthewwarren 9y agoYeah, I know you can do that, but I can never remember which suffix is which ;-)
- lukepothier 9y agoThere are a few more for numeric types: var integer = 1; var long = 1l; var float = 1f; var double = 1d; var decimal = 1m; var unsignedInteger = 1u; var unsignedLong = 1ul;
- mattmanser 9y agoI use it religiously now, so much quicker to program with imo as you don't need to find out the return type. Surprised it's less used than async/await though, which I think MS massively overhypes the usefulness of (and is annoyingly making a lot of classes have async behaviour by default which can result in very weird random hangs). Although I imagine a significant number of class declarations would contain no var or async/await simply because of their nature.
- oaiey 9y agoIt always disappoints me as a C# dev is the lack of top level application products like WordPress and friends. All the top lists in Matt's post are either infrastructure or development tools.
- codeulike 9y agoI suppose its because people would have had to host a C# Wordpress on Windows servers instead of nice cheap Linux ones. Maybe that will change going forwards with .NET Core etc
- throwawayReply 9y agoAnd not just the expensive windows server but for a long time people considered windows builds of postgres / mysql not production-ready (How much of that was fud and how much truth I do not know), so typically any DB solution is Sql-Server which is another significant expense.
- pjmlp 9y agoThey still do. We have customers running Linux instances just for Postgres.
- matthewwarren 9y agoHmm, yeah that's a good point. I'd not looked at the individual repos too much, but you're right, there's not many (popular) products written in C#. However, I guess my lists are limited by what is on GitHub, Paint.NET springs to mind, but it's not open source.
- oaiey 9y agoYeah, paint.net also crossed my mind. Would not even show up. Too "small".
- mattmanser 9y agoIguess it's the pre-compilation requirement. Might change with the new version, but I think the inertia was lost for the language long ago. Here in the UK C# seems a lot more popular than Java, but I must admt I'm getting more and more js jobs these days, which fills me with a slight dread for the future as I really dislike programming in it. I think Unity has helped C# become more popular for the masses again.
- nawtacawp 9y agoC# developers overwhelmingly prefer putting an opening brace { on it’s own line (query used) Putting it on it's own line seems like a waste of space to me and doesn't contribute to the readability.
- mrighele 9y agoBeauty is in the eye of the beholder. For example I used to put the opening brace on a line of its own, mostly for simmetry reasons ( `{` in the same column as the relevant `}` ). By the way, after many years I had to change it for coding style reasons. Now when I look back to old code and I see that lonely `{` my reaction is "ewww", so I guess it is also a matter of habit.
- romanovcode 9y agoFor me it does.
- colejohnson66 9y agoIt’s the Visual Studio default. It definitely improves readability for me sometimes. Having empty lines makes it easier to read.
- partisan 9y agoIf I am not mistaken, Visual Studio automatically places an opening brace on the next line. When setting up coding standards, I asked my team not to fight Visual Studio. It generally has good auto-formatting functionality, but even more important is the uniformity and consistency of the code.
- shoover 9y agoOpening brace on a new line is the default, but VS has excellent granular settings in this area. I was tired of having different standards for C and C#, so at one point we switched our defaults and ran a utility to convert all our C# code. We use a new line for namespaces, classes, and methods and the same line for everything else. VS handles it flawlessly and we haven’t looked back. Thinking back, I have not seen any inconsistencies committed in that time. VS autoformat is that good, with braces and white space.
- joepour 9y agoSurprised there wasn't more Class1.cs
- codeulike 9y agousing UnityEngine; Is the second most used 'using' that's non-Microsoft (after Nunit). Shows how important Unity is for C# take up. And presumably most people using Unity to write games are not going to be sticking their code on GitHub either so this must be a fraction of the real use.
- throwawayReply 9y agoIT's important to open source C# take-up, but I'd wager the vast majority of C# usage is closed-source shops. c# just isn't favoured by hobbyists except for game-programming. But in business world (at least from my UK perspective) where nothing comes close to github, c# still seems as healthy as ever and that doesn't depend on unity at all.
- codeulike 9y agoOh yes for sure, but that's always been there. .NET has always been used widely for business internal stuff and that's what kept it alive. But the recent C# renaissance seems to be about app building stuff like Xamarin or Unity.
- tybit 9y ago1. ArgumentNullException, 2. ArgumentException and 5. ArgumentOutOfRangeException shows how badly C# needs more ability to specify/enforce contracts. It's awesome that C# 8 will address the number 1 problem, with non nullable references but number 2 won't be addressed until records post C# 8 by the looks of things and number 5 not until exhaustive pattern matching which doesn't look to be on the cards at all AFAIK.
- matthewwarren 9y agoGood point, yeah all the instances of 'ArgumentXXXException' points to there needing to be better language/tooling support for it.
- loarabia 9y agoThere were the below two items [0], [1] which are runtime and tooling pieces. I've used them years ago in side projects and they were helpful but haven't kept up with them recently. They both help find or handle argument validation issues as enumerated above. [0] https://docs.microsoft.com/en-us/dotnet/framework/debug-trace-profile/code-contracts https://docs.microsoft.com/en-us/dotnet/framework/debug-trac... [1] https://www.microsoft.com/en-us/research/project/pex-and-moles-isolation-and-white-box-unit-testing-for-net/?from=https%3A%2F%2Fresearch.microsoft.com%2FPex%2F https://www.microsoft.com/en-us/research/project/pex-and-mol...
- stult 9y agoSeriously. Contracts. I inherited a relatively substantial C# WCF business line app with a large number of classes each with many nullable properties. The null handling was awful, but there were too many classes to easily refactor to apply data contract attributes across the board (at least given that I am the sole available resource to do so). Instead I tried selectively applying the null object pattern to some of the most common troublemakers. It's improved things but god I wish the original dev had used data contract attributes from the beginning. Similarly, it's staggering the number of times I've seen someone wrap their entire method (or worse yet their entire program) in empty try-catch blocks just to avoid responsibly handling null and out of range exceptions. To me, it seems like the ubiquity of this antipattern indicates that there's something inadequate about the language, tooling, or developer culture. Or some combination thereof. I'm not enough of an expert to say what the problem is or how to fix it, but in my relatively limited experience I've found requiring data contracts up front smooths over a lot of the pain points. But it comes at a cost. I've never used an equivalent in any other language, so I don't how C# and .NET compare, but it does seem like a lot of boilerplate code that can limit decoupling if misapplied.
- CDillinger 9y agoInteresting how 'css/style.cs' is number 10 on the size list. Is this just a style sheet with the wrong extension? I always assumed GitHub's language detection was based on syntax rather than just extension. Does anyone know if this is the case?
- matthewwarren 9y agoI don't know about what's displayed on GitHub.com, but the dataset I queried only looks for a '.cs' extension, so there's a chance that some non C# files got in. The dataset is here https://bigquery.cloud.google.com/table/fh-bigquery:github_extracts.contents_net_cs?tab=details https://bigquery.cloud.google.com/table/fh-bigquery:github_e... Fortunately, most of the queries I've done are aggregations or looking for C# syntax, so there's only a few places non C# code could get in (I already filter out binary files, which I noticed earlier)
- niftich 9y agoBy the way, GitHub's language detection is powered by their Linguist library [1]. [1] https://github.com/github/linguist https://github.com/github/linguist
- matthewwarren 9y agoThanks for the link, I've always wondered how GitHub does language detection
- emodendroket 9y agoI'm surprised to see so little var, especially when ReSharper by default scolds you for not using it.
- recursive 9y ago> Finally, an interesting list is the top 10 using statements that aren’t System, Microsoft or Windows namespaces: > using System.Web.Mvc; But... that is a System namespace.
- matthewwarren 9y agoLOL, yeah I completely missed that one!! I've just updated the post, 'log4net' makes in into the top 10 now.
- Nucode 9y agoI’m really confused why you think #regions are terrible. I use them generously to collapse sections, and they objectively make code more organized. I would not be as productive without them.