472

June 17th, 2022 × #serverless#edge computing#Deno

Supper Club × Edge Functions and Deno with Eduardo Bouças of Netlify

Discussion with Eduardo Bocas from Netlify about edge functions, Deno, serverless, and more.

or
Topic 0 00:00

Transcript

Scott Tolinski

Welcome to the Syntax supper club. In this episode, we're gonna be talking with Eduardo Bocas. We're gonna be talking about Edge Functions and Deno.

Scott Tolinski

And it's gonna be really exciting because I know Wes and I have a lot of questions about this kind of stuff.

Scott Tolinski

So my name is Scott Tolinski. I'm a developer from Denver, Colorado. And with me today, as always, is Wes Bos.

Wes Bos

I am on the edge of my seat Oh. For this podcast.

Scott Tolinski

I do know what you're going to say. It works better when you call that denno or denno.

Scott Tolinski

That's good. This episode is sponsored by 3 amazing companies today, which is Hasura, The, perfect place to get a GraphQL

Wes Bos

API up and running. The Postlight podcast, which is a must listen for tech leaders about Solving tech problems

Scott Tolinski

and and WPSMTP, which is the easiest way To fix WordPress email deliveries and assure your emails reach their inbox.

Scott Tolinski

So with us today also is Eduardo Bocas from Netlify, and let's talk about Edge functions.

Scott Tolinski

Wes, do you have what what's your what's your plan here for attack in terms of edge functions?

Wes Bos

So I I think this episode is there's a couple of things I want to touch upon it, and then we'll we'll see. So I want to understand, like Like, what is an edge function? We had an episode on it already, but, like, we're just 2 guys. Now we have an expert on, specifically, Netlify's edge functions Are implemented in Dino. So that's kind of interesting to me. And then we have a whole bunch of questions about, like, why I would you want an edge function over a serverless function, and what about databases? And and and we'll we'll kinda go from there. So, Eduardo, do you wanna give us a quick rundown of, like, who you are, what you do for a job, and and and whatnot?

Topic 1 00:02:33

Introducing Eduardo Bocas from Netlify

Guest 3

Absolutely.

Guest 3

First of all, thank you for having me. It's a it's a pleasure to be here. Welcome.

Guest 3

Yeah.

Guest 3

I'm a software engineer. I work at Netlify, and I do a bunch of things around developer and I, currently, I'm part of the team at Netlify that works, in our, serverless compute offering.

Guest 3

So I work a lot with, Netlify functions, and most recently, Edge Functions.

Guest 3

Yeah. And I'm super excited to talk to you about it. Awesome. I'm a big fan of,

Wes Bos

the Netlify serverless functions. I use them on my my own website for all kinds of stuff. I have, like an Instagram feed. I scraped my Instagram. Since Instagram doesn't give you an API, it do some sort of shady stuff to get that feed, and It breaks every now and then, but that's I threw that in a serverless function.

Wes Bos

I do all of my, like thumbnail generation for, what's it called? Like, OG image when you share a URL. I do all of that in Netlify serverless function, and it's it's awesome. It's been great because I have, like, a Gatsby website. But Anytime I need a little bit, a sip of JavaScript I like to call, I throw it in a function. It's been working really well for it for me.

Guest 3

I think, serverless functions are a really powerful way for for people to kinda, To add a lot of workflows and to, like, extend the functionality over the sites without ever having to worry about Provisioning a server and kinda handling traffic patterns and kinda patching security things. And so You just especially as a as a front end developer, you can just go into your repo and add a JavaScript file that has the same kinda shape as

Topic 2 00:04:24

Serverless functions allow adding functionality without servers

Wes Bos

The rest of your front end side, and it just runs on the server and kinda does things for you. And that's, yeah, that's a pattern that I really like as as a user. Yeah. That that's actually a great way to put it as to, like, what is a serverless function? And it's kind of something that maybe we overlook is that we've talked about serverless functions on the thing, On this episode or sorry, on this podcast so much that maybe we should, like, define it really quickly. And that's exactly what it is. It's if you Are a front end dev or literally anyone and you need a little bit of server, you don't necessarily have to spin up a server.

Wes Bos

Especially with like frameworks like, like Netlify.

Wes Bos

I don't know if you would call it frame no. I guess Netlify is not really a framework. But you simply just create a At least in my Gatsby website, just make a file and then, boom, that sucker is running on the server. And I can do literally anything I want in a Node. Js environment inside of that function, which is pretty cool. Yeah. And it's reminiscent of just running

Scott Tolinski

scripts from, you know, back in the day when we just needed to send an email.

Scott Tolinski

You just have a script that would collect that post request and send an email. So in the server, it's fine. It's like now we can do all of that on JavaScript without having Worry about our own server without having to have it on a, just a general shared hosted plan or something like that. So it's, yeah, it's it's funny because it is it's another way that Everything that's old is new again, but in the same way, it's totally new. Yeah. I was just gonna say that I I usually kinda,

Guest 3

imagine serverless functions as Code that can provision itself, where you just, you know, write the file and it'll take care of Spinning up an instance that will be there to serve the traffic, and it'll take care of kinda spinning it down when it's not needed anymore, which is also interesting from Like a cost perspective.

Guest 3

And then there's the aspect of kinda the deployment and versioning side of it, which, platforms like Netlify and others make make possible for you because you just put those files alongside the rest of your site and they're Deployed and versioned alongside the rest of your site. So if you have, like, you know, if you wanna do, like, a rollback, then your Functions will kind of follow the same version, and and everything will will be in sync,

Wes Bos

which is something quite quite powerful as well. So we have serverless functions, and a lot of people are still getting up to speed with it. And then in the last couple of months, we've been talking and hearing a whole bunch about Edge functions. So there's a there's a new one. Do you want to try to give us a rundown? Like, what what's the edge? What does that mean? People keep saying the edge.

Guest 3

And what are what's an edge function? So edge functions are still very much part of the serverless paradigm in the sense that they Still provision themselves. They still kinda make the server available to handle traffic and then take care of Kind of tearing it down when it's not it needed anymore.

Topic 3 00:07:19

Edge functions run closer to users for lower latency

Guest 3

I think the main Mhmm.

Guest 3

Distinction, when when we compare them to the traditional Serverless functions is where in the world the code is running. Where where are those servers that are that are kinda running that that logic? Because when we're talking about a serverless function, we we usually talk about, like, a regional function, like a piece of code that sits somewhere in, for example, if we're talking about the AWS world, let's sit somewhere in US east one and and that's where your code lives and and that's where kind of your invocations will will need to hit.

Guest 3

When we're talking about Edge functions, we're talking about duplicating that code to Potentially dozens of locations around the world. And so when your visitors make a request to your function, they will be routed to, the location that is closest to them, and that will deliver a much faster response with a with much lower latency.

Guest 3

And and and yeah. And that allows us to to create, faster and more kinda engaging experiences, with with customers.

Scott Tolinski

Yeah. So what you're saying is, basically, it matters less of the like, how how the the the technology behind how it gets run and more of the fact You you have access to the server wherever it gets run, whether it is at the edge or yeah. Yeah. Definitely. This episode is sponsored today by Hasura.

Scott Tolinski

Now Hasura is a service that makes it really easy to have a fully managed production ready GraphQL API In just about no time whatsoever, you can get started today for free in 30 seconds. Or if you wanna try out the Standard tier at 0 cost, you can use the code at tryhesura using the link in the show notes, or you can just do hasura.infoforward/free trial if you just wanna type it out.

Scott Tolinski

And there's a lot of cool stuff there and documentation and all these types of things to get you ready. But at The basics of this, Hasura is an awesome way to have a GraphQL API with just about no effort, giving you all sorts of things like Authorization and subscriptions just, like, baked right in. Not only that, but there's a lot of tools for data relations, especially data relations across API so you can have multiple services and have that data relation happening without having to worry about the dreaded n plus one issue where You're after code in some special data loaders and stuff. None of that. You don't have to worry about any of that. No more no more data loader worries with with Hesara because that's something that I don't I don't know why I need to worry about that, but I gotta worry about data loaders now that I have a GraphQL server. No thanks. So Hasura can take care of all of that and more. So check it out at hasura dotinfo.

Scott Tolinski

Use the coupon code, try Hessara. And, again, only the first 100 people who Use this coupon code can get this deal, so go there right now and sign up. Thank you.

Wes Bos

I think an important thing to note here is, where where in the world are you based, Edward? Are you in the States? So I'm I'm in Portugal. I think this I'm in Canada, so I'm allowed to say this. A lot Times Americans think their experience is the same for the rest of the world.

Wes Bos

And a large portion of the Internet is hosted in Virginia or or in the US. And a lot of Americans don't understand Why would you need that until you go to somewhere else in the world? And for Canada, it's pretty much the same. It's pretty fast here. But If you go to other places in the world, can you actually feel that a website is sluggish? Yeah. I've I've, yeah, I've had that experience.

Guest 3

And, Yeah. You can definitely you can definitely notice that.

Guest 3

And I think there may I think that bias exists. Like, if you if you're based in the US, you think that your website has certain kinda you think that the experience is something that is not true for People, you know, in in other locations. And I I definitely think that Edge Functions can help with that. I don't think They will magically solve it for every single use case, and maybe we can talk a little bit about that. But I think it's it's a great tool To have in your, you know, in your arsenal as a as a as a web developer, because it does allow you to run logic

Scott Tolinski

Closer to where your users are. I don't know what you guys are talking about. Everything's really fast for me. It's super

Wes Bos

fast. Yeah.

Wes Bos

It it's so funny. Me and my wife were talking about the other day because someone's like, just go to Target or one day Amazon or same day Amazon. And we're like, the rest of the world does not Have those things.

Wes Bos

You have no idea how good it is for you to have those things. And the same thing is with the Internet as well as you don't realize How cheap your mobile phones are. I guess Europe is is pretty cheap as well, but, you got it good. Yeah. So let's talk about the use cases as well. Like, why what In what situation what are some examples you wanna use an edge function over, either a central server, or a central serverless function running in North Virginia or or wherever the other AWS servers live. Mhmm.

Guest 3

So maybe I can let me just talk a little bit about another difference that is important to note between, an edge function. At least from like, now we're talking more specifically about Netlify Edge functions. And I think this is true for most providers, but I'm gonna talk specifically About Netlify Edge functions here because there's a distinction in in, the the invocation model of these functions.

Topic 4 00:13:05

Edge functions can modify requests and responses

Guest 3

When we're talking about a serverless function, we're talking about a piece of logic that will always Terminate a request.

Guest 3

So you add a file to your project that will automatically get assigned a URL Path. So your function's like hello world and you'll get like a .netlify/function/helloworld, and then you hit that URL, And the response will be terminated with whatever, data you choose to return from your function.

Guest 3

And that can still be the case with, with an edge function, but edge functions also allow you to run-in this like in this Middleware, pattern where you're able to make a function intercept Any request as it comes in, and also modify the response at as it comes back out.

Guest 3

So for example, you could have an edge function that will maybe read a header From the request, and it will run some logic that validates that header. Does this header contain like a valid JWT token with the right permissions to access this route.

Guest 3

And you kinda run all of that logic in the edge function. And if you if it does Kinda if you validate that it does have the right permissions, then you'll let the request go through and follow its normal course. You just say, let this go through.

Guest 3

And Because we run-in this middleware pattern, the request will then hit whatever endpoint it would Normally hit if the Edge function wasn't running. So it'll hit, like, a static asset or an HTML page or maybe a serverless function that will run other things.

Guest 3

And if you if the validation, doesn't succeed, then you can just do a rewrite or redirect to a page for, like, for example, your login page. So this is an example of a of a use case of you, like, intercepting a request, as it as it comes in.

Guest 3

And you can also do things that actually modify the response as it comes back out. So you could have, Let's say that you have a page that renders some some HTML and you want to maybe modify Some parts of those, of that HTML page based on where your users are. So you wanna check that if my, visitor is in Portugal. You're gonna replace this image tag and instead of rendering a burger, you'll render like an image of a hot facial, whatever, because we do love that part too.

Guest 3

And so it it it allows you to, like, dynamically modify the response before it is delivered back to the client.

Guest 3

And and I I wanted to to kinda mention this middleware pattern because I think it it Create some very interesting opportunities for people to to to add dynamic behavior to their pages that you wouldn't normally do with the serverless function because the serverless function usually just terminates,

Wes Bos

a response. Awesome. That that makes a lot of sense is that you can just jump in at any point. And, like, that would also I was thinking about that a couple years ago, That you've got, like, images.

Wes Bos

And if you wanna be able to protect those images, you really have to build your own server To intercept all those requests and then you have to proxy all that data through. So with an edge function, you could just throw it in the middle. In the middle. I love middleware and I think people listening will really understand that because there's a lot of express users or connect users on this that listen to this podcast, and they all understand how middleware works. You You jump in, you grab the thing, you can change the request, you can redirect it, or you can simply just check for something and pass it along to the next guy. Right? So that would be kind of a cool use case with with specifically with images. I like that a lot. And you can also,

Guest 3

you can ask you can also, like, Chain multiple edge functions.

Guest 3

So to go back a little bit, the way that you Create a nets function in the 1st place is you declare, you you write a file either in JavaScript or TypeScript.

Guest 3

And then you need to tell the platform what are the routes, that this function will run for. So you can say that it runs on on a specific path like / hello, and that's the only route where the function will execute, or you can use like a wild card thing so that it it'll run for multiple route. And you can also have more than One function running for a given path. So you can treat these as, like, composable Building blocks, and you can from an edge function, you can decide to early return, and so the next Function in the chain will will execute, and you can use this pattern to be like yeah. You can build your own, like, authorization layer as an edge function, then you can distribute with with your team and they can just add it to their to their flow and it'll kinda it'll work.

Guest 3

So, Yeah. I think that I think that creates some interesting some interesting, possibilities for people to to build functionality with their functions.

Wes Bos

Another, use case that I thought about recently is now that I have edge functions in my head, I've been sort of, like, going through life with this newfound Outlook on life. But, like, I've been listening to a lot of podcasts, and they always say go to, like like, I don't know, coolshirt.comforward/stevo or something like that. And they have these referral links. And I was like, man, like, Top level referrals.

Wes Bos

And I was like, they you would have to have full buy in from the application To do those, like, forward slash. But now I'm thinking, like, oh, no. You don't have to have that, like, referral URL logic as part of your app. You could throw that in an edge function, Set a cookie of whatever referral and then continue on your way. You don't have to bother the product team with integrating this top level Middleware into it. So is that another, like, use case that you might see someone using? Definitely. I think that's a I think that's a great example.

Guest 3

And you touched on something really important, I think, is you don't, like you're you're suddenly able to Tap into this lower level set of capabilities like messing with the cookies that are part of the request or completely changing, like, the caching headers. And so it it's almost like with great power comes great responsibility, like, you you have, You know, you you have access to effectively programming your CDN, And that's that's, that's quite a powerful thing. And and and the the use case that I just mentioned is definitely, an example of that. That's a that's a great one. Let's talk about one of Sponsors, WP

Wes Bos

Mail SMTP. This is a WordPress plug in that will fix all of your delivery issues with, with WordPress. So what it does is they reconfigure the wp underscore mail function to use any of the SMTP Providers out there, they they have a whole list of them here, Sendlayer, SMTP.

Topic 5 00:20:21

WPSMTP sponsor ad

Wes Bos

My favorite is Postmark.

Wes Bos

So what it does is you configure it to use Postmark, And they will send all of your mail with WPSMTP, via whatever service that you've you've configure it with.

Wes Bos

On top of that, they add a whole bunch of, features like email logs. What emails were sent? Who knows? Well, now you can.

Wes Bos

Email engagement tracking, visual email reports, weekly email summaries, integration with popular providers like Sendlayer, Gmail, Outlook, and more. It helps you avoid the spam filter, and your emails will land in the inbox every single time. You really shouldn't be sending, email, Just the regular PHP mail function anymore. Those are not ever gonna end up in the right place that they need to. So check it out. You get 50% off Or you can start with the free version at wpmailsmtp.comforward/syntax.

Wes Bos

Thank you. Wpmailsmtp

Scott Tolinski

For sponsoring. Okay. So, Deno, why why use Deno over node especially for these types of things or maybe even not especially for these types of things. But, Dino, maybe maybe give it a a quick two second what is Dino, and then maybe why why might You choose Deno for this type of application.

Guest 3

So Deno is a JavaScript, runtime.

Guest 3

So, you know, if you if you're a JavaScript developer and you don't know what Deno is or you don't You're not even familiar with what a runtime is and if these are, like, confusing terms to you. Maybe we can like, a a good comparison would be if you're, writing JavaScript in the browser.

Guest 3

You have a set of primitives that are Made available to you like the window object and kinda DOM manipulation things. And if you've ever, Build any server side code in node.

Topic 6 00:22:44

Deno overview

Guest 3

You still have the same language, but you have a different Set of, like, primitives, you can suddenly interact with a file system and you have these kinda node specific APIs that allow you to do that. And so Deno is just another one of it it it's the same transition from node to Deno then from the browser to node, I guess. So it's it's still The same language, you still author just JavaScript or TypeScript, but you're running that code with a different set of Vocabulary if you want, these primitives that that you can use. And Dino is a Secure and performant runtime that was actually created by the same person that Created Node, which is kind of interesting.

Guest 3

Yeah. Yeah. And it it's built with performance in mind, which was, one of the big reasons that we choose it and that it that it makes more sense to run Deno at the edge Then then node because kinda startup times and just performance in general is, is something that is top of mind, for for Dino.

Scott Tolinski

But, yeah, that that was longer than 2 seconds. I'm sorry. No. No. That's that's a okay. Yeah. Yeah. I think I think in general, you know, we We haven't really talked too much about, like, the length of time in which a a function needs to execute in. But when you're dealing in these Functions, you know, speed in which the function executes is of paramount concern. So that that makes a ton of sense if Dino is seen as a more performant option. Yeah. Yeah. Definitely. So with Dino,

Wes Bos

you are running in like you said, you're running in a different Environment. And I I got tripped up on this the 1st time I tried Cloudflare Workers. I tried to npm install something, and it didn't work. And I said, like, what? What's going on here? Why is it? And then I realized, oh, like, this is not like, not every environment that runs JavaScript is the browser, A web worker or Node. Js on the server, there there actually is lots of environments where JavaScript can can run-in.

Wes Bos

And some of those have trade offs in that you get something in return for something else. And I think with Dino, you You get a smaller you get a more of a limited environment, at least right now, in in in terms. Sorry. In trade for speed. Is that true? Like, what are the limitations of using Deno over a regular Node. Js function?

Guest 3

So, yeah, the the the package community is definitely, an important aspect here. If you're So the the the node ecosystem is a lot more contributors.

Topic 7 00:25:38

Differences in Node and Deno package ecosystem

Guest 3

It's a lot more active. It's an older ecosystem as well. And so If your application heavily relies on packages that were built by the community, it might not be a trivial Job just migrating that over to Deno because it's not guaranteed that a node module will work In Deno, and in fact, if it uses any of the node APIs like write disk or or or other Operations, then it will not work because as we said earlier, we're we're operating with a different set of of primitives. So that's definitely something that, You know, I wouldn't I wouldn't necessarily call it a limitation, but definitely something that people need To, you know, to take into consideration if they're thinking about migrating something from node to to Deno.

Guest 3

And another, aspect worth mentioning just on the topic of kind of packages in in the community is that Unlike node where you need this other kinda sibling tool called NPM, which then pulls packages from this registry, 3, with Deno, you import packages directly from a URL.

Guest 3

There's no, like, tree and no kind of package dot JSON where you declare your dependencies and your versions and things like that. You just import From, you know, from, from a full URL that kinda serves your package, and that can that is also like a A paradigm shift that, that some people might be surprised by when they're kinda switching from node to dino.

Wes Bos

Yeah. You see a lot of people being like, like, what do you want from Dino? There was a threat on Twitter the other day, and a lot of people were saying a package manager.

Wes Bos

And they're kinda like, that's kinda What we're against, right, is when you run a, an edge function, are those packages, like are they pulled downloaded ahead of time or or whatnot? Or are they done on the 1st run? Yeah. So they're pulled ahead of time, and there's,

Guest 3

caching in place To make sure that you, you know, don't unnecessarily need to pull the same version of the same package over and over again, It's actually, handled by the Dino CLI.

Guest 3

Yeah. And it just it just ensures that you're not Unnecessarily pulling stuff over the network. Okay. And

Wes Bos

why not just run Node. Js functions on the edge? Like, why not put a whole bunch of node servers Wherever people are and run them. Like, why do we need to run this in Deno and have this different environment where we now now we need to think about, Okay. Well, this is running in an Edge function, so I can't do any of my node stuff that's specific to node in there. And I got to make sure that my packages also work And Dino as well. Like, what's the benefit there? So I I think there's a lot of

Guest 3

evolution, in in the space, a lot of stuff going on.

Guest 3

And I think we're seeing different run times being built with An edge computing model in mind, one of them being Deno.

Guest 3

And to answer the question specifically of why not node, I think mostly is around performance, and around the idea of, you know, how do we spin up a node, isolate quickly enough that it can serve a request in this, like, single digit or low Double digit millisecond time. That goes a bit, into the weeds, like, more than I can kinda give you a solid, explanation about, like, the way that Dino kinda uses, rust to to to kinda do some of these things, kinda is aligned with their vision of making something that is really performant, and I think it will be A little bit challenging to kinda do the same thing and achieve the same level of performance in node, But then again, there's a lot of movement into space, so maybe we will see something like that. Do you foresee a future

Wes Bos

where people are writing packages that work anywhere? Like, do you think that's gonna be the new thing? Like, A couple years ago, people were big on, like, this is an immutable package. We're all writing things in this way. And and now I've actually found a couple packages that work.

Wes Bos

They work both in the browser and on the server, but also they work in a web worker, which means that you can throw them in, You can throw them in Adena or you can throw them in a Cloud for a function. Do you foresee that being like the next big thing where people say, okay, I'm going to write this really good Slug library. Or I'm gonna I'm gonna write this a really good data management or or whatever, but it'll it'll work anywhere. Do do you think that's gonna be more popular coming forward? I think so. I think if Deno if

Guest 3

Deno and other kind of JavaScript run times, start to get More traction, then it makes sense that, you know, package authors try to create things that can be used relatively easily, across those those run times. And I think that is already possible today, as in We talked earlier about how we have different kinda primitives on these different run times, but it's Totally possible to, like, build a package that contains, like, the core functionality and then maybe different adapters that then do the last mile, So to speak, and kinda plug into node or plug into d node and plug into other run times. And so, I yeah. I I think that that makes a lot of sense, and I can see the, you know, the community kind of going in in that direction for sure. Like, you have, like, a save function. Yeah. And then this you could have, like, local storage adapter or node adapter, Deano adapter or key value store adapter or whatever.

Wes Bos

Yeah. Oh, I like that. I'm glad to ask you that because that's something I've been thinking about. I didn't think to I didn't think about the, like, sort of adapter approach.

Wes Bos

Let's talk about Our sponsor, it's another podcast. Can you believe it? This is called the Postlight podcast. So Postlight is A strategy design and engineering firm. They work with some of the world's biggest organization to build platforms to scale to hundreds of millions of users, and they have a podcast with their founders, Paul Ford, Rich Ziadi, Gina Trapani, and Chris Lissacco.

Wes Bos

They talk about tech, business, ethics, and culture. They've got hundreds of episodes, here. Just let's take a quick look at some of the The ones they've had recently. Efficiency is highly overrated. Some life advice.

Wes Bos

Vanity purchases on Elon Musk and Twitter.

Wes Bos

Kids and phones, parenting and technology, where's that thing on impatience as a leader? Really good. I very much, enjoy everything that Paul Ford and Gina Trapani put out. So I'm gonna be checking out this podcast myself. Sounds awesome. Check it out at post lite.comforward/podcast.

Scott Tolinski

Yeah. What a collection of talent that is. Right? Yeah. Well so okay. So what about What about databases here? You know, one one thing that's always been kinda weird for me is that whenever you have a serverless function that's working with a database, You have to essentially open that connection and close that connection each time, right, or at least on the surface.

Topic 8 00:33:05

Postlight podcast sponsor ad

Scott Tolinski

And I I think for the most part, that's not like a huge huge problem, but that doesn't seem super in infinitely scalable to do stuff like that.

Scott Tolinski

So we have something called con connection pooling or database Mhmm. Pooling.

Scott Tolinski

Is that something that you think is is an important thing, or is that just Something that only bigger organizations seem to worry about. Is that something that your average developer working with a A serverless function in a database needs to think about. Yeah. That's that's a great question. And

Guest 3

you're you're right in that A a typical database was not built for this scenario where you have Hundreds of thousands of connections being created and destroyed over and over again.

Guest 3

And I think we've been so so yeah. So if you try to use a traditional database with a serverless function, you will At some point, hit those problems.

Guest 3

There are a bunch of companies innovating into space and in creating, Almost like serverless adapters to traditional database engines like MySQL and Postgres and things like that, Where they kinda give you, an endpoint that you can hit and that will, under the hood, Manage all the complexity of, of like connection pools and and things like that. So that's that's the first part of this, of like how do we have a database existing in this new serverless world? And then there's a second, step that is even more exploratory, I think, at this point, which is, a distributed on the edge version of that serverless model.

Guest 3

And I was I was kinda alluding earlier to the fact that maybe an edge function will not magically solve all of your use cases and in some situations you might not Want to use 1. And I think, an example of that is if you if your function needs to Talk to a database, and your database is sitting somewhere in a a centralized region, then Suddenly, it you know, the benefits of having your code running in dozens of servers around the world becomes Questionable because you will still need to go back to the centralized location to talk to your database.

Guest 3

So is that, you know, is that a good trade off that we want? And we're seeing a lot of companies exploring And innovating in the space where they can actually give you different regions for your database. Yeah. So for example, with with PlanetScale, they recently launched this, This option that l that give you, like, read only regions for your database.

Guest 3

So you still have, like, your main region for your database where you do your rights, But then they give you, like, a set of read only endpoints in in different regions around the world, and that creates a really interesting pattern when you couple that with edge functions because you can you can have a function that is Kinda running really close to your users and those and that function can also hit a database that is also close to your users. And that's where I think, the database story starts to become really interesting.

Guest 3

And so to answer your question, I think Definitely, the traditional databases are sort of in a different world, but we are seeing more and more innovation that bring them Closer to the serverless paradigm and now closer to the serverless paradigm on the edge, which I think is really interesting.

Scott Tolinski

Yeah. It's funny. I I've I've been seeing this planet scale around for a while now, just their logo popping up, and I've never really gotten the the why. But I think this makes it a little bit way more clear to essentially why this is an interesting or exciting option here.

Guest 3

I have to dig into this. Yeah. I haven't fully explored everything that PlanetScale can give you. I was just exploring this the other day because as soon as I Saw something about, like, a multiregional database. I'm like, I was I was all over it, and and that's definitely a a use case for it.

Topic 9 00:38:13

Languages used to build Netlify Edge

Wes Bos

Nice. Cool. That's cool.

Wes Bos

A question about, like, actually implementing edge functions at Deno. Like, we know the edge Functions run-in Dino, at Netlify, but the logic all of the logic surrounding edge function. Did you write that in Dino as well or, like, what language do you use to write stuff at Netlify? I'm always curious about that. Yeah. So we have a,

Guest 3

we have different, languages that we use for different for different services.

Guest 3

We have a What we call the the bootstrap layer, which is this kind of logic also written in Deno That takes care of, like, pulling in, all of your functions and then, Injecting our runtime API. So the the the interface that is available to you, when you write a Netlify Edge function, we can talk a little bit about that because it it has some, like, design principles that that that I think are kind of Worth touching on.

Guest 3

Yeah. And so that that layer that kinda bridges the gap between

Wes Bos

What is a Netlify function and what is run kinda closer to the metal on Deno that is Yeah. Also run, that also written in in Deno. Excellent. Wow. That's cool. Yeah. Dino and prod. Yeah. Definitely. That's funny because Scott and I, like, 6 months ago, were, like, yeah, we still haven't really heard much Much about like like who's actually using Dino? And then just boom, in the last couple of months, like, everybody's coming out swinging, being like, no, like, this is legit. Like, a lot of people have been working on stuff. So it's really exciting to hear this. Yeah. Yeah. It felt quiet for a little while, but it seems like their the in inner community Was not quiet. Right? It was like They were heads down working on stuff, I guess. Yeah. Yeah. Yeah. We we actually,

Guest 3

started experimenting with Deno, At Netlify, specifically for the context of, running stuff on the edge a while ago. So well over a year ago. And we actually Launched this, this product called Edge Handlers.

Guest 3

It was under, like, a, a private beta program, And it was solving this exact problem. We wanted to allow customers to run stuff, on the edge and we Built we were sort of building our own, runtime based on Deno.

Guest 3

And the reason that we ended up abandoning that and and kinda deprecating that in favor of edge functions was because We felt that, we even though we were solving the specific need, of our customers, We felt that we weren't, like, really moving the space in the right direction because we were effectively creating another, like, walled garden, another, like, proprietary, runtime that was specific to Netlify.

Guest 3

And Yeah. The reason that we ended up Building edge functions, this way and and and kind of partnering with with Deno on this is because we see Deno as, a new, like, open, runtime, for for the web, that is built, entirely in the open, and that is based entirely on open standards.

Guest 3

And and that we feel is The right direction, for for the community so that you're not writing a function that will work On Netlify, you're writing a function that will work in this open runtime that can potentially be used across different providers.

Guest 3

And that was a big part of, our decision process and in the way that we decided to build edge functions all the way to the runtime API.

Guest 3

And and the the kind of the surface that that you get is you write a function that receives A request and return and returns a response. And when I'm talking about request and response, I'm talking about the web standard Request and response objects. And that's like the simplest, most kinda spec compliant API that that we could think of. And anything that is specific to Netlify lives in this kinda Context object that you can choose to add to your function or not.

Guest 3

But all the rest is just, You know, using web standards, and and that's that's kinda the most exciting thing for me about about that is kinda building things in the open and not Forcing people to be, like, locked in to a specific provider. And I think that's so huge when you get into these types of things and then all of a sudden you hit Someone's proprietary format or something, and it just can really

Topic 10 00:43:20

Importance of open standards

Wes Bos

sour you on something. So, yeah, I think users will appreciate that very much so. Yeah. Because I we talked about this on our very first edge when I was like, it's it's kinda weird that there's so many providers of these edge things, but they all kinda implement their own Special sauce. And then, like, a week after we said that, they rolled out the, what's the name of the The winter

Guest 3

ciggy?

Wes Bos

Yeah. Yeah. That one's just so it's that's that's a great like, honestly, like, if you write Dino, it's almost less Proprietary that node because Deno is even closer to, like web standards than than Node. Js is. And now Node. Js is like, oh, maybe we should implement some of these standards as well. Like, we just got fetch and they're looking at a lot more. Beautiful. Let's move into the next section here, which is our questions and answers. We have a couple questions that we ask everybody that comes on. We always find a few useful nuggets here or there. You can answer as long or Short as you want, for these. And the first one we have here is, which computer do you use?

Guest 3

Oh, I use a MacBook Pro.

Guest 3

Still the Intel version, I've been dying to try the new almighty m one because I keep hearing that it's really fast. But at the same time, I keep kinda hearing people having problems with, like, compatibilities and stuff. And so, Yeah. I'm I'm waiting it out.

Guest 3

But, yeah, that's that's what I'm running on at the moment. For me too. Yeah. Yeah. What about,

Scott Tolinski

text Editor theme and font.

Guest 3

I use Versus Code.

Guest 3

I think I just used the default theme. I'm sorry to disappoint our,

Scott Tolinski

our listeners.

Scott Tolinski

Talking about this in the last episode, it's shocking how many people just use either the default theme or it's like they don't. It's like just the dark theme or just the light theme or the GitHub theme.

Scott Tolinski

And then for their computer, it's, like, always just a Mac. For phone, it's just an iPhone. For text editor, it's always just Versus Code. It's like you you hear tell of all of these super hackers using all of these, you know, really high-tech, you know, I don't know, customized tools. Yet had Anyone use Vim yet? And we only VIM. VIM. I only said Emacs. Yeah. Yeah.

Guest 3

I kinda lost the lost the habit of, like, Customizing things on my machine. I just use the default. The only thing that I've tried recently, which I'm still kinda Trying out and I've been really enjoying so far is Warp, this new, like, Hermes.

Guest 3

Yeah. We've talked a little bit about Warp. Yeah. That that one is really interesting, and I'm kinda excited to be trying something new and fancy. But other than that, I'm just really boring. What,

Wes Bos

have you have you hit any issues with Warp? I tried it a couple months ago, and I've been using it last week as well and enjoying it. Have you what have you liked about WARP, or has you have you had any issues?

Guest 3

I really like, like the auto completion thing works really well for me.

Guest 3

I really like the fact that you can, almost treated like a text editor so you can, you know, really select the command and change things in the command.

Guest 3

It's also really cool that it can Share like a live, like a live URL to, to the output of any command, and you can share that with someone from your team. I think that's really cool. The only problem that I've hit with it is sometimes and I couldn't figure out exactly when this happens, but sometimes, like the, pressing up to get you to the latest, to the most recent command doesn't really work for me. And instead, it just moves you between blocks In the output, I haven't figured out what what's going on, but that's that's not a Oh, I see. Problem that I face. Yeah. They they recently just rolled out the ability to keep your old prompt,

Wes Bos

which is, like, one huge thing for me because I was just comfortable with my existing, oh, my, is that a sage prompt? Yeah. If you like your old prompt, you can keep it. Yeah. Now you can keep it. They they tried to strong-arm you into using theirs, being like, no. Like, we know better,

Topic 11 00:47:16

Using Warp terminal

Scott Tolinski

but now they're I think they've relented and allowed you to use your own prompt, which is kinda cool. How do you stay up to date on web stuff? I mean, seeing as you're using Deno. Right? Deno is pretty high-tech. How do you Stay up to date here. Wow. That's a really difficult question.

Guest 3

A while ago, I've had to make peace with the fact that there's a bunch of Hot new things that I'll just won't know about. I will I will not be able to be across everything, and and that's okay.

Guest 3

I think I think there's a risk if you're in web development. There's a risk of of feeling that every little thing that comes out or every little that someone talks about, you need to know what that is, what that does, how that works, and and I think that can create, like, an unhealthy amount of pressure on yourself and and I don't, you know, I I don't like that. And so, yeah, I I try to Investigate the things that I come across in my job. So if if if someone on my team or in other teams is kinda Working on a new technology, then I will probably try to ask some questions and investigate, like, what this thing is about.

Guest 3

I will also, like, keep an eye on on social media and and see what some people that that are kinda that I follow are are talking about. But I tried to Yeah. Take it easy and and kinda not not kinda

Wes Bos

corner myself into learning new things all the time because, Yeah. I I can't do that anymore. Hey. Yeah. Yeah. I hear you on that. Yeah. Hey, I'm just getting old. Yeah. No. I think that's part I feel like that's part of becoming a, like, a senior or, like, a a more well rounded developer is just Being fine with not knowing absolutely everything because like like we've seen here today, you could probably figure it out. You released one of the very first platforms using Deno in production. He figured it out.

Wes Bos

Yeah. Yeah. That's great. All right. Last question I have here is, is there anything that you're really Excited about, in the future of web development.

Guest 3

If if edge functions aren't enough. Yeah. I don't want my question to sound boring and and Seem like I'm just plugging stuff, but I'm glad but I'm really excited about what happens on the edge. Even beyond, like, Netlify its functions, like, I'm really interested to see what happens in the space. We've been talking about What happens, like, in in in databases, in the database world, a lot of these companies are, like, doing amazing things in innovating, and I'm really excited to see where that takes to space, whether that will Change the way that people interact with databases and and and to what extent having the ability to run things on the edge will change the way people build websites.

Guest 3

So more than just 1 specific technology or one specific product, I'm really interested in seeing kind of what happens What what people build with this. Because as you you know, when you're rolling out something like this, you do your best to anticipate What people will build, how people will use this feature that you're working really hard on, but it's you know, At the end of the day, the most exciting thing is seeing people doing things that they haven't even imagined and coming up with use case that are, like, oh, I haven't thought of that, and that's really interesting thing. And so, yeah, I'm I'm I'm really looking forward to see how the whole edge space Kinda pans out. Yeah. Totally. Beautiful. Great answer.

Wes Bos

All right. Is there anything else that we didn't touch upon, today that you you would hope hope to touch upon or impart wisdom on our listeners? Yeah. I

Guest 3

just just be kind to each other.

Topic 12 00:51:24

Closing thoughts on being kind

Guest 3

I Yeah. You know, it's there's a lot there's a lot going on at the moment, and, you know, and we we talked earlier about, like, people feeling the pressure to learn everything and be on top of everything. And With everything that's going on in the world, that's even more tricky and even more unreasonable.

Guest 3

So, you know, just Be kind with the people that you work with, with the people that you interact with on social media, and and yeah. That's I know that sounds like a cliche, but that's that's the only thing that I can that I can think of to to to ask people just, you know, be kind. Beautiful.

Scott Tolinski

I love it. I appreciate that. Yeah. So do you have did you come with any, sick pics for us, things that you think are pretty cool? Yeah.

Guest 3

Had to think, a lot about this one because I didn't want to say anything about web development because I think we've we've, you know, talked.

Topic 13 00:52:23

Podcast pick - S-Town

Guest 3

We had the opportunity to talk a lot about that. And so, I thought I'd mention a Podcast that I've recently rediscovered, and it is probably my favorite Podcast ever, and I wish that I could unlisten, like, wipe it from my memory so that I can listen to it again. It's a it's a podcast called S Town.

Guest 3

It's from the same, producers as Serial which was, very very kinda, well known at the time. And, Estown just talks about this kinda really fascinating Person, and the the story is, like, full of twists and turns, and it's just a fascinating,

Scott Tolinski

podcast that I would definitely recommend. I will give this a listen to. I you know what? I've seen s tone pop up a whole ton of times, and it's one of those ones that I've never listened to. So, I just I clicked subscribe. I'm gonna have to listen to it. I think my brother was even telling me about it too, so I I have to get on that. Yeah. The gorgeous website. I'm just checking it out. Big fan of this. All that cereal money. They got that Yeah. Match up money.

Wes Bos

Yeah.

Wes Bos

Man, I remember when cereal came out and it was just, like, That was so big for podcasts. Change the game. Yeah. Yeah. Definitely. Yeah.

Wes Bos

Yeah. Wow.

Wes Bos

Alright. Last section is any shameless plugs, Twitter or URLs or anything you wanna plug.

Guest 3

Totally shameless, so go nuts. Yeah. Feel free to, like, to check my my Twitter and my website. So I'm at edwardobucasandedwardobucas.com.

Guest 3

My DMs are open, so I'm always Happy to chat with people about whatever they're building and kinda hear about, what they'd love to see, in the developer tooling space.

Guest 3

And, yeah, if you wanna give Edge Functions a try, just, go to netlify.com, find Edge Functions in the product list, And, yeah, if something doesn't work, ping me, and I'll make sure to fix it.

Wes Bos

Awesome. Thank you so much for coming on. Awesome.

Wes Bos

We're like I don't know. We're we're sort of, like, new to this whole Edge functions things. We've had a couple of shows on it, and we really appreciate having, like, an expert on That can can really explain it to us and whatnot. And it's it's really cool to see both that as well as listen to all the Dino stuff. So thanks so much. I really appreciate it. Thanks so much for having me. Alright. Peace.

Wes Bos

Peace.

Scott Tolinski

Head on over to syntax.fm for a full archive of all of our shows. And don't forget to subscribe in your podcast player or drop a review if you like this show.

Share

Play / pause the audio
Minimize / expand the player
Mute / unmute the audio
Seek backward 30 seconds
Seek forward 30 seconds
Increase playback rate
Decrease playback rate
Show / hide this window