Why We Use the C# Programming Language

Here at SGSI, our preferred programming language for desktop, service, and backend coding is C#.NET.

We were early adopters of the language when it first appeared circa 2002. I would love to say we did so because of our keen technical and business foresight, but the truth is we did not have much choice at the time. We are MapInfo resellers, and MapInfo was committed to Microsoft, and Microsoft was committed to its new .NET platform. 

Since then, C# has grown into a mature and solid development language for all-purpose coding. It is a Swiss Army Knife of programming languages. Stack Overflow’s 2021 survey reported that a quarter of all respondents use C#, and a third of all respondents use the .NET framework. It handles memory management robustly, compiles to an intermediate language that runs in multiple operating systems and provides innumerable features and tools that make our life easy. The latest version of its IDE, Visual Studio 2022, has both impressed and frightened the team here with its prescient AI intelligence. In short, the language and its tools free us up to focus on what we do best – cartography, GIS, and location intelligence.

Yet, I do admit that I sometimes miss the days of coding in straight C. I cut my teeth in high school on the original Kearns and Ritchie C manual, a slim volume with as much explanatory prose as a graduate math textbook (i.e., almost none). I used the C programming language all throughout my undergraduate and graduate school days and later developed an appreciation for C++, its object-oriented Pokemon evolution. C lets you get down and dirty in the memory heap to write the most efficient code possible. However, you had better know your way around pointers – those little sticks of coding dynamite that can quickly open an underground passage or just as quickly bury you in one. Coding in C may be slow going, but so is crossing the uncharted wilderness. There is something exhilarating about it and a sense that you can go anywhere and do anything.

C/C++ coders are the ones building and maintaining the infrastructure we all depend on – operating systems, engineering software libraries, the internet itself. But their numbers are small compared to the new legions of modern programmers, autodidacts, and boot camp graduates well versed in scripting languages like Javascript and Python, whose platform is the internet itself and whose applications are the web sites and APIs that run our economy. These scripting languages let you cobble together a full-stack application in a day, and if you can’t make the code more efficient, you can always scale up by adding more servers, which are cheap.

It is easy to be disdainful about scripting programmers. Some people say they aren’t “real programmers” in much the same way they say that a physician assistant or nurse practitioner is not a “real doctor.” I don’t think this is a useful way to think. PAs and NPs treat people with as much facility, professionalism, and empathy as doctors. In fact, they are often better suited to treat the more common sort of ailments because it is their daily bread and butter. Likewise for programmers. If I need a responsive, single-page web application, I am far more likely to look for a boot camp graduate than someone who wrote a PhD thesis on machine learning applications for the stock market. At SGSI, we have hired programmers with master’s degrees in computer science, and we have hired boot camp graduates straight out of school. They have different skills and abilities, and both have been effective, valuable members of the team.

But what has this to do with C#, which is neither a low-level engineering language like C, nor a scripting language like Python? It fits neither category neatly, trading control for expediency. It more closely resembles Java, another popular, IL-compiled, object-oriented language. Many things are much easier to do in C# than in C, but there are certain things you can’t do in C# because the language runtime insists on doing them for you under the hood.

Let’s use an analogy to explain the benefits and downsides to these languages and hopefully illustrate why C# is the ideal choice for us. Let’s say there’s a mountain, and on top of this mountain is a spectacular garden with a rare and splendid view of the surrounding countryside. People want to get to the top of this mountain, and they are willing to pay for the experience. Your job is to find a way to get the people up there. 

If you are a C programmer, you are going to engineer a solution with solidly designed infrastructure – a road up to the top of the mountain. And not just any road but a safe, multi-lane highway made from durable materials with clearly marked signs and effective drainage for rain and rest stops and runaway truck ramps and so on. You will be able to take any vehicle you want on this road whether a motorcycle or a semi-truck. However, roads are generally difficult to alter once built. You’ll probably only get one shot to build this road, and it will need to last for years, so you have to over-design the road so that it is large enough to handle its peak capacity and durable enough to last beyond its expected lifetime. When it’s done, it will handle thousands of visitors a day with little risk of injury, delay, or discomfort. But it will cost you a lot of money and take years to complete.

If you are a Python or Javascript programmer, you are going to find a solution that requires as little coding as possible, that reuses equipment others have built, and is easy to change – helicopters. You are going to buy helicopters and hire pilots who can take a dozen people up in under 5 minutes. Simple, quick, and effective. As the popularity of the attraction grows, you simply buy more helicopters and train more pilots. There are some downsides though. At some point as the traffic increases, you are going to have to do more work to handle situations you didn’t expect or plan on. For example, you are going to have to organize flight plans so there’s no chance of mid-air collisions. And unlike a road, there are a lot more ongoing maintenance costs which will require specialists. And you can only bring what fits in the helicopter or what it can carry on a harness.

And if you are a C# programmer? As you might expect, it is a compromise between the two – you are going to build a railroad to the top. Like the C programmer, you’ll need some initial construction to plan and lay out the tracks. But like the scripting programmer, you can still scale up or down by adding or removing train cars or altering the schedule. The startup time and costs are less than a highway but more than helicopters. The scalability is better than a road but not as responsive as helicopters. And while you can’t bring a semi-truck to the top, you can certainly haul anything on a train that you can haul on a semi and at a fraction of the cost in fuel.

What C# gives us over both C and scripting is an 80/20 solution that supports our Agile process. It can give us 80% of the functionality that the client wants with about 20% of the budget and time. The client can get their hands on a functioning prototype or beta version and give us feedback or request changes before the majority of the investment has been spent. And because Microsoft has invested so heavily in its .NET platform, we know that anything we write in C# will continue to run for the foreseeable future.