My Experience Using .NET Core in the Real World

A New World

After 8 years of living in Microsoft world, I had begun to feel I was on a train that wasn’t going to stop in civilization. So when I was offered the opportunity to follow a boss I loved to a startup writing Ruby, I dropped my matte black Lenovo, and picked up a shiny Macbook. Going from C# to Ruby was quite a change, on the surface the differences between Rails and MVC are pretty small… but as I learned the differences, I grew to love it. Around the office my boss and I had a common refrain “there’s a gem for that”. Using the command line as part of my development workflow was different, but once I got used to it I declared it would be taken from my cold dead hands. Some of my favorite parts of the CLR was the very powerful meta-programming capabilities of reflection… and if you love meta-programming, well Ruby has got you covered. I had crazy fun, I missed the strong typing of C#, but overall I could deal with it because all the other benefits of Ruby made up for it.

A Merging of Worlds

About a year after I left Microsoft tech, a crazy post bubbled to the top of Hacker News. Microsoft was going open source. Many laughs were had, I even tried downloading an early version. Ultimately though, I liked my new ruby world a lot better. A few months later though, I decided I wanted to start a new project. The startup I was working at didn’t succeed, so I found a new job, but also wanted to build something. Except I I wanted to work with a business model I understood. eCommerce makes sense, you buy products, and sell them for more than you paid. The devil is in the details, and the world of ecommerce is all about collecting and analyzing data, and moving really fast. If you look at some of the top ecommerce businesses (like etsy, or wayfair) they’ve adopted engineering cultures that revolve around doing things fast, trying experiments small, and scaling up successes. PHP is the weapon of choice, because deploying quick and often is easy.To me, the ultimate architecture would be one that had strong typing, had good library support, allowed me to deploy often easily, and reliably, ran on the cheapest of operating systems, and had a good command line work flow. Ruby was pretty close to what I wanted, but strong typing is important to me, so I tried to pick up .NET Core again. This time was different. In just a few months, they had made an awful lot of progress. I made my decision then and there, that I was going hop back on my old train, they seemed to have switched tracks, and I liked where it was going.

Library Support – woe is project.json

Before I get too much into this, I want to make it clear. .Net Core is Beta software. Things are getting better; my experience today might not be your experience tomorrow. That said, the worst part of the new .NET are dependencies. Microsoft is actively porting libraries over as fast as they can, and for the most part things are coming pretty good. There are a few notable libs that are missing that really should be moved up in the queue (such as the SmtpClient) however the open source community has really been stellar at providing alternatives (thank you Mimekit!). There’s also been a few times that I really needed something (like a stripe library), and the community was finishing the port as I was working on that feature. There’s a lot of work going on, but what’s there today is very usable, and the community works together very nicely.The most frustrating part though, that I still struggle with is the definition of the project.json file. Despite reading as much about it as I could, it feels very much like voodoo to me. I have wasted hours doing nothing more than rearranging dependencies inside those files until something works. I think if my project consisted of only 1 project, it might be a lot easier, but since I have many shared library projects, things have been very frustrating. Simplifying the way this file works would make my life SO MUCH easier.


Deploying is a big topic, and I think to really do it justice I should write a separate post about it, but the short is… the worst part is mono. To build a real world application, you’re going to have to fall back on some dependencies that still require mono. The number of times that something failed, and the solution was “roll back to a previous version of mono” is more than 1. It has been a frustrating experience. Stable is not stable, and there are quirks such as the way DateTime works (inserting dates to a database is frustrating, code that works on windows fails on linux, and its monos fault).The good news though is the dnx stuff has been a great experience. As mentioned previously, an important thing for me is the ability to deploy often. Now to be sure, dnx is NOT php. You can’t just throw an updated file up on the server, and declare your work done. But compared to IIS, deployment is stupid simple. My basic setup is a Nginx reverse proxy that listens on port 80, and than 2 parallel environments (I’m on a single server) with the code base on unique ports, for which I alternate between each time I deploy. So while one environment is up and serving requests, I can do a quick git pull in the other environment, a dnu restore if necessary, and then run my script that does a nohup on the dnx command, and warms up some cache items. In all, it’s a process that takes seconds. I then manually connect to the new port, check that everything is okay, and than switch nignix configs to point at the new port and do a reload. Within minutes I can go from old code to new code, and if necessary fail back to old code. It’s smooth, its fast, and it works. Compared to life in IIS, its wonderful. No stupid 500 errors, no permission errors, no web.config voodoo… it all just works. I feel free to try experiments that might break things, because now not only do I have strong typing on my side, I’m confident I can deploy in minutes.


The power of .net is the tools, Visual Studio has always been one of the best IDE’s out there (and with Resharper, its just that much better). Since I do my coding on a mac primarily, VSCode has been my primary tool. Over the months, it has really improved… but overall it is a great experience. Plus, since I also have quite a few python scripts doing things that python is just a better tool for, I’ve found this really great harmony of having a single coding interface for ALL my code no matter what the language (except SQL, I have yet to find a good replacement for SQL Management Studio that works on mac).I love the simplicity of yeoman, and the other command line tools. My workflow is extremely productive, and I think Microsoft is on the right track by embracing these ideas. It feels very much like an echo of my Ruby days, and I’m very happy with that. Combined with gulp, and bower, working with Javascript is much the same as it is in other platforms. The integration is perfect in its simplicity. I never ran into any issues, and moving from another platform that had similar ideas much of my knowledge was transferable. A major plus.


Overall, I think if I was going to do this adventure again, I might think twice before building a business on beta software 😀 Struggles aside, I’m very happy with the direction Microsoft is taking their best asset (the .net framework), and I think my business has a very solid maintainable architecture that’s built to support my needs. it’s definitely a major upgrade from old world .NET development. Much as C# combined the best parts of C++, and Java I think .NET Core is combining the best parts of Java, and Ruby, while also running on a server that can take full advantage of the plentiful open source software available. I’m going to enjoy eating this cake.

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » My Experience Using .NET Core in the Real World

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址