DevQuestions with Tim Corey
I am Tim Corey. I teach coding online and my inbox is full of questions from current and future developers. I wish I could sit down with each of you and share the answers I know will help you go further, faster in the world of development. This podcast is the next best thing. On this podcast, I will answer the biggest questions people are asking! Send us to your suggestion for a future Dev Questions at https://suggestions.iamtimcorey.com/ To keep the podcast coming, like, subscribe, rate, and share it with your friends and colleagues. See why thousands of students have chosen to learn to think and code like a professional developer at www.DevForge.com.
DevQuestions with Tim Corey
164 What is the Future of Blazor?
Use Left/Right to seek, Home/End to jump to start or end. Hold shift to jump forward or backward.
Should I learn a JavaScript framework or concentrate on mastering Blazor? What is the future of Blazor? Is Microsoft invested in making Blazor great? We will answer these questions in today's Dev Questions episode.
Website: https://www.DevForge.com/
Ask Your Question: https://suggestions.iamtimcorey.com/
Sign Up to Get More Great Developer Content in Your Inbox: https://signup.iamtimcorey.com/
Welcome to the Dev Questions Podcast with Tim Corey. Join us each episode as we tackle the questions you are asking about a career in software development, understanding the industry, and new technology. If you're just starting out or you want to grow stronger as a developer, this is the place to get your questions answered. Now, here's your host, expert developer and online educator, Tim Corey.
SPEAKER_02What is the future of Blazor? Is Microsoft invested in making Blazor great, or is it going to go the way of Silverlight? Let's talk about it in today's episode of DevQuestions. Now, if you have a question, go to suggestions.imtimcorey.com and ask it there, and hopefully you'll see your question answered in a future episode of DevQuestions like this one. So, what is the future of Blazor? Is it going to succeed? Is it going to be a long-term thing, or is it just a passing fad? And the answer is the future is bright. And the second question is, Microsoft invested in making Blazor great? Absolutely. In fact, if you look at the upcoming.NET release,.NET 8, you'll see that a lot of the changes that have been reported, that have been talked about, that are already in the pre-versions, the um the testing versions, a lot of those changes have to do with Blazor. In fact, there's a lot of really cool new things coming into Blazor. So let's talk more about that because why is this the thing that Microsoft is going all in on? Why is this the thing that the technology that Microsoft says, hey, this is the way to go, especially since you might not be seeing Blazor as much in the industry as let's say MVC, which is much more common. So let's talk first about why is it that Blazor is not everywhere and just you know throughout the entire marketplace? Well, the reason for that is because of time. Yes, Blazor's been around for a while. Blazor server came out with.NET Core 3.1, I believe. Um so it's been around for.NET 5, .NET 6, .NET 7. That's three full years, almost four full years. And now we're hitting our fifth year with.NET 8 and a lot more changes. So there's a lot of uh history here, but at the same time, there's something where companies, even five years, that's enough time to get started and get some momentum. And we do see a lot of companies using Blazor. But at the same time, there's companies with 20 and 30 years in a software product, and they don't just change overnight. So don't expect to see, you know, don't expect to judge whether or not their market share is, you know, is large or is growing or if they're investing in it based upon just what jobs you might find in the industry right now, or the percentage of jobs, because that will grow over time, but it's uh it's definitely a lag measure, something that happens um after the fact. So, Blazor, if we look at the um the metrics, the people who are using it, the the amount of interest, the amount of people that are saying, yes, I want more of this, yes, I want to start using this, that is has gone up tremendously. And Microsoft is saying this is something that people are asking for, therefore, this is what we're investing in. So let's talk more about Blazor. So every tool has a purpose, and not every tool fits a job. So let's understand what the benefits of Blazor are so you can look at a future of Blazor and see, you know, where does it fit and what tool is this? Because it's not going to be an everything tool necessarily, although it's getting larger and larger in that category. Because Blazor is becoming less and less about a specific project and more about an ecosystem. So let's talk about Blazor. So the goal with Blazor is to have rich client-side interactivity powered by C sharp. And that's both Blazor Server and Blazor WebAssembly have the idea of running your web app on the client and giving that rich client-side interactivity that you might normally associate with Angular or React or Vue or something like that, a JavaScript framework. But it's a C sharp powered framework. So you can use the same C sharp code you're you're writing your data access with and your business logic. You can use that same code to then write your UI with and have that same interactivity. Well, Blazor Server sits on both the client and server side, which is really convenient because Blazor Server says, hey, you can write all your server-side code and act like it's a PHP or other server, MVC, other server-side code, but at the same time, you still get that rich client-side interactivity. And of course, it does that using uh Signal R to communicate between the two. So you can write code that directly talks to a database and it's okay, it's safe. So that's Blazor Server. And then Blazor WebAssembly says, hey, you might want to have an offline app or a progressive web app or a fully client-side application for, you know, maybe it makes your site more responsive that way. Whatever the case may be, that's Blazor WebAssembly and it runs fully on the client side, and yet you can still use full C sharp to do that. So that's what we have now is Blazor Server and Blazor WebAssembly. Or at least we did. And then .NET Maui said, hey, you know what? We could do web apps and desktop apps, or I'm sorry, mobile apps and desktop apps if we use some of that same Blazor server code or Blazor code. So they created Blazor hybrid, which you can use with Maui to create native desktop apps that run in a web view, but it runs all locally. It doesn't go to the server to get anything. It runs all locally. Um, and you can use that same code that you would use in a Blazor server or a Blazor WebAssembly, but now in a mobile client or a desktop app. So there's a lot of different options we have right now. They all interact well with JavaScript. So you can use JavaScript as well. You don't have to say just C sharp. You can say C sharp and JavaScript. They fit together. But now let's look at what's coming with.NET 8 to see kind of Microsoft's vision for where Blazor is going to go. Because that's important to understand when you're talking about, okay, these tools are great. I think I want to use one of those, but where's it going? Because if it's going to go to a dead end, I don't want that. And if it's going to a place I don't want to go, okay, you know, change and do something else. But if it's going to a great place, I kind of want to be on that train. And so let's talk about.NET 8.NET 8 has a few different things into it. And really what they did was they sat down and they dreamed up what could he possibly do with Blazor. One of the things they're going to offer is, and this is all pre-release stuff, so things may change as they get close to production. But one thing they're going to offer is server-side rendering. And you might say, well, we have Blazor server, right? No, that's different. Server-side rendering is completely server-side. There's no client-side aspect to it. So it's more like an MVC or a PHP, where it renders entirely on the server and then just passes down the HTML, CSS, and maybe even JavaScript if you have some, but it passes down just the completed web pages. So you can intermix your C sharp into your web page and it will render a dynamic page, but it will render on the server and then pass it down. Which, if you're not familiar with how MBC or PHP or others work, you may think, well, that seems inefficient. And in fact, it's just the opposite, usually. It's highly efficient because the client is downloading a very small, just what they need web page, as opposed to the web page plus all the code. So it is very efficient, it's very quick. And when you don't need to have that rich client-side interactivity, this is a great option because it just renders the page cleanly how you want it. So you can still have that dynamic, hey, let's pull from a database, you know, maybe our business hours. We're going to pull business hours from a database, but they're not going to change. So the client doesn't need to interact with those in a way where they get to adjust anything. So we just want to show them here's our hours. We want those hours to be changeable by changing a database entry. That's where server-side rendering is really powerful. The same is true with things like employee lists and information about your product, even can pull from a database where it can be dynamic, but at the same time, on the client side, there's no dynamic interaction. A lot of websites you deal with, mostly are going to be this static type of page where it's not going to change for you. It's not going to change for your interaction. It may change over time as hours get updated, employees get added or removed, and so on. But that's a longer term change, not a right now change. And that's where server-side rendering is really powerful. So that's one thing that's coming to Blazor and.NET 8. But then, and this is a really cool thing, specific components can be rendered as server or WebAssembly, which means you can have a fully server-side application. Maybe let's just say you are a restaurant. And so you have your welcome to the restaurant homepage. Nothing really changes there. So server-side rendering. You have your menu. Things don't change there very often. Again, not in the life cycle of that one web page. Therefore, again, server-side rendering, Pulsmith database. But then there's the order page. Well, that order page needs to be interactive. You can make that page or a component on that page interactive using Blazor Server with that Signal R connection or Blazor WebAssembly, where you have a fully offline or fully downloadable version of that interactive form. So that can be just for that page, which cuts down on the overall transmission to the client. It makes the whole page faster. And then that one component is the only thing that's that's pulling down changes and doing some rendering on the client side. So specific component rendering in either server or WebAssembly. But then there's also the idea, and this is another great idea, the ability to change the render mode at runtime. So here's the example that I've seen is that your site loads as a Blazor server application. Remember, Blazor server is it gets rendered on the server, but then when it transfers down to the client, a connection is open with Signal R. And that connection allows for real-time changes in the client to be reflected back to the server and for the server to have any changes reflected back to the client. And that connection has to be open and it has to be always online. So if you have any service disruptions, that will break the connection and can cause problems rendering your page. That's Blazor Server. Blazor WebAssembly is we download the entire application to the client. Well, the application can be two, three megabytes potentially of content. Now, if you actually look at web pages and how they render today, a lot of web pages are a lot larger than that. Your whatever news site you go to, whatever sports site you go to, those are all going to be larger than two to three megabytes in download size. But that's still a significant download. And that means that until the site is downloaded, you don't render the page effectively. Now there's some things you can do to say, hey, I'm loading. But with the render mode being able to be changed at runtime, they're saying, hey, what if you started as a Blazor server application where it's very fast to render that first page? And then in the background, you download the rest of the source code and it became a Blazor WebAssembly application, which means now it can work offline. Now it can, all the rendering happens at the client. Now you don't have to keep that connection open to the server anymore in order for the page to be properly rendered. This is a really big deal and a really nice addition. So there's a lot of new ideas coming to Blazor in.NET 8 that really push the platform forward. And again, take it from being one of two options, well, one of three now, uh server, WebAssembly, thesis for the web, or hybrid for mobile and desktop. But now we have for the web server, WebAssembly, server-side rendering, component rendering, and also that change at runtime which version you choose. So Microsoft is heavily invested in improving Blazor and making Blazor an even better product. Now, the other thing I want to point out before we go on is the fact that what Microsoft has done with all of the ASP.NET Core web application types, including Blazor, is it's open source. You can actually go to the repository and watch what they're doing in real time. You can see how they're working, what changes they're making, what issues they're working on, and so on. You can also see what choices they're making, and they're also trying to build their code off of web standard things like WebAssembly. WebAssembly is not a Microsoft thing, it's a web standard. So they're trying to make sure that they build on top of web standards. Signal R is just on top of things like Web Sockets. So it's just a wrapper around that because they're trying to make sure that they're not just saying, hey, you have to use this Microsoft specific stuff. They're saying, nope, we're gonna use web standards. That way it's broadly compatible, that way it's not going to be shut down kind of like uh Silverlight was, because you know, Silverlight required a browser plugin that a lot of browsers said, nope, we're not gonna do that anymore. And so Microsoft's kind of bind. Now they're saying this is all web standard stuff, so you really can't shut it down because this is what the web is doing. This is the web as a whole, not just Microsoft. So they really invested in making wise long-term choices with Blazor. And I think Blazor is going to become that complete ecosystem of tools for web development that allow you to not just say this one tool, Blazor, instead it's here's my toolbox called Blazor, because now inside there I have server and WebAssembly and server-side rendering and hybrid and you know, whatever tool you need, a lot of it is in there already. Not all of them, but a lot of them are already in there. So I think the key thing here is that actions speak louder than words. Microsoft can say all day, we're committed to X. We're we're definitely behind this, we're definitely behind that. But at the end of the day, they're a large company that's looking to make a profit. Their job isn't to make sure that they always follow through in every promise. Now you break too many promises, you start having problems with the community with trust. But and they're starting to build back from some of those broken promises. But I think the key here is actions. Actions speak louder than words. And this is true for anywhere in life. You know, when you when you hear a person making claims, look at what they're actually doing. Because what they do really shows what they mean or what what they're really meaning when they say something. So Microsoft has made a big commitment to Blazor and they're continuing to put more into it. So let's talk why. Why is Microsoft saying Blazor is the thing? Well, the first one is people are wanting rich web interactivity. The days of having static rendered sites that get pushed down to the client, and they're just, you know, anytime you put post a form, it goes back to the server and then brings a new page down and re-renders everything. Those days are long behind us for the standard. Yes, pages still do it. But as far as the norm for web interactivity, people want that rich interactivity that they are expecting from websites now. And so this is one of those things that provides that. This is the one thing that Microsoft does on the web that is that rich interactivity. NBC is completely server-side. API is just API, it's not even for necessarily user interaction. And then uh Razor pages, still server-side rendering. That's all it is. So, what else is there for that rich interactivity? Well, that's the Blazor suite. Okay, so people want that, and Microsoft has that. And so what people want is what Microsoft is giving them. The other thing is people are already using C. And this is a key point and something that people often miss. They say, well, you know, I have no knowledge of anything. Uh, why should I choose, you know, this over that? Well, you have to have a broader picture first because if if you just try and say, well, you know, forget everything else, which one's best, that it depends. You know, you've heard me say that a thousand times or more, because it does depend on more than just the technology. There's lots of technologies out there to render a rich web interactivity on the web. You can do that with jQuery. Should you? Probably not. Not in today's um internet, but you can. So which one is right? Well, it depends on your scenario. If you are a JavaScript shop, you're you're uh building a node and you're writing JavaScript all the time or TypeScript, I don't think there's a reason why you would use Blazor. I don't think that Blazor is the right choice, probably for you. But on the other hand, if you are a complete C sharp shop and you're writing C sharp for your data access, you're writing C sharp for your business logic, I'm not sure why you would then say, let's now add NPM and you know, Angular or Reactor View and all this JavaScript UI. It might not make sense because now you have to bring a whole new ecosystem in, a whole new set of tools, and a whole new set of everything in order to have just your UI when you could use the same C sharp code and have a much easier to build UI. Now there's still reasons. I am not saying if you're a C sharp shop, you should not use Angular Reactor View. You definitely can. There's definitely purposes for it. But I'm saying if you are making a choice today and you're just a C sharp shop, I think that Blazor is the right choice in a lot of cases because it's an easier transition into that rich client interactivity, that rich web interactivity. So, and then the third reason why, you know, why we're doing this, why Microsoft's doing this, not me personally, uh, but why is Microsoft doing this? Because options are good. And that's again something that people often tend to discount. They often say, what's the best that's the only thing that should exist? Well, guess what? That best, even those change from month to month or year to year. So should we throw things out over and over and over again? No, of course not. And what is best for you is not best for me. What is best for one situation is not best for another. So having the options are really good because otherwise I might feel forced into a corner and make bad choices and have a bad experience because I didn't really had an option to go somewhere else. So, yes, Microsoft is invested in Blazor. I think that's the clear answer here. And the question is, should you be invested in Blazor? And I think I've kind of answered that already. I think that yes, if you're a C sharp developer, you should be invested in Blazor. You should know about Blazor. You should know how to work with it, know how to build it, and know what it's doing, because I think it offers a very clear value add to you as a developer to know Blazor and to use it. I have found that I can get a project up and running complete, much, much faster with Blazor than I can with a JavaScript framework or another system like that. So if you're already in the groove of C sharp, just adding that front end of C Sharp, I think, is a good option for a lot of people. So that's my answer to the question. I hope that that answered your questions. If you have more questions, don't forget to go to the suggestion site. Otherwise, thanks for listening. And as always, I am Tim Corey.
SPEAKER_01Thank you for joining us for this episode of Dev Questions. Tim is committed to making it easier for you to become a developer. If you would like to help make more content like this possible, please like, subscribe, rate, and share Dev Questions. You can also send your questions to questions at IamtimCore.com. Until next time, remember, you are too smart and your time too valuable to waste it making all the mistakes Tim did. When you're ready to learn to think and code like a professional developer, head over to imtimcore.com and enroll in a course.