Scott Hanselman discusses .NET with SE Radio host Jeremy Jung. They discuss what .NET means; intermediary languages and JIT compilation; why there are three runtimes; making the core runtime open source and cross platform; platform-specific code; advances in performance and deployment; changing .NET’s perception; and domains that use .NET.
Show Notes
Related Links
- Scott’s blog
- @shanselman
- How to get started with .NET
- What is .NET?
- Common Language Runtime (CLR) Overview
- NuGet (package manager)
- Techempower Benchmarks (ASP.NET core)
- Mono runtime (Cleanroom .NET implementation)
- Unity (Write games using C#)
- Xamarin (.NET Mobile apps)
- .NET nanoFramework (embedded devices / microcontrollers)
- .NET foundation
- .NET interactive
- Blazor (Client web apps with .NET)
- Single file deployment and executable
- All About Span: Exploring a New .NET Mainstay
- Virtual Desktop is what VR needs
Transcript
Transcript brought to you by IEEE Software
This transcript was automatically generated. To suggest improvements in the text, please contact [email protected].
Jeremy Jung 00:00:17 This is Jeremy Jung for Software Engineering Radio. Today I’m talking to Scott Hanselman. He’s a partner program manager at Microsoft, the host of over 750 episodes of the Hansel minutes podcast. And he’s got a YouTube channel. He’s got a lot of interesting videos. One of the series I really enjoy is one called “computer stuff they didn’t teach you.” You’re you’re all over the place. Scott, welcome to Software Engineering Radio.
Scott Hanselman 00:00:41 Thank you for having me. Yeah. I was an adjunct professor for a while and I realized that in all of my career choices and all of my volunteerism and outreach, it’s just me trying to get back to teaching. So I just started a TikTok. So I’m like the old man on TikTok now, but it’s turned out to be really great. And I’ve got to engage with a bunch of people that I would never have found on any other social platform. So whether you find me on my podcast, my blog, which is almost 20 years old now, uh, my YouTube or my TikTok or my Twitter, it’s pretty much the same person. I’m a professional enthusiast, but that’s all done in the spare time because my, my primary job is to own community for visual studio.
Jeremy Jung 00:01:22 That experience of being a teacher in so many ways is one of the big reasons why I wanted to have you on today. Because I think in the videos and things you put out you do a really good job of explaining concepts and just making them approachable. So I thought today we could talk a little bit about .Net and what that ecosystem is, because I think there’s a lot of people who they know .Net as a thing, they know it exists, but they don’t really know what that means. So yeah, maybe you could start with defining like what is .Net?
Scott Hanselman 00:01:57 Sure. Microsoft is historically not awesome at naming stuff. And I joke about the idea that 20 years ago, Microsoft took over a top-level domain, right? Thereby destroying my entire .org plan to take over the world. When they made the name .Net, they were coming out of comm and C and C++ involved component object models. And they had made a new runtime while Java was doing its thing and a new language and a new family of languages. And then they gave it a blanket name. So while Java was one language on one runtime, which allowed us to get very clear and fairly understandable acronyms like JRE, Java, runtime environment, and JDK, Microsoft came out of the gate with here’s .Net and C# and VB and cobol .Net. And this and that. And this was a multilanguage runtime. In fact, they called it a CR, a common language runtime.
Scott Hanselman 00:02:54 So rather than saying here’s C#, it’s a thing. They said .Net. And it can run any one of N number of languages. Now, the reality is that if you look over time, Java ended up being kind of a more generic runtime and people run all kinds of languages on the Java runtime .Net. Now has C, which I think is arguably first among equals as its language. Although we also have VB and, and F#, as well as a number of niche languages, but the .Net larger envelope name as a marketing thing remains confusing. If they had just simply said, Hey, there’s a thing called C. It probably would have cleared things up. So, yeah, sorry. That was a bit of a long answer and it didn’t actually get to the real answer, bear with me.
Jeremy Jung 00:03:42 So, I mean, you had mentioned how there was this runtime to that C runs on top of it. Is that the same as the JVM, like the Java Virtual Machine?
Scott Hanselman 00:03:51 So as with any VM, whether it be V8 or the JVM, when you could take C and you compile it, you compile it to an intermediate language, we call it IRL. Java folks would call it a byte code. And it’s basically a process or non-specific assembler for lack of another word. If you looked at the code, you would see things like load four byte string into, you know, shooto register type of stuff. And you would not be able to identify that this came from C. It would just look like this kind of middle place between apples and apple juice. It’s kind of apple sauce. It’s pre chewed, but not all the way. And then what’s interesting about C# is that when you compile it into a DLL, a dynamic link library or languages like a shared object, or you compile it into an executable, the executable contains that ill, but the executable doesn’t know the processor it’s going to run on.
That’s super interesting, because that means then I could go over to an arm processor or an Intel x86, or an X 64, or whatever, an iPhone they radically. And then there’s that last moment. And then that jitter that just in time compiler goes and takes it the last mile, that local runtime, in this case, the CLR, the common language runtime takes that ill choose it finally up into apples, apple juice, and then does the processor specific optimizations that it needs to do. And this is oversimplification because the pipeline is quite long and, uh, pretty exquisite. In fact, for example, if you’re on varying levels of processor on varying versions of X 64, or on an AMD versus on a, uh, an Intel machine, there’s all kinds of optimizations you can do as well as switches that we can do as developers and config files to give hints about a particular machine. Is this a server machine? Is this a client machine? Is it memory constraint? Does it have a, you know, 64 processors? Can we prep this stuff both with a naive Git, a naive just-in-time compilation, or then over time learn, literally learning over the runtime cycle of the process and go, you know, I bet you, we could optimize this better than swap out in while it’s running a new implementation.
So we can actually do a multi-layered Git. So here’s the, I want to start my application fast and run this four loop. You know, this four loops been running for a couple of thousand milliseconds and it’s kind of not awesome. I bet you, we can do better than we do a second pass, swap out the function table, drop a new one in, and now we’re going even faster. So our jitter, particularly a 64 bit jitter is really quite extraordinary in that respect. That’s
Jeremy Jung 00:06:41 Pretty interesting because I think a question that a lot of people might have is what’s, what’s the reason for having this intermediary language and not compiling straight to machine code. And what it sounds like, what you’re saying is that it can actually at runtime figure out like how can I run things more efficiently based on what’s being executed in the program, Right?
Scott Hanselman 00:07:01 So when you are running a strongly typed language that has the benefits and the speed of drawing type language, and you also choose to compile it to a processor specific representation, we usually as developers and deployers think about things in terms of architectures like this is for an arm processor, but is this a raspberry PI is an Android device. You really want to get down to the stepping individual versions of like an Intel. For example, I’m talking to you right now on an Intel , but it’s a desktop class processor. That was the first one released many, many years ago. It doesn’t have the same instruction set as a modern I nine or a Xeon or something like that. So we have to be able to know what instruction sets are available and do the right thing. And then if you add in things like S I M D, or doing, you know, data parallelization as the CPU level, if that’s available, we might treat a vector of floats differently than we would on another thing.
Scott Hanselman 00:07:57 So how much information up front do we know about deployment and is it worth doing all that work on the developer’s machine? And this is the important part, which may not necessarily reflect the reality of where it’s going to get deployed. You know, my desktop does not represent a machine in Azure or Heroku or AWS. So getting up to the point where we know as much as we can, and then letting the, the runtime environment adapt to the true representation of what’s happening on the, on the, on the final machine. That doesn’t mean that we can’t go and do native compilation, or what’s called end gen or native image generation that if we know a whole lot, but it provides a lot of, uh, uh, value if we wait until the end.
Jeremy Jung 00:08:44 That’s an interesting point, too, in that if we are compiling down to an intermediate language on our own development machines, then we don’t have to worry about like all these different targets, right. Of saying, I’m going to build for this specific type of arm processor, you know, all these different places that our application could possibly go because the runtime is taking care of that for us.
Scott Hanselman 00:09:06 Right. And I think that’s one of those things where it’s taking care of it for us, unless we choose to, it reminds me of the time. If you remember, when we went from, you know, mostly manual shift cars to automatic shift cars, but people who bought fancy Audis and BMWs were like, you know, when I’m going to the shops to get groceries, I’m cool with automatic, but I really like the ability to downshift. And then we started to see these hybrid cars that had, you know, D and R for drive in reverse, and then a little move left and move right. To take control. And like, I’m going to tell the automatics, you know, transmission on this car that I really want to run@ahigherrpms .Net tries to do that. It gives you both the ability to just say, you know, do what you’re going to do. I trust the defaults, but then a ton of switches, if you choose to really know about that ending environment…
Jeremy Jung 00:09:59 And talking about the common language runtime, which I believe you said as the equivalent of the Java virtual machine, you also mentioned how there are languages that are built to target the intermediate language that, that runtime uses, like C and VB and things like that. And you touched on this earlier before, but I feel like we haven’t quite defined what .Net really is like, is it that runtime and then so on?
Scott Hanselman 00:10:26 Yeah. Okay. My apologies. Yeah. Okay. so .Net, as an, as an all-encompassing marketing term, I would say is the ecosystem just as Java is a language and also an ecosystem. So when someone says, I know .Net, I would assume that they are at the very least familiar with C. They know how to compile code and deploy code. They might be able to be a website maker, or they might be an iPhone developer. That’s where .Net starts getting complicated, because it is an ecosystem. Someone could work, let’s say two people could work for 10 years in the ecosystem. And one could be entirely microservices and containers on the backend in the cloud. And the other person could be Android and unity and games and X-Box, and they are both .Net developers, except they never touched each other’s environment. One is entirely a game and mobile app developer. And the other one is entirely a backend developer.
Scott Hanselman 00:11:19 That’s where it’s harder. Now. I think the same thing is true in the Java world. Although I would argue that you would, you’d be surprised how many places that you can find .Net, whether it be in a Python notebook, you can run .Net and C and an IPY MB and a notebook and Jupiter on, you know, on the Google cloud. Or you can run it on a microcontroller, not a microprocessor, but literally on a tiny 256 K micro controller, all of that is, is .Net. now .Net is also somewhat unique amongst ecosystems in that it has a very large what we call BCL base class library. One of the examples might be that we know with a Python or with a JavaScript, you say console dot log, hello world. We got the same thing. And then it’s like, Hey, I need a really highly optimized, a vector of floats with a complicated math processing.
Scott Hanselman 00:12:10 Well, you have to go and figure out which one of those libraries you want to pull in. Right? There’s lots of options in the Python world. There’s lots of ops in the Java world, the JavaScript world, but then you have to go hunting for the right library. You have to start thinking Microsoft, I think is somewhat more prescriptive in that our base class library, the stuff that’s included by default as everything from regular expressions to math, to representations of memory all the way up to putting buttons on the screen. So you don’t always have to go out to the third party until it’s time to get into higher level abstractions. And that has made .Net historically attractive to enterprises because when you’re picking a framework and it has a whole ton of ecosystem, things, who do you throttle when it doesn’t work? Right? There’s an old joke that people picked IBM because they got it, gave them one throat to choke people who are an enterprises typically will buy a Microsoft thing and then they’ll buy a support license. And then they can call Microsoft when it doesn’t work. Now in the fast forward 20 years, Microsoft has a balance between a strong base class library and enrich open-source environment. So it’s a little bit more complicated, but the historical context behind why Microsoft ended up in enterprises is because of that base class library and all of those libraries that were available out of the box. And
Jeremy Jung 00:13:28 In direct contrast to something like say JavaScript, where people are used to going to the node package manager and getting a whole bunch of different dependencies that have been developed by other people. It sounds like with .Net, the philosophy is more that Microsoft is going to, to give you most of what she’ll need. And you can sort of stay in that, in that environment.
Scott Hanselman 00:13:53 I would say that that was the original philosophy. I would say that that was pre open source Microsoft. So maybe 10 and 15 years ago, I would think that that is not a philosophy that is very conducive to a healthy, open source ecosystem, but it was early on when it was like, here’s a thing you kind of buy, you didn’t really buy it, but like it comes with windows and you buy visual studio. When I joined about 13, 14 years ago, myself and others are really pushing open source because we came from the open source community. And as we started introducing things like Azure and services .Net is free, has been free, is now open source visual studio code, visual studio community are all free. So the stuff I work on, I actually have nothing to sell as such. It’s better to have a healthy community.
Scott Hanselman 00:14:40 So we have things like new get so new, get, and UGT is the same as NPM is the same as Maven. It’s our package manager environment. And that is, uh, allows you to pull Microsoft libraries and third-party libraries. And we want to encourage an open source community that then, you know, pays open source framework creators for their work uses things like get hub sponsors, people who are working in enterprises. Now need to understand that if you pick just the stuff that Microsoft gives you out of the box, you may be limited in the diversity of cool stuff that’s happening. But if you go and start using open source technology, you might need to go and pay a support contract for those different tools or frameworks, depending on whether it’s a, you know, a, a reimagination of asp .Net or web framework. And you say, I don’t like the one Microsoft has, I’m going to use this one or an OAuth identity server that Microsoft does not ship out of the box. It’s a missing piece. Therefore use this third-party identity server.
Jeremy Jung 00:15:38 Are there some things that you or Microsoft has done to encourage people to build open source stuff for done?
Scott Hanselman 00:15:46 Yeah. Well, early on Microsoft was, you know, attempted to open source .Net by creating a thing called rotor, R O T O R, which was a way of saying, Hey, Java, everyone in, in, in academia is using Java. We have one too, but it didn’t exist. The only real open source licenses as a time where GPL. So Microsoft made a very awkward, this is about 20 years ago, very awkward overture, where it’s like, here’s a zip file with a weird license that Microsoft made called the MSPL, the Microsoft permissive license. And here’s a kind of a neutered version of .Net that you could potentially use. And it wasn’t source, it wasn’t open source. It was source opened. It’s like, here’s a zip file. Like, go, go play with this. There were no takebacks fundamentally, Microsoft was not a member of the open-source community. They were just like, Hey, look, we have one too.
Scott Hanselman 00:16:38 When we started creating asp .Net MVC, the model view controller stuff, which is kind of the Ruby on rails for .Net. The decision was made by a bunch of folks on the team that I worked on and encouraged by me and others who think like me just open source to think and do takebacks it’s it’s not just, Hey, there’s Hey, you can watch us write code and do nothing about it. But the take backs is so important. The rise of GitHub and social coding enabled that even more. So now actually about 60% of .Net comes from outside Microsoft. It is truly collaborative. Now Microsoft used to patent a bunch of stuff and they’d patent stuff all over the place, and everyone would be worried. I don’t want to commit to this because it might be patented. But then they made the patent promise to say that any of the patents that covered .Net won’t be things that will be enforced.
Scott Hanselman 00:17:25 And then they donated .Net to the .Net foundation, which is a third party foundation, much like many other open-source foundations and .Net and all of the things within it, the logos and the code and the copyrights are all owned by that. So if Microsoft, God forbid were to disappear or stop caring about .Net, it is the communities that can be built and deployed and run entirely outside of Danette it’s overtures like that. To try to make sure that people understand that this isn’t going anywhere, it’s truly open source and then take backs is such a big thing. And this has been going on now for, for many, many years, most people who think .Net and probably the folks that are listening to the show are thinking the big giant enterprise monolith that only runs on windows that came out in the early two thousands. Now it is a lightweight, cross-platform open source framework that runs in containers and doesn’t Linuxes and raspberry pies. It’s totally open. And it’s totally open source all the way down. The compiler’s open source, all the libraries, everything.
Jeremy Jung 00:18:23 To your point of people picturing .Net being closed source running only on windows. I think an important component to that is the fact that there have been multiple .Net runtimes, right? There’s been the framework there’s been core. There’s been mano. I wonder if you could elaborate a little bit on what each of those are and what role they fit n today?
Scott Hanselman 00:18:47 That is a very, very astute and important observation. So if I were to take Java byte code, I’ve taken Java source code, and I’ve turned it into Java byte code. There are multiple Java runtimes, Java VMs that one could call upon it’s from Oracle, there’s Zeus, and there’s different open source, open JVMs and whatnot. There are even interpreters. You can run that through a whole series of them. There’s X. You can imagine a pie chart of all the different Java VMs that are available. Now, certainly there’s the 80% case, but there are lots of other ones. The same thing applied in the .Net ecosystem. There is the .Net framework that shipped and ships continually still with windows and the .Net framework and its associated CLR, I would say is a, and I’m putting my fingers in quotes here, a .Net. But to your point, there are multiple dot nets.
Scott Hanselman 00:19:40 Plural mano is a really interesting one because it is an open source, clean room reimplementation of the original windows based .Net and clean room in that they did not look at the source code. They looked at the interface. So I said to you, Jeremy, here’s the interface for system dot string, right? Me and implementation of this interface here are the unit tests and you wrote yourself Jeremy specific system, not string. And it, it worked, it passed all the tests. Now, you know, who knows under load, it might behave differently. But for the most part, you made a, a clean room reimplementation of that. Mano did that for all of .Net proper, but then that became a new .Net. So for those that are listening, they can’t see us or see a screencast. But imagine that I go out to the command line and with a Microsoft implementation of .Net, I make a new console app.
Scott Hanselman 00:20:36 It says, console dot write line. Then I compile it into an executable. I can then run that with mano. So I created it on one environment and ran it with another. So I, I did the compilation and the first, the first bit of chewing, and then the finally the jitter would run through mono because the L language is itself a standard that has been submitted to the standards organizations. And it is a thing. So if you and I were, uh, you know, advanced computer science students in university, that might be an interesting homework assignment, write a interpreter or write an ill jitter. And if you can successfully consume aisle that has been created by one of these many dot nets you have passed the course then .Net core is a complete reimplementation opensource cross-platform with no specific ties to windows. And that’s the .Net that has kind of, we’re hoping will be rebranded just .Net.
Scott Hanselman 00:21:37 So five years from now, people won’t think about .Net core .Net framework. They’ll just think about .Net. It will run great on windows. It’ll run great on Linux. It’ll run great in the cloud, yada yada yada, that is a kind of a third .Net. We’re trying to unify all of those with the release of .Net five, which just came out and .Net five. We pick the number because it’s greater than four, which was the last version of .Net on windows. But we also skipped a number because .Net poor three would have been confusing. If we named it done at core four. Again, Microsoft not being good at naming stuff. You imagine two lines heading to the right .Net framework and .Net core. They then converge into one .Net. The idea being to have one CLR, one common language runtime, one set of compilers and one base class library. So that if someone were to learn that if we harken back to the middle of the beginning of our conversation, when I said that there was a theoretical .Net developer out there, who’s a gamer and there’s another one who’s doing backend work.
Scott Hanselman 00:22:40 They should be using the same libraries. They should be using the same languages. They should have a familiarity with everything up to, but not including the implementation specific details of their systems. So that if a unity person or a, uh, decided to become a backend developer or a backend developer decides move over to make iPhone games, they’re gonna say, oh, this is all the system got this and that stuff I’m familiar with. That’s a system about string. I appreciate that. As opposed to picking an iPhone or an Android specific implementation of a library.
Jeremy Jung 00:23:10 If .Net core is the open source reimplementation of the dynamic framework. And you’ve also got, you were talking about how mano is this clean room implementation of it? What role does, does mano play? Correct?
Scott Hanselman 00:23:25 Good question. So mano was originally created by Miguel de Caza and the folks that were trying to actually make an outlook competitor on Lennox at then turned into the Xamarin company, X a R I U M, and Xamarin then was a different reimplementation, which allowed them to do interesting stuff like can take that aisle and send it over to doing a thing called SGN and generating code that would run on an iPhone or code that we run on an Android and they created a whole mobile ecosystem and then Microsoft bought them. So then, because motto and .Net work on the same team we’re getting together right now, and we’re actively merging those together. Now, originally motto was really well known that it was just nice, solid, clean C code. You could basically clone the repo run configure run make, and it would build while the windows implementation of .Net core and .Net core in general, wasn’t super easy to build it.
Scott Hanselman 00:24:22 Wasn’t just a clone configure and make a lot of work has been done to make the best parts of mano be the best parts of .Net core, as opposed to like disassembling one and, you know, taking them apart and making this Frank and build, we want to make it. so .Net core is, is a, a re-imagining of both original Danette framework and windows and the best of across platform one. So that is currently in the process in that .Net five .Net six wave. So this year, mid November, we were released .Net six, and that will also be an LTS or a long-term support release. So those of you who are familiar with UHIN twos on sort of LTS those long short long-term support versions will have, you know, many years, three years plus of, of support. And by then the mano .Net merge will kind of be complete. And then you’ll find the Dynacore will basically run everywhere. That motto would, that doesn’t mean motto as an ecosystem goes away. It just becomes another, not the supported version of .Net at a runtime level.
Jeremy Jung 00:25:26 Look at the Java Virtual machine, and we look at that ecosystem, there are languages like Scala and closure things that were not made by the creator of the JVM, but our new languages that target that runtime. And I wonder from your perspective why there was never that sort of community with the common language runtime.
Scott Hanselman 00:25:50 I would think that because the interest from academia early on 20 years ago was primarily around Java and Microsoft was slow on the uptake from an open source perspective that slowed down possible implementations of other languages. And then .Net got so popular and C evolved. Cause C# is now on version nine, the C# that you wrote the idiomatic C of 2001 is not the idiomatic C with includes, you know, records and async and await and interesting things that have shown up on C and then been borrowed by other languages, asynchronous wiping a great example, link language, integrated query, being another things that didn’t exist, that language has evolved fast enough, that people didn’t feel that it was worth the effort. And it was really F# that picked an entirely different philosophy in the, in the functional way, by doing kind of an old camel style thing. And because C and F# are so different from each other, they really fit nicely. There is different as English and another language that isn’t Latin based, you know, and that meaning that they add flavor to the environment. That doesn’t mean that there aren’t going to continue to be niche languages, but there was also things like iron, Ruby and iron Python, but they weren’t really needed because the Python and Ruby runtimes already worked quite well.
Jeremy Jung 00:27:08 We’ve been talking about .Net and sort of the parts that make up .Net, but I was wondering other languages have niches, right? You have go maybe for more systems type programming or Python for machine learning. Like, are there initials for .Net?
Scott Hanselman 00:27:26 Oh yeah. I mean, so when I would, I would, I would gently push back on the idea of niche though, because I don’t want to use niche as a diminutive. Right. I kind of like the term domain specific, just in the sense of, you know, you know, when in Finland speak Finnish, that doesn’t mean that we would say, Hey, you know, finished didn’t win. Like we’re not all speaking. It’s not the, it’s not the language that one, but we don’t want to think about things like that. There are great languages that exist for a reason because people want to do different stuff with them. So for example, a really well thought of language and the .Net spaces F# and F# is a functional language. So for people who are familiar with OCaml and Haskell and things like that, to people who want to go and create a language that is, you know, very correct, very maintainable, very clear that has a real focus on you managing the problem domain, as opposed to the details of imperative programming. It has immutable data structures by default. There’s a lot more type in, for instance, there is in C. A lot of people use F# in the financial services industry. And it also has some interesting language features like records and discriminated unions that C people are just now kind of getting hip to.
Jeremy Jung 00:28:38 what I typically see or what I think people sort of believe when they think of .Net as they think of enterprise applications. And I’m wondering if you have some examples of things that are sort of beyond that space.
Scott Hanselman 00:28:53 Sure. So when I think of .Net, like in the past, I would think of like big windows apps with giant rows of tabs and text boxes over data. You know, if I go to my eye doctor and I see the giant weird application that he’s running, that’s multiple colors and I not have grids and stuff. And I think, oh, that must be written in .Net. Those are the applications of 20 years ago. The other thing that I think people think about when they think about .Net is it’s a thing that is tied to windows and built on windows and probably takes about gigabytes of space .Net core is meant to be more like node and more like go than it is to be like .Net framework. So for example, if I were to create a micro-service using .Net core, I go out to the command line and I type .Net, new web or .Net empty or .Net new console.
Scott Hanselman 00:29:43 And then I can say, .Net publish and I can bring in a runtime. And we talked before about how you could keep things very non-specific until the last minute and let the runtime on the deployed machine decide. Or you could say, you know, this is going to a raspberry PI, it’s going to be a microservice on a raspberry PI. I want it to be a smallest. So there’s multiple steps we’ve gone to, we made this little microservice and we published it. Then we publish all of them. The support DLLs, the dynamic link libraries, the shared objects, if it’s going the Linux, all of the native bindings that, that provide that binding between the runtime and the native processor and the native operating system, all the system calls then that is right now, about 150, 180 megs on .Net. But then we look at the tree of functioning calls and we say, you know, this is a microservice.
Scott Hanselman 00:30:33 It only does like six things. It looks at the weather, it calls like six native functions. Then we do what’s called tree trimming or trees shaking. And we shake, we give it a good shake. And then we basically delete all of the functions that are never called. And we know those things that’s right. We can, we can introspect the code and we can shake this thing and we can get microservices down to 30 or 30 megs. Now, again, you might say, well, compared to go or compared to writing that in C sure. But you’re talking about still maintaining the jitter, the garbage collector, the strongly typed abilities of .Net, all of the great features of this cool environment shaken down to, you know, 30, 40 megs. And then you can pack that tightly into a container, even better if the container layer above it. And if you imagine a multi-stage Docker container doesn’t include the compiler, doesn’t include the SDK and the container above.
Scott Hanselman 00:31:26 It includes the runtime itself. You might only deploy and 15 megs. You can really pack nicely together microservice, and then a whole series of them. Thousands of them potentially into something like Kubernetes. That’s a very fundamentally different thing than the giant .Net application that took two gigs on your, on your hard drive. This is the cool part though. At giant, we call it windows forms or that WPF, that windows presentation application that, um, often we find in large enterprises moves slowly because the at not, not running lowly, but move slowly from an om from a dev ops perspective because the enterprise is afraid to update it, or they need to wait for windows to get the version of .Net they want because .Net has historically been tied to windows, which sucks then that application and the whole team behind it gets depressed. What if we could take the cool benefits that I just described around containers back port it, so that, that giant application at my doctor’s office ships its own local copy of .Net, which it can then maintain, manage, and deal with it’s okay, it’s on its own.
Scott Hanselman 00:32:36 All in a local folder, doesn’t need to wait for windows. That’s really cool. Then they could do that. Rejigging basically do a native image generation and even create a single executable where inside is .Net. So then I give you my doctor’s office dot exe. You double click on it, you install nothing. It simply unfolds like a flower into memory, including all of the benefits. Now it’s not generated native code at this point, right? It’s dot net in an envelope that then blooms and then runs with all native dependencies that it needs. That is pretty cool. And that actually regenerates in excitement in the enterprises so that they can bring those older applications to modern techniques like dev ops and as well as a huge, huge perf up like two X, three X per speed. Up.
Jeremy Jung 00:33:27 When you talk about a perf speed up, why would including the .Net runtime with the application result in a purse Speedo?
Scott Hanselman 00:33:35 It’s not that we’re including the, the, the .Net runtime that caused the perv speed up. It’s that 20 years of improvement in jitter, 20 years of understanding the garbage collector, rather than using the .Net that shipped with windows, they can use the one that understands, again, a call back to the beginning instruction sets that are newer and modern S I M D SSE to all the different things that one could potentially exploit when on a newer system, those things are, we get huge numbers and actually .Net itself done at five is like two or three X over .Net core three, which is two or three X over. So a huge push has been happening and actually all the benchmarks are public. So if you go to tech M power, the tech E M power benchmarks, you can see that we’re having a wonderfully fun kind of competition, a bit of a thumb war with, you know, the NGOs and the Java’s and the, you know, groovy on rails of the world to the point where we’re actually bumping up against the laws of physics. We can put out, you know, seven or 8 million requests a second. And then you notice that we all bundle@thetopand .Net kind of moves within a couple of percentage of another one. And the reason is, is that we’ve saturated the network. So without a 10 gigabit network, there’s literally nothing, no more bites can be pushed. So dot-net is no longer in the middle or to the far right of the, uh, of the long tail of the curve we’re right up against anything else. And sometimes as fast as 10 X faster than things like node.
Jeremy Jung 00:35:02 So it sounds like going from the .Net framework to .Net core and rebuilding that you’ve been able to get these giant speed improvements. You were giving the example of a windows desktop application and saying that you could take this that was built for the .Net framework and run it on .Net core. I’m wondering, is that a case where somebody can just take their existing project, take their existing code and just choose to run it? Or is, is, does there have to be some kind of conversion process?
Scott Hanselman 00:35:33 So that’s a great question. So it depends on if you’re doing anything is like super specific or weird. Like if you were a weird application, then, then you might bump up against an edge case. The same thing, think the same thinking applies. If you were trying to take an application cross-platform or example, I did a tiny mini virtual machine and an operating system for a advanced class in computers, 15, 20 years ago, I was able to take that application. It was written and compiled and .Net 1.1 and move it to done at core and run in a container and then run around as Berry pie, because it was completely abstract. It was using bite arrays and list of tea and kind of pretty straightforward based class library stuff. It didn’t call the registry. It didn’t call any windows, API APIs. So I was able to take a 15 year old app and move it in about a day.
Scott Hanselman 00:36:27 Another example, my blog, which used to run on .Net to my blog has over 19 years old now has recently been ported from .Net two to four, then .Net core. And now .Net five runs in the cloud in Linux, in a container with 80% of the code, the same, the stuff that isn’t the same that I had to actually consciously work around with the help of my friend mark Downey was well, we called the registry. The registry is a windows thing. It doesn’t exist. So what’s the what’s the implement patient is at adjacent file. Now is in an XML file when it runs in a container, it needs to talk to a certain map to file system things. Well, before it was assuming backsplashes or a C colon. So implementation details need to move over. Another thing that is interesting to point out though, is that there are primitives, there are language and runtime primitives that didn’t exist before that exists now.
Scott Hanselman 00:37:21 And one of the most important one is a thing that’s called span of T span, less than uppercase T greater than. And this is the idea of a completely new way of thinking about arbitrary, continuous bits of memory. Do you want to be at a high level language and then messing around and bite or res, or do you want to think about things at that higher level, but then also avoid reality occasion and copying of memory around. So something very simple, like some HTTP headers come in, if you’re doing 7 million of these, a second, this can add up, right? And it’s like, well, usually we take a look at that chunk of it Emory, and we copy it into an array. And then we start using they’re level constructs to deal with that. Now I have a list of char and then we for-loop around the list of char that’s kind of gross.
Scott Hanselman 00:38:10 And then you find out that you’re in the garbage collector a lot because you’re allocating memory and you’re copying stuff around. You could take that older code, update it to use span of T and represent that contiguous region of arbitrary memory differently rather than an array. The span can point to native memory or even memory manage on a stack and then deal with stuff. For example, parsing, maneuvering within HTTP headers with no allocations. So a really great example, you’d ask for an example of an application that you couldn’t believe, VR desktop. Are you familiar with VR desktop as it relates to the Oculus quest? No. So the Oculus quest is the Facebook VR thing, right? And it’s an Android phone on your face and it’s, you can use it unplugged. And then people say, well, I got this Android phone in my face. I’d really like to plug it in with a USB cable and use the power of my desktop.
Scott Hanselman 00:39:04 But then I got to ship those bits across the USB and then have a client application that allows me to use it as a dumb client. You would expect an application that someone would write to do that would be written in C or C plus plus or something really low level VR desktop allows you to actually see your windows, desktop and ship those bits across the wire, across the literal wire, the USB or wirelessly is written entirely in C. And you can use really smart memory allocation techniques. And the trick is don’t allocate any memory and C is more than fast enough to have less than 20 milliseconds jitter on frames so that it is buttery smooth, even over wireless. And I did a whole podcast on that with the giga, the Canadian gentlemen who wrote VR desktop.
Jeremy Jung 00:39:51 It’s really interesting because you’re talking about areas where typically when you think of a, a managed language, like C, you’re able to use it in more environments than you, you might normally think of. And I also kind of wonder you have the new apple machines coming out. They have their arm processors instead of the x86 processors. What is the state of .Net when targeting an arm environment? Can somebody simply take that aisle that’s on one machine, bring it on to the, our machine and it just works.
Scott Hanselman 00:40:28 Yep. So if you are putting, if you’re taking over the, the, I L and I’m on a windows machine right now, I’m on an X 64 machine, and I go, .Net new console and I go, .Net run. And it works on my X 64 machine. And I say, .Net publish. I can then take that, that library over to the raspberry PI or an arm machine say, .Net run. And because I’m saying, .Net run with the local .Net runtime, it will pick up that aisle and it will just run. So I have run using my now 1920 year old blog, as an example, I have run that entire blog on a raspberry PI unchanged. Once I had worked out the portability issues like backsplashes versus forward slashes and assumptions like that. So once the underlying Cisco’s line up, absolutely. And we actually announced in July of 2020, that we will support .Net core on the new Mac hardware. There are requirements for .Net and .Net core on apple, like arm 64 and big sir, that would be required to get that runtime working. But yes, the goal would be to have native processes versus Rosetta to processes working. And that work is happening .
Jeremy Jung 00:41:41 Talking about like the typical enterprise application. You’ve got a windows forms application. Is it possible for somebody with an application like that to, to target arm?
Scott Hanselman 00:41:54 So right now there is there’s multiple layers. So the compiler yes. The runtime, yes. The application. Yes. At the point where if I were going to run on windows arm, like a surface pro X or something like that, we would need support for, I believe windows forms, wind forms and WPF. I don’t know that those are working right now, but those apps still run because just like we have the, the Rosetta emulator, I can emulate X six x86 stuff. So for example, paint .Net is a great .Net application that is basically Photoshop, but it’s four bucks that it runs entirely on .Net core. And it runs just fine on a surface pro X in an emulated state. And I believe that the intent of course is to get everything running everywhere. So, yeah, I would be sad if it didn’t, that’s a little outside my group, but the people that are working on that stuff.
Scott Hanselman 00:42:40 And by the way, the great thing about this go and look at the GitHub issues, right? So, you know, if you look on, I’m looking right now on a .Net issue, 48, 79, where they’re talking about the plan is supporting .Net core three and five on Rosetta to via emulation. And .Net six supported in both native and one architecture and Rosetta two. And there’s in fact, a .Net runtime tracking issue. That’s called support apple, Silicon. And they walk through where they’re at current status on both mono and .Net six. It’s cool because you get to like, actually see what we’re doing, right? Like before you had to know somebody at Microsoft and then call your friend and be like, Hey, what’s going on? We are literally doing the work in, open on GitHub. So if the, if the tech journalists would pay more attention to the actual commits, they would get like scoops weeks before an blog post came out, because you’re like, I just saw that, you know, the check-in for the Apple Silicon show up in the .Net, but it might get a little technical for the average journalist though.
Jeremy Jung 00:43:38 One of the things that you’ve been talking about is how with .Net core, you have a lot of cross platform capabilities. I wonder from an adoption standpoint, what you’ve seen, like are there people actually running their services and Linux and Docker, Kubernetes, that sort of thing.
Scott Hanselman 00:44:00 Yeah. Dot net. One of the things that we try to make sure that it works everywhere. So we’ve seen huge numbers, not only on Azure, but AWS as a very burgeoning non-IT community, as well as their SDK is all work on .Net. Same with Google cloud. We’re trying to be really friendly and supportive of anyone because I want it to run everywhere. So for example, at our recent .Net comp, which is our little virtual conference that we make, we had Kelsey Hightower from Google cloud, like their main Google cloud, Kubernetes person learn .Net in a weekend and then deploy to on Google cloud. Uh, we’re seeing a huge uptick on .Net five. So that unified version where we took .Net core and the .Net framework and unified them, it’s the most quickly adopted .Net ever. I mentioned before that like 60% of the commits are coming from outside the community.
Scott Hanselman 00:44:50 We’re seeing big numbers, you know, stack overflow is moving to dot, has moved to down at core. They’re actually showing their perf most of the games that you run are already running on .Net. And, you know, if you see a unity game, there’s dot net and C running in that a lot of the mobile games that you’re seeing, one of the other things that we’re noticing is that more and more students and young people are getting involved. So we’re really trying to put a lot of work into that. One of the other things that’s kind of cool that we should talk about before the end is a thing called blazer. Have you heard about that? And maybe you could explain it to our audience. So just like, um, if we use Ruby on rails, as an example, I like to use other frameworks as an example, like builds cool stuff on top of it.
Scott Hanselman 00:45:28 So it’s like you pick your Ruby, whether it be J Ruby or in Ruby or whatever. And then you’ve got your framework on top of that and then other frameworks, and then you layer in your layer and your layer .Net has this thing called asp .Net active server pages. Doesn’t it, it’s a stupid old name. You can make web APIs that are Jason and XML based API APIs. You can make standard model, view controller type environments. You can do a thing called razor pages where you can basically mix and match C and HTML. But if you want to do those higher level enterprise applications where you just don’t want to learn Java script, we’ve actually taken the CLR and compiled it to Wassom WebAssembly and we can run the CLR inside V8. But then if you actually hit up 12 tools on a blazer page, laser is bla Zed, O R hit F 12.
Scott Hanselman 00:46:21 You go, and you hit a blazer page. You can see the DLLs, the actual dynamic link libraries coming over the wire. And then the intermediate language that we’ve been talking about so much on this podcast gets interpreted on the client side, which allows a whole new family of people that already know C#. Like those individuals that we spoke to spoke about at the beginning, you’ve got someone with 10 years experience in unity and someone else got 10 X years experience on the backend. I never got around to learning JavaScript. They can write C, they can target the browser. And then the browser itself runs .Net. And then blazer allows them to create spa applications. Single-page applications much like Gmail and Twitter and PWAs, progressive web apps. So one could go and create an app. And rather than an electronic kind of an app, which is using JavaScript and a whole host of tools, they can make a blazer app, have it run natively anywhere. They can then pin it to their mobile phone or their taskbar on windows. And they’re, they’re suddenly a web developer, and it’s a really great environment for those big enterprise applications or those more line of business type apps, because the data is just so clean and then that back end can be anything. So laser is a really great environment and a pretty interesting technical achievement to get .Net itself running within the context of the browser.
Jeremy Jung 00:47:41 That means that somehow you’ve been able to fit the .Net core runtime in web assembly. I’m trying to understand how that works.
Scott Hanselman 00:47:50 Yep. That’s exactly. That’s exactly right. So remember how we mentioned before that this isn’t the multi gigabyte thing that everyone is so afraid of, you basically bring down, I think it’s like 15 or 20 megs, which is, you know, a little bit big, but if you think about the homepage of the verge, it’s not that big, right. I’ve seen P and G is bigger than the .Net runtime. Once you bring that down, of course, if you put that on a, on a CDN that’s handled, I think it’s actually even smaller than that. It’s not that big of a deal because once it’s down, it’s cashed. And that is really the .Net core, you know, mano runtime running within the context of web assembly. And then you’re just calling local browser things. But here’s the cool part. Let’s say you don’t like any of that, let’s say I’ve described this whole thing.
Scott Hanselman 00:48:31 You liked the application model. I want to write C, but you don’t want to download and like put a lot of work into getting the local CPU and the local V8 implementation to do that. You can actually not run the .Net framework and the .Net core rather, pardon me on the client side, but you can have it run on the server side and then you open a socket between the front end and the backend, but then the events that occur on the client side get shuttled over web sockets to a stateful server. So there’s blazer, which is client side, and then there’s blazer server, which means it can run anywhere on any device. So then it’s more of a programming model thing. You still don’t have to write any JavaScript because you’ll be addressing the Dom the document object model within the browser, from the server side, the messaging then goes magically over the web sockets. You basically, you have a persistent channel bus running between the front end and the backend. So you get to choose.
Jeremy Jung 00:49:37 We did a show on Phoenix live view, and it sounds like this is a very similar concept, except that you get the choice of having that run in the server or rent locally.
Scott Hanselman 00:49:49 Yeah. And I think the folks on Ruby on rails are doing similar kinds of things. It’s this idea of, you know, bringing HTML back, maybe getting a little less JavaScript heavy, and really thinking about shoving around islands of marked markup. Right? If I have a pretty basic, you know, master detail page and I click on something and I just want to send back a card is that really need to be a full-blown react view angular application. This is the idea is you, you make a call to get some data ship the HTML back and you swap out a div. So it’s trying to find a balance between too much JavaScript and too many post backs. And I think it, it hits a nice balance. Blazer is seeing huge pickup, particularly in people who have found JavaScript to be somewhat daunting.
Jeremy Jung 00:50:35 I think we’ve been talking about things that are a little more cutting edge in terms of what’s happening in the .Net ecosystem, things like web assembly. What else are Microsoft’s priorities for the future of .Net? Are you hoping to move into some more ahead of time compilation environments, for example, where you need something really small that can run on IOT type devices. What’s the future of .Net from your perspective,
Scott Hanselman 00:51:04 All of the above. If you take a look@themicrosoft .Net IOT repository and get hub, we’ve got bindings for dozens and dozens and dozens of sensors and screens and things like that. We have partnerships with folks like high-top. So if you’re teaching .Net, you can go in inside of your browser in a Jupiter, kind of an environment, go and communicate with actual physical hardware and call GPIO general purpose IO directly. We’re also partnering with folks like wilderness labs, which has a wonderful implementation of .Net based on motto that allows you to write straight C on a tiny micro processor, not a three micro controller, pardon me, rather than a microprocessor and create, you know, commercial grade applications, like a, you know, uh, a thermostat running in .Net, which again, takes those different people that I’ve mentioned before, who have familiarity with the ecosystem, but maybe not familiarity with the deployment and turns them into IOT developers.
Scott Hanselman 00:52:03 So there’s a huge group of people that are thinking about stuff like that. We’ve also seen 60 frames, a second games being written in the browser using blazer. So we are finding that it is performant enough to go and do you know, we’ve seen gradients and different games like that. Being implemented using the canvas with laser server, running at its, uh, at its heart. The intent is for it to be kind of a great environment for everyone anywhere. And then if you go to the .Net website, which is@dot .Net dot .Net, we can actually run it in the browser and write the code and hit run. So you can learn .Net without downloading anything. And then there’s also some excitement around .Net interactive notebooks, which allows you to use F# and C in Jupiter notebooks and mix and match it with different languages. You could have JavaScript, dethroned JS, some SBG visualizations using C all in the browser entirely in the, uh, in the Jupiter notebooks IPY and B ecosystem.
Jeremy Jung 00:53:05 So when you talk about .Net everywhere, it’s really increasing the number of domains that you can use Donnette in like, be the person who maybe you built enterprise windows applications before, but now you’re able to take those same skills. And like you said, make a game or something like that.
Scott Hanselman 00:53:24 Bingo. Exactly. It doesn’t mean that you can’t or shouldn’t be a polyglot, but the idea is that there’s this really great ecosystem that already exists. Why shouldn’t those people be enabled to have fun anywhere?
Jeremy Jung 00:53:38 I Think that’s a great note to end on. So for people who want to check out what you’re up to, or learn more about .Net, where should they head?
Scott Hanselman 00:53:47 Well, they can find me just by Googling for Hanselman, Google, with being, if it makes you happy, everything I’ve got is linked off of hanselman.com. And then if they’re interested in learning more about .Net, they can go to just Google for .Net and you’ll find .Net.microsoft.com within the download page. You’ll see that we work on Mac Linux, Docker windows. If you already have visual studio code, just download the .Net SDK, go to the command line type .Net, new console, and open it up. And visual studio code vias code will automatically get the extensions that you need and you can start playing around. Feel free to ask me any questions. We’ve got a whole community section of our website, whether it be stack overflow or Reddit or discord or code newbies or tick-tock we are there and we want to make you successful.
Jeremy Jung 00:54:32 Very Cool. Well, Scott, thank you so much for chatting with me today.
Scott Hanselman 00:54:35 Thank you. I appreciate your very deep questions and you clearly did your research and I appreciate that.
Jeremy Jung 00:54:41 This has been Jeremy Jung for Software Engineering Radio. Thanks for listening.
[End of Audio]
SE Radio theme: “Broken Reality” by Kevin MacLeod (incompetech.com — Licensed under Creative Commons: By Attribution 3.0)
Very informative, thank you!