# Blazor United with Javier Nelson and Steve Sanderson

An episode of [.NET Rocks!](https://invisiblenetwork.ai/podcast/130068596), 23 Mar 2023, 52 min.

Audio: https://dts.podtrac.com/redirect.mp3/api.spreaker.com/download/episode/53305260/dotnetrocks_1838_blazor_united.mp3

What if you didn't have to choose between client-side and server-side Blazor? Carl and Richard talk to Javier Nelson and Steve Sanderson about Blazor United in its early stages of development, providing flexibility at the web component level for client- and server-side rendering. At the simplest level, Blazor United offers server-side rendering when a site is first hit so that you can load the larger client-side components over time. But deeper is the idea that some elements on your web page benefit from being client-side, and some from being server-side, and why should you have to choose only one?

## Transcript

[0:01] How'd you like to listen to dot net rocks with no ads? Easy?
[0:05] Become a patron For just five dollars a month you get access to a private
[0:10] RSS feed where all the shows have no ADS. Twenty dollars a month will
[0:14] get you that and a special dot net Rocks patron mug. Sign up now
[0:18] at Patreon dot dot net rocks dot com. Hey Carlin, Richard Here,
[0:24] As you may have heard, NDC is back offering their incredible in person conferences
[0:29] around the world, and we'd like to tell you about them. NDC Oslow
[0:33] will be me twenty first through the twenty fifth. Go to NDC Oslo dot
[0:37] com to register. NDC Copenhagen is happening August twenty seventh through the thirty first.
[0:43] Go to NDC Copenhagen dot com for more information. NDC Porto is happening
[0:49] October sixteenth through the twentieth. The early bird discount for DC Porto ends July
[0:53] twenty first. Go to Eddcporto dot com to register and check out the full
[0:58] lineup of conferences at DC conferences dot com. Hey, welcome back to dot
[1:18] net Rocks. This is Carl Franklin and this is Richard Campbell and what it's
[1:23] been a Whileston. So we recorded, but we're kind of recording this right
[1:26] up to the wire, aren't we. I love it when we have a
[1:27] show the week of that. Yeah, we live the Hopper get a little
[1:30] low. I blame myself. I was traveling a lot. Well, you
[1:34] know, can't blame me for traveling. Yeah. I went down in New
[1:36] Zealand, Australia. Then I came home for like two days, and then
[1:38] I went over to Wales. So I do not know what time zone I'm
[1:41] in. It's not a thing. I got back yesterday. I've got a
[1:45] little story for you, and that is the construction has started on my new
[1:49] home studio, which I'm affectionately calling Poop three point zero. Okay, that's
[1:53] cool. So this is in that giant garage you have, the giant garage
[1:57] Chat. It's a twelve hundred square foot ga and I'm taking up more than
[2:00] half of it with in the back and I'm gonna give it the same treatment
[2:05] that we did in New London in the originals, kind of Yeah, you're
[2:07] gonna go right again. Oh yeah, same material and everything. Oh cool.
[2:12] Yeah. So they're in there now pulling out the insulation and I'm going
[2:15] to document it on our Facebook page. That's cool, WoT Productions. All
[2:19] right, enough chit chat, let's start off with Better Know framework. Well,
[2:30] we all know what the poly project is. If you've been listening to
[2:34] this show, and if you haven't used it, you really ought to check
[2:39] it out. Polly is a tool that you can use for resilience strategies.
[2:44] So what happens when transient errors happened, your network goes down, or some
[2:49] network endpoint is busy or something like that. We started talking about it on
[2:53] dot net Rocks and then fv next became a shepherd of it. Then it
[2:57] got into the dot Net Foundation, and then Polly went into dot net two
[3:02] point one with HTTP Client Factory. So needs to say it's been a few
[3:07] years. There's we actually haven't had many updates to it for the past couple
[3:14] of years. Well, there's also a point where it's done right, Well
[3:17] you'd think it's done, but there's a bit of non trivial technical debt,
[3:24] including lack of cancelation tokens and in some operations of a lack of file a
[3:30] sync support for all callbacks, and some performance issues. So what happened is
[3:37] the dot net team built a prototype version of Polly that simplifies Polly's API surface
[3:43] area with a single eye resilience strategy interface that's responsible for executing all the poly
[3:51] scenarios and addresses the performance issues with excellent results. In fact, in the
[3:55] early test, the new changes resulted in CPU overhead reduction of eighty percent.
[4:00] That's nice numbers. Yeah, And additionally the proof of concept significantly reduced allocations
[4:06] by large factors. So these are all great optimizations. What's interesting is that
[4:14] it's completely backward compatible and it hasn't happened yet. So what happens is Joel
[4:19] Human has written this blog post that we're going to link to, and this
[4:24] is eighteen thirty eight, So if you go to eighteen thirty eight pop dot
[4:27] me, you'll see the link. And we're looking for feedback about version eight,
[4:34] which is the up and coming version with all these changes. And so
[4:39] that's what we want. Want you to take it for a spin, you
[4:43] know, check it out, and let us know you know what you like,
[4:46] what you don't like about it. I love me a V eight.
[4:49] Yes, so's it's really exciting and I hope people can jump in and contribute.
[4:58] Who's talking to us today, Richard, I grabbed a comment off the
[5:00] show seventeen ninety four. That's the one we did with jemmia Abu when we
[5:04] were I think we were at NDC in London. This is back in early
[5:10] twenty twenty two, and of course we talked a little bit. We were
[5:14] talking about different front end frameworks from Vanilla JavaScript all the way through Blazer,
[5:20] and Josh Dabashaw had this great comedy said, I've been working almost exclusively with
[5:25] web components in Blazer for almost two years now, and the two work really
[5:29] well together. We've even gone so far as to wrap some of my web
[5:31] components in Blazer components to augment them with server's side code. Fancy. Initially
[5:38] I went down the web component route because when the orders came from on High
[5:42] to use Blazer only a few months after the first release, those are early
[5:46] days, I wasn't convinced it was going to hold up under a load.
[5:50] I wanted a framework agnostic escape hatch, and I came upon the at the
[5:55] time new Microsoft Fast Element library. Luckily did hold up, and we've been
[6:00] massively productive with our new stack. And then he goes on to say,
[6:03] y'all should interview Rob Eisenberg or something in a fast team. They're doing a
[6:09] lot of great stuff with Web and Blazer components for fluent. And by the
[6:14] way, Flash is not dead. Yes it is. Bite your tongue,
[6:19] don't believe it. You can use Flash application code to publish to canvas with
[6:25] an adapter library called create JS, the same syntax as action script three,
[6:30] because everybody loves action script, Carl, everybody loves it. My god,
[6:34] I use this to make a computer based training modules at my last gig only
[6:39] three years ago, and it worked really, really well. I just have
[6:41] flashbacks to speaking of flashbacks, I have to say flashbacks. He didn't really
[6:45] I did. I have flashbacks to my stepdaughter in high school in the nineties
[6:49] talking about how her web class was all flash. They didn't even talk about
[6:56] HTML. It was easy, and I wanted to go down there and ring
[7:00] neck guy's neck. Well, you know, people were looking for easy ways
[7:04] to do things. There's about it. Yeah, back at the time.
[7:08] So Josh, thank you so much for your comment, and a copy music
[7:11] Coby is on its way to you. If you'd like a copy of music,
[7:13] go by write a comment on the website at dot dot rocks dot com
[7:15] or on the Facebook's if you publish every show there, and if you comment
[7:18] there and I read it on the show, we'll say, do you a
[7:19] copy music copy and you can follow us on Twitter if you want, but
[7:24] we really like you to follow us on Mastodon. I'm at Carl Franklin at
[7:28] tech hub dot social, and I'm rich Campbell at mastadon dot social and send
[7:32] us a two and check it out. Check out maskdon doesn't even matter.
[7:36] If it's funny, it's pretty good. Yeah, just send us the tute.
[7:40] Some guy just today said, hey, have you been saying send us
[7:42] a tute? So here it is. I'm checking out Mastodon. Thanks,
[7:45] thanks for the reference. Okay, let's uh bring on our guests. Steve
[7:51] Sanderson doesn't need any introduction. He's he would say, yeah, I'm Steve.
[7:57] I'm a developer at Microsoft. But what he really is is the ventor
[8:00] of freaking Blazer and all other sorts of cool things and how your nelson is
[8:05] with him, and he's a senior software engineer on the ESPN team. Welcome,
[8:09] guys. I can't imagine why you came around. Hi there, Carl,
[8:16] Hello Richard I am glad to be back and chatting to you again.
[8:20] Um yet you want to say hi everyone? I'm Ahavier. I work on
[8:24] Blaze on ESPN D with Steve and I'm happy to be here. Steve,
[8:28] how did you become so humble? Were you always this way? I think
[8:31] you know, I've I've practiced for many years to become as humble as I
[8:35] am now, and it's definitely one of the greatest accomplishments I think in human
[8:39] history. Astounding. It's astounding. I mean, so, were you like
[8:46] much more braggadocious, like in school? I was a very very quiet person
[8:52] at school. Yeah. Yeah, Well, anyway, that's not why you're
[8:56] here. We're here to talk about what Blazer United or something like that.
[9:00] Yeah, yeah, so you've heard of it. What do you think so
[9:01] far? I have? Well, I haven't played with the bits, but
[9:05] everything that I see I love and I can't wait. I can't wait for
[9:11] the first preview. So we better tell people what the heck Placer United is?
[9:15] Yeah? What is it? Okay? Have you had you want to
[9:18] explain the idea? Sure? So right now? When you do place or
[9:22] you have to choose between server and client and the idea of Place or United
[9:26] is essentially removing that choice that you may need to make ahead of time and
[9:31] enabling you to make that decision on a more granular level, not at the
[9:35] level of your app, but on a per component basis. So we are
[9:41] trying to enhance place or with server side rendering similar to how you do NBC
[9:48] or recur pages, and on top of that being able to render interactive islands
[9:52] of functionality within your app, so that you can have as an application that
[9:58] starts as a server and the app that has some more modern take on server
[10:03] side rendering with things like a streaming rendering and that then can evolve on continue
[10:09] on its path to returned activity through either server components or web assembly, and
[10:16] essentially trying to avoid forcing you to make a choice and letting you choose whatever
[10:22] fits best for your scenarios. Yeah. So the thing that catches everyone's here
[10:26] the most, I think is this automnode where you start as a Blazer server
[10:31] application and then in the background the web assembly DLLs are loading, and when
[10:37] they're loaded, it switches over to a web assembly component or page. But
[10:46] I don't want to I don't want to glaze over the server side rendering thing,
[10:50] and I kind of want to talk about that and how it differs from
[10:56] MBC and how it differs from blazers over. Yeah, can we do a
[11:01] why do you care? Like? Is this about speeding up the startup time?
[11:05] Yeah? It really comes down to you. So I guess one way
[11:09] to think about at a very high level is that we want Blazer to be
[11:13] suitable for all WebUI scenarios, which it isn't today, right, if we're
[11:18] honest, Blazer is great for certain situations, but not all of them.
[11:22] Prior to dot neet a like, it's great for richly interactive sites that are
[11:28] so rich that it's worth downloading a dotnet runtime into someone's browser and making them
[11:31] wait for you know, a second or two seconds or something before before it's
[11:35] ready. All for scenarios which are really read and you want to run them
[11:39] interactively on a server, and that's cool, but that's not all of web
[11:43] development. That's probably like, you know, fifty percent of web development or
[11:46] something, And the other fifty percent is you just want to send some HTML
[11:50] to people's browsers as fast as possible with the lowest possible server overhead, and
[11:54] it's a stateless request. Response thing, and Blazer has not been suitable for
[11:58] that in the past. But we are greedy and we want to eat all
[12:05] web UI scenarios, so we're coming for the other fifty percent. We would
[12:09] like all the web please. Yeah, all right, I hear that humility
[12:15] kind of right, But it's not about us. It's about the customers,
[12:20] right. People are spending their time building their web applications and at the moment
[12:28] they're forced into this choice up front, like am I orienting stuff around stateless
[12:31] server rendering or am I oriented and get around interactive SPA type programming. And
[12:37] because you have to make that choice, like have you I said, you
[12:39] choose once at the beginning, you're then kind of stuck with that and you
[12:43] can't really cross that chasm easily. But what we've realized, and what we've
[12:46] seen from some other similar technologies, is that it is possible to have one
[12:50] UI technology that will cover both of these scenarios, so that you only have
[12:56] to do your work once you write your component and it can work in either
[13:00] this interactive mode or the stateless server mode, and then we can do all
[13:03] the advanced stuff on top of that that. Have you listed a bunches of
[13:05] stuff where you know, we have different islands that some of them are interactors,
[13:09] some of an art some of a server, some web assembly, some
[13:13] dynamically switch from one to the other. You know, all these different advanced
[13:16] things. But ultimately it comes down to the fact that we want to cover
[13:20] all the scenarios with a single programming model, single UI technology. Is there
[13:24] a case for a mixed mode? I mean it isn't ideally everything client you
[13:28] just as long as you don't have to wait for it. Mum. There
[13:31] are advantages right, well, yeah, advantages. There's advantages to both,
[13:37] aren't there. There's avantages to the server side, and that you don't have
[13:39] to hide your secrets. You don't have to have an API layer for example.
[13:43] Yeah, you have you have your data and your state alreadyly available on
[13:46] the server. You don't have to go through all the hussle office to be
[13:50] client, all the things that you need to deal with like authorization, all
[13:54] that stuff, because it already is on the server. So it's one of
[13:58] the things that missus to realize me in many cases when you using Blazer server
[14:03] is that it's really really convenient because you have everything right at the top of
[14:07] your hand. The moment you move to web assembly or do others of framework,
[14:11] then you have this layer where you need to be serializing everything, and
[14:15] as much as you can try to smooth over that, you still need to
[14:18] think about it. So if you have something that is highly interactive, then
[14:22] it makes sense for example, to be web assembly. If you are handling
[14:26] song operation on the server, then it might make sense for you to be
[14:31] able to plug an a component that that's everything on the server. So Richard's
[14:35] question is really valid here in that. Okay, I see the benefit to
[14:39] Blazer server, but if you're going to end up that place a web assembly
[14:41] anyway, why would you need to start with blazers server. Well, there's
[14:46] a couple of advantagies. One of them is the startup time that we've alluded
[14:50] to. So with web assembly, you know, if the user's got a
[14:52] fast network connection, then hopefully the app can get started within a couple of
[14:56] seconds, but you know can't absolutely that, especially if they're on a slow
[15:01] network connection. Whereas a Blazer server app is going to start instantly there's nothing
[15:05] really to download, so you've got that startup time. The other thing is
[15:09] all these architectural advantages that have you mentioned where you're trying to talk to your
[15:15] database, You can just do that right. Your code's already on the server.
[15:18] It can just stop to the database straightaway, no need to bother writing
[15:20] API layers. It's just a very very productive environment to be in. But
[15:24] if it's going to eventually end up as a Websemily application in automode, you're
[15:30] still going to have to have the API layer and all of the things that
[15:35] we are required for a Websemily application, right, Oh, yeah, yeah,
[15:39] you are right. Yeah. So if your intention is to have an
[15:43] application that genuinely works in birth modes and is able to switch between them,
[15:48] then you do have to be concerned about birth server side and client side concerns.
[15:52] And at that point it's a pure startup time startup time optimization. Yeah,
[15:58] yeah, there's and it's almost a philosophical question of here is that which
[16:02] would consume lest bandwidth staying strictly server side and you know, interacting the client
[16:07] back and forth versus getting all the client down and its interacting at the API
[16:12] level. Because I could almost see as one of the be different commigurations based
[16:17] on bandwidth constraints or bandwidth cost constraints yep, yep. There's there's sons are
[16:21] trade us to make. There's the bandwidth, there's the startup CPU time.
[16:25] There's how much time and memory you're consuming on the server. There's how much
[16:30] state you might need to transfer. There's the latency of UI interactions that they
[16:36] all put you at different points on preferring server or client side code. And
[16:42] we can't decide for all applications how it should be. And that's part of
[16:45] the goals with this new programming model is that developers can make that decision for
[16:51] themselves on a very fine ground basis. It doesn't have to be the entire
[16:53] project is just server side, or the entire thing is web assembly. But
[16:56] you could have individual components where you say this one needs a superlo latency interaction
[17:03] like a text data to or something and something else which is just like a
[17:07] list of products. Maybe that's suddenly going to update once in a few minutes.
[17:11] You will just run that server side, all right. Getting back to
[17:14] my question about the differences between server side rendering and MBC and Blazer Server,
[17:22] what are the differences there? Ye, So Blazer United or server side Rendering
[17:30] Laser is an equivalent model to MBC and racer pages in the sense that everything
[17:34] is server side rendered. There is no JavaScript. The browser is the one
[17:40] talking to the server, and the main advantage of using racer components over NBC
[17:48] or race or pages is that then that component can also work on web assembly
[17:53] and Blazer or server and you're using a single component model or a single programming
[17:59] model to target all three scenarios. So the goal here as a stick mensions
[18:03] is to try and reach the broader set of people possible. And pretty much
[18:11] nothing beats server render apps in terms of getting data to the your customer and
[18:15] being able to do simple interactions. So what's the difference between a Razor component
[18:22] in a place of server application that takes some data and some HDN splits it
[18:26] down and just server side rendering and place of United Yeah, so the difference
[18:33] is the interaction. The interaction in a place or server app happens completely on
[18:37] the server. We literally delegate the event that happens in the browser and send
[18:41] it to the server. While in a server render app, okay, is
[18:45] the browser actually using the standard estemail and web technologies to serve a foreign post
[18:51] that then we traditionally processed like you would do in NBC or racer pages.
[18:56] Okay, so there's no circuit, I guess you could say, and just
[19:00] yeah, exactly right, that's the circuit. Happens in the circuit is the
[19:03] signal our connection plus some metadata around it. They call a circuit, right,
[19:08] yep. Yeah, And so there's a circuit when you have a server
[19:12] side blaser component or page, but not when you have either web assembly obviously
[19:19] or server side rendering exactly and those and as we talked about this on Blazer
[19:26] trains to you, I was concerned about, you know, multiple circuits with
[19:30] multiple components, and there's only ever one circuit and it's either on or it's
[19:36] not. Right, Yeah, that's right. Yeah. And the intention is
[19:37] that we have that circuit for the minimal amount of time that we need to
[19:42] so as the user navigates around, if they happen to go to a location
[19:45] that has a server ended component, then a circuit will start up and as
[19:51] soon as they navigate away from that, it can go away, which means
[19:53] that the amount of time that you spend holding open a connection to the server
[19:59] is kept as small as it kind of that reduces the costs for the web
[20:03] developer, but it also gives you certain resilience benefits as well. So whenever
[20:07] you don't have a circuit, you don't have to worry about things like you
[20:11] know what if they go into a tunnel and lose their three G connection areas.
[20:17] So yeah, it just becomes a traditional website as soon as the circuit
[20:21] goes away. Back to HDB keep alive. So let's talk about that dreaded
[20:26] pale white reload page that happens when the circuit gets broken in a Blazer server
[20:32] application. If you lose the circuit for whatever reason, the Internet goes down,
[20:36] or Steve said, you go through a tunnel. You know, it
[20:38] tries to reconnect and if it can't then you have to refresh the page or
[20:44] whatever. So let's say in the scenario where we have mixed things, maybe
[20:48] we have one page that's a server Blazer server page, another page that's server
[20:56] side rendered or web assembly or whatever it's you'ld only run into that issue if
[21:02] you went to that page. What if you have a rendered page that has
[21:06] just a component, a Blazer component that's a Blazer server component on it,
[21:12] and you lose the circuit, does the whole page go wait? Or is
[21:17] it just that little component area or does it We don't know yet, right,
[21:21] We haven't implemented that, right, If you've got a design in mind
[21:25] for that, I think it's a bit of an open question. That's cool.
[21:27] Yeah, yeah, say so it must work perfectly an implemented yet yeah
[21:32] yeah. Now you should understand and listeners should understand that we are at an
[21:37] early stage of design right now. We've got a good prototype and we did
[21:40] some cool demo videos, but the real implementation we've only just got started on
[21:45] in the last month, and there's tons of open questions and we are looking
[21:48] for a lot of feedback on many aspects of the design. People can follow
[21:52] along and get up and see the work as it goes in with prs,
[21:55] and we often write things in the PR description which is like open question what
[21:59] should happen and blah blah blah, And it's great when people come along and
[22:03] give us their feedback on that. And that thing that you've just raised there
[22:06] is exactly the sort of thing that we still are you know, design is
[22:10] pending on that, right, and you're targeting the dot net eight timeframes,
[22:15] so November of twenty twenty three, that's right, Yeah, yeah, And
[22:18] I say targeting genuinely say like some features will make it as some features will
[22:22] not, Like software is complicated and it's a preview out yet or no.
[22:26] The first preview that you're going to see something of this is Dotnet eight preview
[22:30] three. I don't know the release state, but we've just gone through the
[22:33] CD complete point for that at the end of last week, so it's probably
[22:37] a month away or something. I don't know have yet. Do you know
[22:37] in it ships, it's just another pretty regular cavens. I don't have the
[22:42] exact day, but every month. I used to be more worried about done
[22:48] previews, but I'm not anymore because I know it's ships every month. They're
[22:51] like clockwork. Yeah yeah, yeah. You stop having that pressure to get
[22:55] everything done for a given release. You know there's just another release coming.
[22:59] Better make it right. I said, to make the deadline you really want
[23:03] to get it like in previous seven rather than But yes, I didn't have
[23:08] the cojones to actually do the nightly build and try it out. Yeah No,
[23:12] I wouldn't really recommend most people to bother trying to get the prototype code
[23:17] runningcause you do have to build the whole ESPNT Core repo and yeah, it's
[23:19] not that easy, to be honest with you, but yeah, hopefully it's
[23:22] only a few weeks away until some of the first parts of server rendering show
[23:26] up. It'll be fairly basic in the first prev three that we won't have
[23:30] streaming rendering or even the ability to put interactive components on the page. But
[23:36] you'll start seeing some of the core APIs come together and this is being built
[23:40] in the asp net core gethub repository, Like, that's where that's where I
[23:45] see the issues, Like, that's where folks should be going if they want
[23:48] to participate. That's absolutely right, Yeah, yeah, absolutely, I'm just
[23:51] gonna make sure include that link. It's like, look, folks, here
[23:53] it is being built up public you could and you could be a part of
[23:57] it. So they're what are you guys doing in the area of performance with
[24:03] dot net aiding with Blazer United, Are we going to enable some scenarios that
[24:10] can be more performant than done at seven? Sure, depending on how you
[24:15] look at at performance. We obviously do performance testing on pretty much everything that
[24:21] that we feield and shape, but generally in first releases you're not going to
[24:27] see us to focus a lot on performance and we focus more on on features.
[24:32] However, if you think about performance as in user metrics, you're going
[24:37] to see at enough improvement just by the fact that we are server rendering things.
[24:41] Yes, because the time to first bite, the time to interactive a
[24:45] large content paint, and all the metrics that are defined generally for measuring the
[24:52] purf of the app will all I'm expecting them all to improve, like significantly.
[24:57] Imagine just using automode right out of the box is going to architecturally give
[25:02] you better performance. Yeah, yeah, that's right. But also the streaming
[25:04] rendering feature is potentially quite a significant one for that as well. So right,
[25:10] let's talk about that after the break. We'll be right back after these
[25:12] very important messages. You know, Amazon Aws is a great home for your
[25:18] dot net applications. Whether you're looking to run your apps as serverless functions,
[25:23] have them running containers, or you require the complete flexibility of virtualized hardware,
[25:30] you can do it all on Aws. Dot Net toolkits and templates guide you
[25:33] through build and deployment, or you can use your favorite infrastructure as code and
[25:38] CICD tools including Azure DevOps, GitHub actions, and git labs. CICD.
[25:45] Loving visual Studio vs Code or Rider. There's an AWS toolkit for each of
[25:49] them. Want to use familiar Microsoft Sequel server databases, you can with the
[25:53] Amazon Relational Database service, which provides fully managed sequel server databases that for automatic
[26:00] scaling failover in snapshots. Once your dot net application is deployed, it can
[26:04] use any of the over two hundred AWS services to extend its functionality. Interested
[26:11] in AI, IoT, machine learning, video processing, or transcription. Your
[26:17] dot Net on AWS application can do it all. To learn more, go
[26:21] to AWS dot Amazon dot Com, slash net. All right, we're back.
[26:30] It's dot net Rocks. This is Carl Franklin and this is Richard Campbell,
[26:33] and we're talking to Stephen Javier about Blaze United. And you were just
[26:37] going to talk about streaming rendering, which is a new feature in Blaze United.
[26:44] Yeah, yeah, that's right. So this is part of as we
[26:48] move from a SPA centric way of thinking about why programming to one that encompasses
[26:53] traditional request responses as well, we have to find ways of retaining the same
[26:59] benefits that SPA program has had. And one of the benefits of SPA programming
[27:03] is let's say that the landing page of your site involves making a quite an
[27:08] expensive database query to get the data for like a list of dot net rocks
[27:11] episodes, and you've done like ten million by now understanding, so it takes
[27:15] a long time for that to come back. So with a SPA, traditionally,
[27:21] the user would get back some like a skeleton of HTML that doesn't really
[27:25] contain anything initially, and then it would contain some script that makes it go
[27:27] and fetch stuff from the you know, from an API and render this massive
[27:32] list, and so the UI shows up pretty quickly. Right, it's empty
[27:36] initially, but it's still there. It's better than just a spinner that's empty.
[27:41] If you move to a pure server endered mode, then what would happen
[27:45] by default if you don't do any further optimization, is that the browser does
[27:48] the HDP request to say, get me this homepage, and then you start
[27:52] doing your database query, and then you wait for like ten seconds for the
[27:55] database to reply, and the user doesn't see anything at all. The HDPU
[27:59] request is just hang open for that amount of time. Streaming rendering allows the
[28:03] server to send back the HTML straight away or like a skeleton of it,
[28:08] straight away, but keep the HTTP response open until that database query completes,
[28:15] and then it can send a further chunk of mark up which can then get
[28:18] attached to the page, so it can get merged into the dom without having
[28:26] to do any further HTP request, without having to run a full SPA programming
[28:33] and rendering system. So you get that ability of a fast initial render and
[28:38] with the ability still to patch additional data into it later. Does that make
[28:42] sense? I know it's a bit of an unfamiliar feature. So under the
[28:45] hood, is it calling? Is it using ia sync result to do your
[28:49] traditional streaming? So on the dot net side, it's just using tasks.
[28:56] So the Blazer renderer has always kept track of what pending tasks there are associated
[29:02] with a renderer. That's how the existing pre rendering system knows when to complete
[29:06] the response. So what we've changed really is instead of waiting until all those
[29:10] tasks are finished before we send the response, we now just send the response
[29:12] straight away, but we don't close the actual connection for the response until the
[29:18] tasks have completed, and at that point we do a further render and send
[29:22] a UIF to the browser. Hey, I want to go into that a
[29:26] little bit more, but I just get because this just came to my mind.
[29:29] I got to tell you, Steve, I just went through about six
[29:34] hours of absolute pain and torture trying to get bindable properties working with an observable
[29:41] collection in a maui A just to bind. And then I did the same
[29:45] thing in Blazer in about five seconds. And it just goes to show you
[29:48] the power of this binding model, of the Blazer component model, and just
[29:55] how awesome it is. I can't thank you enough for invcting. Oh my
[30:04] god. I guess the real thing is, Zammal's just still a nightmare,
[30:11] your friend. I didn't say that. I said that as a person,
[30:15] Carl, not as a Microsoft anybody. Yeah, yeah, yeah, okay,
[30:19] all right, I'm not saying Zamal your friend doesn't have emotional problems,
[30:23] your friend. It's just hard, you know, the way Zamal is all
[30:29] set up, there's just so many there's so much plumbing under the hood.
[30:33] I think it's just hard to nail. Um. But anyway, um,
[30:37] so, so this would I've been doing this kind of thing, this streaming
[30:41] rendering myself. Um, let's say, from an API that's returning a whole
[30:47] bunch of things and wrapping that AI API calling an a I a sync result,
[30:53] and then um just getting getting the data and then only you know,
[31:00] let's say that there's a thousand items in a list, but my list is
[31:03] only twenty, you know deep, so I can only show twenty at a
[31:07] time. So after first twenty, after I have the first twenty, boom,
[31:11] I call status changed. Everything rerenders and it's like instant, and so
[31:17] then every other hundred let's say, we do another render, so the list
[31:22] box sort of scroll bar starts getting wider and wider. I've been doing that,
[31:26] but it does take a little bit of work, and I think what
[31:30] I hear you saying is that you know you don't have to do the work
[31:33] now. It will It'll just stream as the data comes back and is showable,
[31:41] it'll just show. Is that what I'm hearing? Yeah, that's right.
[31:45] So we've taken the existing a data loading pattern that people already use in
[31:48] their Blazer components, and we simply made it so that you can put a
[31:55] flag. It's probably going to be an attribute I think on a component to
[31:57] say I do streaming rendering, and simply by opting into that, it means
[32:00] that the service side rendering will not wait for all those tasks to complete,
[32:05] but instead will will send each subsequent chunk of rendering down as it occurs.
[32:09] To be clear, it's not a top to bottom thing where you know,
[32:13] we send an h one element and then we don't render the next bit until
[32:15] we've got the rest of it. We do send everything in the document and
[32:19] then we can patch changes into an arbitrary locations within the document as they occur.
[32:23] So cool. Yeah, what has been the biggest challenge in designing this
[32:28] system? Oh? I don't know, Um, you got some opinions?
[32:31] Have you? Probably working with me, that's one though, Yeah, I
[32:35] would. I think I'm out that the word wave. We are both the
[32:45] very opinionated people. Yeah. Yeah, it's always fun through discustings with Steve.
[32:51] Did it start with just you guys though? Or was it was it
[32:53] stuff that was gleaned from the repose, from from the customers? What brought
[33:00] it on? So it was really a lot of like things coming from multiple
[33:05] places. There was a lot of feedback that I collected in this area over
[33:08] the years that's somewhat raised the question of of like, hey, what about
[33:15] all these other areas that were not tackling And then Steve went on a journey
[33:21] to learn more about the area and came in and said, oh, there
[33:23] are actually many great things we can do here. And then the teams started
[33:29] working together towards like creating this vision. And that's more or less how it
[33:34] happened. Steve, do you have like a magic sauna at your house where
[33:37] you go out, you know, and you just like sweat it out and
[33:38] like things come to you in a vision. And yeah, after I've made
[33:44] the relevant sacrifices and you know, vipe the right, I've solved this.
[33:49] I've solved this problem. It was hard on the chickens. Yeah, I
[33:55] mean I always thought about this issue, but I just resigned myself to the
[34:01] fact, well, you kind of have to pick your orson. You're either
[34:05] servi side or client side, and that's it. And so it's yeah,
[34:09] very interesting. We should give credit to some of the other technologies that I've
[34:14] already been doing some of this. So within the JavaScript world, there's been
[34:17] a pretty big swing over to service side rendering over the last year. And
[34:22] you know, it's not like they've all made an equal level of progress.
[34:27] Some of them have got a lot further than others. I think next JS
[34:30] is probably the one that's covered the most ground and set a lot of the
[34:34] patterns that others have tried to copy. But but you look at the server
[34:38] side toolkits for each of the different SPA frameworks, whether it's spelt Care or
[34:43] whether it's next or other things like that, you know they've all attempting to
[34:46] do stuff in this area. So you could say, in a way,
[34:51] we're simply following a trend that's occurring. There's another more sort of perhaps optimistic
[34:59] way to look at it, which is that Plaza already has certain strengths in
[35:01] this area, Like we're already got a massive head stop because we've got Blazer
[35:06] Server already, we've got one of the strongest server web offerings that there is
[35:10] available. And so this is in fact actually a very natural thing for us
[35:15] to do, to take a bit of that inspiration and then see that we
[35:17] can go further in many ways. Yeah, in Microsoft has a long history
[35:22] of server side rendering, right yep. So absolutely if you think about it,
[35:27] like in many cases, the Davastry world has gone into this journey of
[35:31] like going from the browser to the server, and we're kind of doing the
[35:35] opposite thing, which is we went from the server to the browser, and
[35:39] we're kind of both meaning in the middle for from different angles, if you
[35:44] want to think it that way. These are the healthy evolutions of an evolving
[35:47] platform space, right, we try all the things exactly. And the other
[35:53] thing that I would say is that if you go enough far backing off,
[35:59] you'll see that in the beginning s password not just an index HTML and some
[36:05] like JavaScript that loaded everything and bid requests and all that stuff. The beginning
[36:08] of office pass was really here's my JavaScript, here's my component within my page
[36:14] that was sever rendered. And that's kind of the words. Where we're going
[36:17] again is about giving people more flexibility and more granularity into how they build it
[36:22] apps. Yeah, between the magic of ajax and inner HTML, suddenly what
[36:29] do you want to do on the page? Yeah? Yes, we have
[36:31] been accused of reinventing web forms and update panel and j Query and basically everything
[36:37] else. So yeah, all the different steps along the journey, all those
[36:43] really great technologies that made it easier to develop, but implemented with the new
[36:47] understanding in the new capabilities and the richer language that we have now, Like
[36:52] these are good oscillations, and you know, to your point, and I
[36:55] grabbed links for like next JSS, Felt Kit and so forth. You know,
[37:00] alone, lots of different groups of folks that care about web development are
[37:05] experimenting with tools for exact in these exact same contexts. Yeah, that's true.
[37:09] Do you think that web assembly is getting its due respect these days?
[37:15] Are people still wary of it? Like, you know, they bring up
[37:20] the S word, you know, and non understanding that it's different than silver
[37:24] light? Do you still run into that? I would say within the Microsoft
[37:30] communities there is definitely some residual fear of the silver Light days, But honestly,
[37:37] that's a fairly small portion of the web ecosystem. Like I would imagine
[37:43] that, you know, a good eighty percent of web developers entered the industry
[37:47] after silver Light was already finished, and they don't think about that. You
[37:52] know, web assembly is not even a new technology. It's been in your
[37:54] browser since what twenty seventeen? Yeah, I think, yeah, so like
[37:59] it. It's older than probably half of the web developers careers by now.
[38:02] So I just gotta say it. You know, if you're a Microsoft developer
[38:06] and you're afraid of web assembly, just to educate yourself, it's there's nothing
[38:10] to fear here. Yeah, everybody's gonna be fine. It's a standard,
[38:14] Yeah it is. It's a standard that everybody's implement. Oh hey, how
[38:17] about that news that Safari is finally getting a makeover. I bet you're happy
[38:22] about that. Safari is getting an update that they're going to fix like one
[38:25] hundred and twenty three issues, and the issues with progressive web applications are going
[38:31] to be addressed, and notifications and all these things. All right, Yeah,
[38:35] well, I'm glad to hear that. Yeah, Safari has been a
[38:37] bit of an odd one out browser for a little while, but I've certainly
[38:40] seen they've been doing a ton of effort to try and correct that perception.
[38:45] Safari fifteen seems to be the big one, Like, this is the one
[38:49] that's going to really play well. It's going to be the one that we
[38:52] should have had ten years ago. Maybe not, yeah, alright, five
[38:58] years ago. Still error holding out for a while, all right. So
[39:01] automode basically, this is the mode you can pick for any component. You
[39:07] can pick whether it's going to be a server side rendered or web assembly rendered,
[39:14] or auto which starts as server side and then ends up as web assembly.
[39:19] Right, and you do this with word and attribute on the component.
[39:22] Yeah, that's right. Well, we're looking at different ways of specifying how
[39:25] components should render, so that the intention is that one a component can say
[39:30] its own preference about how it renders. You can have an attribute that says
[39:34] like I'm a server component, i'm web assembly, or i'm auto. Right,
[39:37] But as well as that, the person who consumes the component at the
[39:40] call site can specify what they want. So as you use a component,
[39:45] you can say render mode equals and then you can override the components own preference.
[39:49] Like, the intent is that mostly components should not express an opinion about
[39:52] how they render it. They should be agnostic, you know, they should
[39:55] be as flexible as they can to work anywhere, and then the person who
[39:59] use it will just say what they want. Yeah. So, therefore,
[40:01] your components should be completely separate from your data layer, your API layer,
[40:07] and all of that stuff should exist outside your components, except maybe in your
[40:12] pages, right, I mean they have to a page has to decide that,
[40:15] right. Well, you know that's an interesting point, right, because
[40:17] yes, and one sense, yes, all that kind of separation is all
[40:22] a good thing, but in another sense, it's all kind of overhead like,
[40:23] you're spending your time creating interfaces and abstractions and thinking about d I services
[40:29] and all that stuff, and you know, wouldn't it be better if you
[40:30] didn't have to think about any of that stuff. So we're trying to think
[40:35] about what kind of patterns around data loading or other platform specific features would enable
[40:44] people to just be more productive. And one of the key ones that we're
[40:45] looking at at the moment is multi targeting. So up to now, if
[40:52] you wanted to have something that runs on web assembly, you had to have
[40:55] a special project that compiles for website, right, But we are looking in
[41:00] dotnor eight to have a way of multi targeting your server project to say this
[41:06] is both server and web assembly, and then it will produce two separate builts,
[41:10] one for each of those environments. And then in your code you can
[41:14] have an if server or if grows or if web assembly whatever we call it.
[41:19] And so in your data loading logic you can say something like if server
[41:22] load it directly from a database with entity framework. Else call an API endpoint
[41:28] something like that, and then you don't have to bother making an interface and
[41:30] doing extra abstractions. Well, it'd be nice to use I would be using
[41:35] a repository pattern where I could implement a repository interface and then have one to
[41:43] implements my API calls, and have another one that implements my data services.
[41:49] Right, and I'm using one when I'm on the server and one when I'm
[41:52] on the client, and if that interface holds up, it should I should
[41:57] just be able to swamp them out depending on what environment. And I mean,
[42:00] right, yeah, that's absolutely one way to do it. But wouldn't
[42:02] it be nicer if you didn't even have to bother Like if you just literally
[42:06] put your data access logic in your component and you just said, if I'm
[42:08] on the server, then get it straight from the database. Otherwise call some
[42:14] endpoint. Okay, I guess it. Just you still have to do that.
[42:16] It justs depending on where you do it, I suppose. So it's
[42:20] a bit more about that, because if you think about it, when you
[42:22] like add a repository, you need to have a set of data types that
[42:27] you define that become the contract. You normally have to put those in a
[42:30] separate assembly so that both things can reference. You need to have a bit
[42:37] much more ceremony, yeah, than if you define everything on the same project.
[42:40] It gets compiled twice and at that point you don't have to add anything
[42:45] that you don't want. You want to do the repository, you can still
[42:49] do it, but you're not forced to. So your solution, Steve,
[42:52] is within this Blazer United project. Maybe instead of having in the template the
[42:57] shared folder where all your component let's go, maybe you have a you know,
[43:02] server side components and web assembly components, and you can have the same
[43:08] component in there with the same interface. It's just that depending on where they
[43:13] run, they are going to be different under the hood. Is that what
[43:15] you're saying, Well, that's one way you could do it. Yeah.
[43:17] So actually this is a very flexible system. So you could have that pivot
[43:22] on a per component basis, and we might do that with a file name
[43:24] convention. So you have my component dot server and my component dot well lovely,
[43:30] and you know it will pick the right one, but it might not.
[43:32] It could be even more granular. You could just have my component dot
[43:35] razor and inside that. Yeah, you can have a preprocessor directive that says
[43:39] this range of code is used for server and this other range for web assembly.
[43:44] Or you can have interfaces, or you can have separate projects like you
[43:46] know, whatever level obstruction is what you want, you can choose and we
[43:50] can offer that flexibility. You're just trying to offer here. If you want
[43:54] them the least amount of overhead in ceremony, use this solution. But if
[43:59] you want to have more control, you're free to implement your own. Yeah.
[44:02] Yeah, yeah, that's right. And I think there's possibly even a
[44:05] longer term vision about how data loading can be made quite opinionated. So you
[44:09] don't even think about this at all. I think I have you. You're
[44:13] starting to think about designing that you want to explain how that could work.
[44:15] Yeah, So I think one of the most where I'm trying to go for
[44:22] is to live in a world where you actually don't even have to define an
[44:25] API because you're already having all that data loading logic within your component application.
[44:30] So why would you need to have a different mechanism when you are running a
[44:37] web assembly versus when you are running on server. And one of the ideas
[44:42] is somehow translate the data that you gather on the server to the web assembly
[44:50] piece because on server, again, as we said, everything is very convenient.
[44:53] Your state and everything is on the server, you already have it.
[44:57] There is the is the breach on the client. And we already do some
[45:00] of these with pre rendering, where we actually have a mechanism that allows you
[45:07] to persist a state and will automatically pick it up on the client and applied.
[45:10] And the idea here would be that we can do that in more scenarios,
[45:15] not only during pre rendering, and that we can do that more declaratively,
[45:21] like using an attribute or something like that that you put on a piece
[45:24] of data in your component. We can handle the rest. Yeah, I
[45:28] just wanted to suggest, like as a really concrete illustration of that. You
[45:32] know, our place has got different life cycles methods today like on initialized racing
[45:36] and all that stuff. Imagine and there isn't but imagine if there was one
[45:39] called onload data racing or unloading gasing or something like that, and you put
[45:44] your data loading logic in there. But the magic of that particular one would
[45:47] be that it always runs on the server. Regardless of whether your web assembly
[45:52] or server, that particular method will always run on the server, so you
[45:57] can always talk to your database straightaway plate whatever parts of your component you want.
[46:01] I love that idea. Yeah, it just takes away an entire layer
[46:06] of your OCTASRI really wow. And and you know here's the other issue if
[46:13] you if you're going to end up in web assemily Land anyway, now you
[46:16] have to, as I said before, make an API layer. But that
[46:20] also involves data transfer objects. And you know there are tools out there to
[46:24] help you with those things. But um, have you guys thought about that
[46:29] at all? About in terms of like simplifying serialization or something simplifying Yeah,
[46:37] maybe creating DTOs from models with attributes or things like that. I don't know
[46:42] that you would need to create DTOs quite as much. Like imagine you're making
[46:45] your products editor page or something. You want to load a collection of products
[46:49] from from your database with the f or something, and then you put some
[46:52] logic on on onloading gas inc. Which populates a list of product. Well,
[46:58] that's it, Like there's no other to write that. There is no
[47:00] dto your product is the DTO in a sense like oh, you could load
[47:05] multiple things and they would all get loaded at once. I mean you can
[47:08] still freely define classes that play a DTO like role if you want, but
[47:13] you just wouldn't have to. Yeah. I suppose you're right. Yeah,
[47:15] Yeah, I think the other way to put it is that whenever you are
[47:21] serializing graphs, you need to think about like back references and things like that.
[47:24] And part of you being an engineer is figuring out that, well,
[47:30] if I don't need to like have back reference to something, maybe I can
[47:34] just live with those And as long as you keep seeing, as long as
[47:37] you keep things simple and Jason serializable, you should be good. I got
[47:42] called the task once for taking the database table architecture, representing that as a
[47:50] class and sending it down as a dto too, and then they were simple
[47:53] tables, right, you know ID, first name, last name, email,
[47:57] whatever. But the criticism was somebody can nefariously if they know that the
[48:06] that you're basically representing the shape of the data, then they can neferously inject
[48:10] things by making calls. But that seems to me that a good, good
[48:16] security is going to handle that. But I'm not sure have you ever heard
[48:22] that kind of thing before? Yeah, so NBC has that, And if
[48:25] you look at MBC, there's an attribute that is called pye never that you
[48:29] can put on a property to essentially prevent that type of attack, where like
[48:32] you're using your MTD fraenwork type and you're using an ID or a foreign gear
[48:38] or something like that. I want to prevent someone from sending up post request
[48:42] and change with that. Yeah, that's that's the way down you normally do.
[48:46] And yeah, okay, the other Yeah, the other thing is that
[48:51] you normally also use the ID from the URL or something like that has the
[48:55] input for like keen things to your database, because that's where normally do you
[49:00] have your authorization rules and everything else, and essentially avoid using the body for
[49:07] things that decide where things go. Good. Yeah, I mean, I
[49:09] suppose if you're really paranoid about it, you could create a map and you
[49:13] know, use gooids or something to send it the client and then map those
[49:16] two things in the database if you're really worried about it. But I think,
[49:20] I think there's plenty of solutions out there to prevent that from happening these
[49:22] days. In the end, I would say that it is perfectly fine to
[49:25] use videos, and it's actually what we recommend in like NBC, and we
[49:30] behind many cases because you know the exact shape of your data. We have
[49:34] attributes to make other things work. But if you can be explicit, it
[49:37] is a bit more work and a bit more ceremony. But in some cases
[49:40] it makes sense. All right, good Richard, you have any more questions,
[49:45] No, I think we've nailed this. It's of course it's still early
[49:47] days, so a lot of this we can say it's all going to be
[49:51] phenomenal because you haven't had the building yet. I guess that's right. Yeah,
[49:55] well, I can't wait for the preview coming up and coming here.
[49:59] I'm definitely to take it out for a spin in and I'll definitely talk about
[50:01] it on Blazer Train and show some demos and things. Guys, thank you
[50:05] for your continued awesomeness. There's no other way to say it. It's just
[50:08] awesome, awesome, cool, thank you. All right, Well, thank
[50:10] you for having us. You're welcome and we'll talk to you next time on
[50:15] dot net rocks. Dot net Rocks is brought to you by Franklin's Net and
[50:39] produced by Pop Studios, a full service audio, video and post production facility
[50:45] located physically in New London, Connecticut, and of course in the cloud online
[50:51] at PWOP dot com. Visit our website at d O t n et r
[50:55] O c ks dot com for RSS feeds, down modes, mobile apps,
[51:00] comments, and access to the full archives going back to show number one,
[51:05] recorded in September two thousand and two, and make sure you check out our
[51:08] sponsors. They keep us in business. Now go write some code, see
[51:13] you next time. We got a chad metal band.

Shows are listed from Apple Podcasts' charts and directory, and Podcast Index where it is used. Every show and episode belongs to its publisher and plays from the publisher's own feed; this site hosts none of them.
