651

August 9th, 2023 × #TypeScript#Posture#Cloud Services

Potluck × Is TypeScript Fancy Duct Tape × Back Pain × Cloud Service Rate Limits

Scott and Wes answer listener questions about TypeScript, preventing back pain while programming, and options for limiting cloud service costs.

or
Topic 0 00:00

Transcript

Wes Bos

Welcome to Syntax. Today, we've got potluck for you. Rid You're bringing the questions. We bring the answers. We got some really good questions. Is TypeScript just a bunch of fancy duct tape? How do you program without back pain? Why do cloud services not have cutoffs so you can't spend up $6,000 by accident? All kinds of really great stuff. My name is Wes Bos. I'm a developer from Canada. With me, as always, is mister Scott Talinski.

Topic 1 00:12

Scott and Wes introduce themselves and the podcast episode

Wes Bos

How you doing today, Scott? Hey.

Topic 2 00:39

Scott talks about needing a beach vacation next week to refresh his brain

Guest 2

Doing good. Feeling feeling ready to go.

Guest 2

I'm gonna be on the beach next week, And I think my brain needs it. I I've just feel it very I don't know what what it is. It's it's Monday morning, and 2 Monday mornings are just very tough. I I don't know what's been going on. The kids have a lot of stuff.

Guest 2

And, like, even, like, yesterday, we hung out at a local pool with the kids. And and Courtney and I, I think, just felt so tapped. We we felt so overwhelmed and overworked.

Guest 2

It was like the the kids fighting in the pool or doing anything like that was, like, just both of us would just look at each other and be like, oh my gosh. This is just, You know? But it could be much worse. So, you know, obviously, we're just very stressed out, with life stuff and, you know, ready ready for that beach time.

Wes Bos

Rid Life's a lot. We just I just got off a week of vacation where, my whole extended family came up to the cottage. And rid. It's the opposite of that is that there's cousins everywhere to play with, and there's parents everywhere to watch the kids. And It's I just this morning, I was just like, programming? Yo. What? What? How about rid. Drinking beer and Yeah. Ripping on the ATV. You know? Yeah. That that's a lot more fun. And then we just had a really good rid. It was it was really hard to get back into it. I was telling my wife, and she's like, have you never had that before, where, like, after a vacation, You don't wanna go back to work? Mhmm. And I was like, like, usually at the end of a vacation, I'm just like, ah, like, this is nice to get back to the swing of things. Rid Probably.

Wes Bos

I was I was in total relaxation mode, so I think it was a little hard to to get back up and running. But luckily, we just had a really good interview with rid. Andres, and and Thrice.

Topic 3 02:33

Wes says they just had an exciting interview about email that got him excited to get back into work

Wes Bos

And he I don't know. He got me really excited about email, and I think that rid Kick me kick me back into it.

Guest 2

We just had a really exciting interview about email, and it got me super excited to get it. Surprisingly.

Topic 4 02:45

Scott likes to get back into work after vacations, and talks about ways he prepares on Sundays

Guest 2

I am the type of person where, like, You know, before our vacation, Courtney was like, are you gonna want to work on on this vacation? Not as, like, a negative. She just wanted to know if I had to work. You know, we have, You know, to some context, we have an a new job. I have a new job. And, like, having a new job, you always want to, you know, show out and and do your best work, Especially early on in that job. So she was like, I understand if you gotta get, you know, stuff done or whatever. I was like, you know what? I'm gonna I'm gonna take this time, but I am the type of person too where, like, When my vacation's done, I'm usually, like, ready to get back into it. But I don't know about you, but, like, Courtney gets the Sunday scaries really bad. Do you have you ever heard that term before? Yeah. I've been hearing that a lot lately. Where is that where you just get that, like, gut the night before on Sunday night? Yeah. Like, on Sunday nights, it's, like, guaranteed she's gonna be more anxious. She's not going to sleep well.

Guest 2

You know, just The the the kids will set her off more, you know, in terms of, like Yeah. Really, you know, being able to get to her. But, like, I I think it's just the end of the day. It's, like, just the, the dread of going back to work. And it's not like she hates her job or anything. I I think it's just like those transitionary periods From going from not working to working your way, much more difficult. Where I'm like usually, I'm like ready to get back into it, you know? Totally. Yeah. Some rid I don't I don't get that at all, which is the best because I would get that for school. I remember being in school and being, like, Sunday night and just having that, like, pit. Like, I don't wanna go back to school.

Topic 5 04:16

Wes says he doesn't get Sunday night anxiety about going back to work since he works for himself

Wes Bos

And, working for myself rid Is the best. Doing this podcast is the best because, like, I I don't get that at all. If anything, sometimes my mind starts cooking on stuff the night before Sunday night, rid. And I have to bring out the to do list and do a little brain dump.

Wes Bos

Otherwise, I start chewing on what needs to be done because I go, oh, my gosh. What a busy week, Caitlyn. Like, I've rid I got so much going on this week. I'm I'm feeling a little bit stressed out, but then I'll I'll bring out my to do list and try to just dump everything into my to do list,

Guest 2

rid Sort it by anxiety, and then I feel a lot better. So I'm just really glad I don't get that. I like to do that, and and, typically, I'd like to do that. Look. What When I will do that is, like, right after we finish recording the podcast. Like, my post podcast recording Monday is like, alright. It's Monday. We finished recording the podcast. I'm gonna work on my to do list. I'm gonna work on my email, and I'm going to get set up essentially for the rest of the week.

Guest 2

Rid you know, my Sunday routine of you know, this is I think it's a nice little detour conversation, but my Sunday routine Yeah. Has always been a big part of my successful workday.

Topic 6 05:13

Scott details his Sunday routine to set himself up for a successful work week

Guest 2

My successful workday and successful workweek always comes in because every Sunday evening, once the kids are in bed, you know, 7:38, the kids are down, rid I can play video games a whole whopping 2 hours before bed. Like, that is my my Sunday Sunday routine, and I'm free to play video games for that time. And, for something for some reason about that, it it like, just having that that weekly routine there to chill me out on Sundays to get ready for the week and be like, alright. This is like your time for myself, which you don't get much of these days. So, like, it's great. Yeah. I love that. All right. Let's get into the questions here.

Wes Bos

Enough detail. Yeah. Yeah. Alright.

Topic 7 06:02

Scott reads a question asking if TypeScript is just fancy duct tape

Wes Bos

Go for it. You got the first one. 1st question from Dago. Dago says,

Guest 2

Is TypeScript just a bunch of fancy duct tape? I'm learning TypeScript, but so far I have noticed that Other than auto completions, it is pretty much saying good lies to ourselves and having easy code change Consequences, hints. So I think what they're saying here is, like, if you change code, here's some hints as to the consequences, what they may be. I have prepared an example where even I know the implementation is 100% right. So The Dackel has included a Stackblitz example here of basically an example where they know the implementation is 100% correct, But TypeScript is not happy.

Guest 2

And they say basically, like, hey, is TypeScript actually Saving us is the the root of this question. Does TypeScript save our bacon or is it really just a system in place to potentially Help us along.

Guest 2

And I think that's really what you do need to look at it as. And I wouldn't necessarily the way way this question is put Host is that, like, that's a bad thing. Right? Like, oh, it's a it's a bad thing that TypeScript won't save us from every potential situation, But also we have to do extra things to appease TypeScript sometimes even though the code works fine.

Guest 2

And I personally, rid One, the having to write code to a piece TypeScript is a trade off you make. You use TypeScript. You're gonna have to go out of your way. You're gonna have to take maybe the long way sometimes rid just to make TypeScript happy, you know. Oh, you have to you have to take this little detour here just to make TypeScript. I'm fine with it. That's the price of admission.

Guest 2

But is TypeScript just duct tape? Is it just kind of, you know, saving you a little bit these consequences? Yeah. It is. It's gonna save you those easy bugs. It's gonna save you those easy bugs that you might have to find yourself otherwise.

Guest 2

And then, therefore, you're not gonna have rid Spend that time finding those bugs. The compiler is going to find them for you, or even better yet, your editor is just gonna put a little squiggly in there while you're rid Writing so you could say, oh, yeah. I forgot to do x, y, and z or I still need to do this or this might have a possibility of potentially breaking.

Guest 2

It's not a rid. It's it's not a impenetrable system that if you follow TypeScript, your code will be perfect every single time. And also even if your code is perfect, That doesn't mean TypeScript's gonna be happy 100% of the time. It's it's definitely a tool to help rather than, you know, an all knowing god.

Wes Bos

Rid The example that he gave here is he has a function that takes in a string and returns a texture. A texture is curly, wavy, or straight.

Wes Bos

And that's a union, so a list of possible options, curly, wavy, or straight.

Wes Bos

And in there, he's checking if the inputted value is both a string rid And it is in a list of possible, textures.

Wes Bos

Rid. And return from that is it says it's just a string, but it should be returning a texture. Right? And I think the issue with this is that rid. TypeScript doesn't run at runtime, meaning that it doesn't know the value of the rid array. So he has he has a type curly, wavy, or straight, but then he also has an array, curly, wavy, or straight, which is simply just, rid an array of strings.

Wes Bos

So in order to make this, like, you kind of wish that it would realize, okay, well, the only possible options in this array are Curly, wavier, straight.

Wes Bos

And I think TypeScript is getting mad here because it's a possibility that that rid Could change. Right? And you have you would have to put a custom type guard in here instead of just using straight up includes. I actually talked about something similar to this where rid Filter? You know, remember we were, like, using filter. We had 2 different types, and you filter for a specific type of 1, rid And and TypeScript doesn't realize that you filtered it at that point. Somebody messaged me and said TypeScript 5.2 fixes that, which is really nice. So I think, yeah, there's there's a lot of like annoying little things here where any dev can look at that code and say, there's no possible situation rid Where I can see that this would be a string, it's going to be one of those union values there. And in order to make this work, You have to cast it or do a type guard. And I I sometimes run into this as well where, like, rid I look into a library and go, oh, how are they ensuring that it is of of a specific type? And you look into it, and they're just using as. You know? Totally. Yes. Exactly. Me. You know? And, Unfortunately, yeah, that's that's the case in in some use cases. So is it a bunch of duct tape? I don't I don't think it's I wouldn't go that far, rid. But it's certainly not going to catch absolutely everything, especially once you start getting into these types of things. Rid In your case, I would write a custom type guard to make sure it's in there. And also I would generate I would not duplicate the union and the array of possible values.

Wes Bos

Rid I would just create an array of the values and then generate a a type directly from that. So, I don't know, some sometimes you see people saying this, but Certainly wouldn't want to go back to writing just regular JavaScript even if you're just using it for the at the very least, if you're using it for the autocomplete,

Guest 2

man, is it worth it? It's worth it. And you know what? I do have to feel I feel like it is a little bit of just duct tape, but maybe like the the next level up of duct tape. It's not like It's not quite like a, a foundation of a house and it's not quite duct tape. It's a little bit in between, you know. A strong wind can blow it over, but it definitely is going to rid. Save your bacon for a lot of time, you know.

Topic 8 11:28

Scott concludes TypeScript is a helpful tool but not a perfect all-knowing system

Wes Bos

Exactly. Yeah. I the amount of little edge case y things, especially, like, a lot of my Initial hate of TypeScript was just me not realizing, oh, that could be a possible bug. Rid. And as much as you think My job is good. Never it's never gonna happen.

Wes Bos

You're making me add you're you're I'm probably doubling The amount of code I have to write for this function just to satisfy TypeScript Mhmm. Which is a little bit of a bummer. But in reality, a lot of the cases are you're rid.

Wes Bos

You're stopping a potential weird edge case from being from from, like, crashing your application. Yeah. Totally. Yeah. Next question from Christian.

Wes Bos

Could you share with us how you go years into rid. Programming without back pain. I'm coding as much as I can every day because of the session, but also start feeling some back pain. I am going to the gym, rid by foot, and I stretch occasionally. Is that too little? Thanks. Hope you have an amazing day. Yeah. This is something that is Kind of scary to me is that I'm luckily, I don't have any back pain or anything like that. But rid. It would be kind of scary to to do that type of thing, and I am kind of getting more into stretching. I know we did a show probably 2 years ago rid where Scott talked about stretching. And it's funny to me. I kind of see it as I'm gonna relate this to skateboarding, is rid 15 years ago, skateboarding was just a bunch of stoners going around. But now if you look at Who the top skaters are these days? They're they're athletes. Yeah. Like, they have like, look go look at what Nigel Houston does. You know? Rid He has so much regimen.

Topic 9 12:34

Wes reads a question asking for tips on programming without back pain

Wes Bos

I follow him on Instagram. I never see the guy take a sip of a drink. He's at parties all day long. I don't know if that he probably drinks, but he obviously is so dialed. And anytime he's eating something, it's like, oh, he cares about literally everything because he's an athlete. And us as developers, we're athletes. No. We're we're not athletes, but It's a bit of a stretch. We're athletes. Yeah.

Wes Bos

Mathletes. You gotta think about, like, okay. If I wanna be the best dev I can be, You you do have to take care of your your mind and body as well. How you do that, I will ask Scott because that's kinda his route here.

Topic 10 14:22

Scott talks about the importance of posture and provides tips for improving posture at a computer

Guest 2

Yeah. You know what? I, you I have a long history with stretching. I grew up my dad was a gymnast, So he, instilled stretching, you know, very early on in life. Like, if we're watching TV, my dad was sitting on the floor stretching. So, like, I grew up with that kind of model. So I I'm the I totally inherited that. I'm stretching all the time. I one of the reasons I got a standing desk is so I could stretch at my desk. I I I'll put my foot up on the desk. I was kinda largely known in in some of our offices as the guy who will Occasionally, sit on the floor and stretch at work.

Guest 2

So so I'm I'm a stretcher. I I like that stuff a lot. But, you know, more importantly to me than even stretching or or Mobility stuff is straight up posture lately for me has been a big topic in my world about back pain.

Guest 2

And one thing that I've begun to really notice in the world, not just computer programmers, but in the world, every person Has this awful posture where their head is forward and their shoulders are slouched forward. Everybody has this, like, forward head posture, And I, you know, I even have it too. I mean, it's not like bad because I'm constantly thinking about it. One of the the big Tips that I learned very recently from physical therapy to fix part of this posture issue, especially shoulders based, is that when people often are told To sit up straight. Like, one of the first things they do. Right? And this is this is gonna be really good for anybody who's sitting all day long. You get told to sit up straight. And what do you what's, like, the first thing you do? You, like, pull your shoulders back and, like, sit up. Right? Yeah. You're, like, you know, I try to sit up straight. But a physical therapist that I have, because I've been having some some some weird I I messed up my rotator cuff, so I've been going in for that. So But she was telling me that, like, part of my posture issues is simply that I'm not pinching my shoulder blades together.

Guest 2

And it's not like I'm not thinking about the tops of my shoulders. Like, typically, when you think about pulling your shoulders back, you're thinking about, like, actually pulling your shoulders back. But it's much more subtle than that where I'm thinking about the middle of my shoulder blades and just pinching them together. And I'm not thinking about my shoulders long. My shoulders are loose. And that to me, that has unlocked every single little posture issue that I have. If I'm feeling any type of back pain, all I think about Is pinch those shoulder blades together in a way, and it just fixes everything.

Guest 2

So my solution To you is to 1, be cognizant about your posture.

Guest 2

That that head forward posture from looking at your phone or shoving your face near your computer is a rid. Real problem long term. And not only that, it'll it looks wild. When you go out in public and you see people, their necks are permanently stuck forward, You can tell. Like, that guy's addicted to his phone, because he's just shoving shoving his head forward. But it's gonna cause you a lot of a lot of shoulder pain. It's gonna cause you back pain. And as somebody who has back pain, like, that stuff does not go away. I I back pain from, like, spinning on my head and stuff. It's a little bit different. But, rid that won't we if you have back pain that's persistent and long lasting, it it can be a heck of a thing To fix, to get rid of, especially the longer you go without fixing it. So really invest time into getting your posture worked at. And and Posture is one of those things that you're not going to be good at it for, I don't know, a long time because it takes Actual muscular training for your body to adjust.

Guest 2

Mhmm. So if you fix your posture 1 minute, like, maybe even 30 seconds later sometimes you're out of that posture. And just be cool to yourself, be kind to yourself, fix it, and then move on with your day, and then think about it. It's a it's it's It's a long term thing. You gotta just think about and improve. But either way, work on your ergonomics. You don't have to, like, Fall out and do ergonomic everything.

Guest 2

But Yeah. Posture at the very least is a big one. You know, stretching.

Guest 2

One one thing, the best The best dynamic stretch you can do in the morning to help with your back is to do you put your your arms up at, like, You know, 40 or at 90 degree angles. And you just do really light twists with your shoulders up, Just light twists where you keep your lower body in the same spot and your upper body twists. Just mobilizing your spine. And, Wes, ideally, you want to move your head as well. I'm just having Oh. Yeah.

Topic 11 18:31

Scott suggests dynamic stretching in the morning to help prevent back pain

Guest 2

I'm gonna Here I am. I'm cracking all over the place. That wakes up your whole spine. It'll get your your back muscles warmed up and moving, And those are the types of stretches that you'll want to do more so than grab and pull and hold. Because those static stretches where you're grabbing and rid and holding. They're good for, like, building, like, end end length of, like, rid distance in terms of, like, how far you can go and stuff. But this dynamic stretching where you're where you're moving through the motion is going to help build muscle. It's gonna help Wake, you know, warm your body up a little bit and just, it it's a much better warm up.

Guest 2

That's a mistake you'll often see in athletics.

Guest 2

People think that I'm gonna I'm gonna start an athletic thing, so I'm gonna stretch my legs. I'm gonna put my leg out, and I'm gonna just stretch it like you did. That's actually wrong. You should be doing dynamic squats where you're standing up and getting up. You should be doing, like, different types of movements To warm your body up rather than static stretches. Static stretches are for the end after your athletics.

Guest 2

But, yeah, I could go on all day about this stuff. We could do it with the show.

Topic 12 20:10

Wes refers back to a previous episode on stretching for more tips

Wes Bos

Rid Go back and listen to the episode on on stretching because it's super interesting.

Wes Bos

Actually, I have 2 more things to add here is rid So I'm at a cottage right now where I have my my cottage office.

Wes Bos

And the one thing I have a Herman Miller Aaron at both rid Locations at home and at the cottage. And I I don't have the standing desk here, which I don't stand, Almost never at home. But the fact that you can dial in the height perfectly at home is so good. So now I'm thinking I have this beautiful maple slab desk And I'm thinking, like, maybe I should buy a set of, adjustable Legs for it. Yeah. Legs for it. It doesn't have to be the, like, rid The standing ones because I don't stand all that often, but I just want to be able to set it exactly how I want it. Because right now, I have my chair a little bit higher than I would like, and I have to do that because of how high the legs are on my desk. Right? Yeah. So it would be really nice to do that. And the other thing I'm talking about is rid. About a year or 2 years ago, I I sick picked a a pillow that was, like, shaped to your head.

Topic 13 20:40

Wes and Scott discuss pillows and mattresses for proper spinal alignment

Wes Bos

Rid. Do you remember that where it's like basically, you lay on it and it, like, supports the back of your neck. And, like, rid. That was such a big benefit because I would often wake up with, like, a really sore neck or, like, a headache.

Wes Bos

And again, I came to the cottage. I don't have that pillow here, and I rid. Noticed that immediately when I woke up.

Wes Bos

So I was, like, looking into it. I was like, oh, maybe I should buy 1 for for here or just bring it with me. But everybody's talking about these cube Pillows right now? Yeah. I see them. Like a hard square? Mhmm. I think I wanna try that. It seems so cool.

Guest 2

Seems like it that would work. I got a pillow matched to our mattress.

Guest 2

Like, we got, like, one of those Tempur Pedic mattresses. The, like, Yeah. The heavy phone that you sink into, and I got a they they pitched me on this really thin pillow, and I'm like, I don't know, man. I'm like the type of guy who's got, like, rid pillows are, like, a little bit more there, and they're like, no. That's messing up your neck. You want a really thin pillow for these reasons.

Guest 2

And I went to the thin pillow, and I have not looked back. Rid I'm very into it. So yeah. I don't know.

Wes Bos

There's so much there. Yeah. There's so much for like, it's rid It's such a personal thing. Like, that's my problem is when I have too thin of a pillow, I'm all creaked up. So I need, like, a a more of a significant pillow, but not too much. And it's just a I was very happy when I found that pillow that actually worked for me.

Guest 2

Nice. Yeah. And one last thing, you're talking about the skateboarders.

Guest 2

If you wanna see that active right now, Wes, the breakdancers, now that they're going to be in the Olympics next year, they have rid. From in, like, 2 years. Now the Olympic team is training at Olympic facilities, and it's like like, last year, they were not training at Olymp they were training in some guy's backyard. And this year, they're training in Olympic facilities.

Guest 2

It is, like, a different world, and you can already see the level changing in, like, one year. It's it's been drastic. Yeah. It's it's wild. They went from old English forties to smoothies real quick. Yeah. Right. That's it, legitimately. In fact, our our our Crew. Wes, you laugh, but our crew in breaking had an official forty. Our forties was Mickey's.

Guest 2

So After every battle, we would get Mickey's, which was a 40, and, celebrate with Mickey's. That was our favorite.

Guest 2

I don't know I've ever had a 40 in my life. Oh, man. That was our. They're they're really super cheap.

Wes Bos

Really? It's like Yeah. They don't have that. Canada.

Guest 2

I don't even know know if you can buy that in Canada. Malt liquor. Just big old big old beer. That's not good. It's not good beer, but when you're in college and they're, like, $4 or something and that's all you need, it's rid. Good. Yeah. Alright. Slightly annoyed in Michigan. Hey, guys. I'm slightly annoyed by all these cloud services not providing an option to Shut off services when the spending limit is reached.

Topic 14 24:03

Scott reads a question asking why cloud services don't automatically shut off when spending limits are reached

Guest 2

Best you can do with most Netlify, Vercel, etcetera, is to set a billing alert via email.

Guest 2

Rid. For some like Firebase, you can program a serverless function which shuts off the service, but that's complicated and error prone. Yeah. Jeez.

Guest 2

All I need is to all I need is a toggle in the settings UI. This really sucks for hobby developers and toy projects. I'm fine with paying a fixed Or maximum amount each month, but I don't want a surprise $10,000 bill if I add an endless loop. What's your opinion on this topic? Cheers, and keep up the great work. I Totally agree. And, honestly, I'm shocked that those things don't exist because I've been on render, as a host for a long time now. Although we are moving to Vercel for syntax stuff. Right? So I'm gonna have to get used to the Vercel stuff. But this might be a use case in which I mean, do you need the I mean, maybe, I guess, for serverless functions, that's that's one thing. But, like, maybe you just need a straight up node server to host on. And, like render, rid. I have a a fixed price amount node server that I can put on auto scaling, but I can set auto scaling thresholds rid to say, hey. Only auto scale up to this dollar amount, if if it really calls for it. But, like, a straight up node server for a fixed price rid. Has always worked pretty well for me in these scenarios, so maybe that's really what you need. Yeah. You can set, like, I have mine to auto scale

Wes Bos

rid. From 1 to, I think, 3.

Topic 15 25:31

Wes suggests a regular server instead of serverless to set hard limits on resource usage

Wes Bos

And then at at that point, if it goes more than 3, something's wrong. You know? You gotta you gotta take a look. You talk about containers or what? Rid In my render yeah. My render containers or digital ocean droplets or whatever. They can scale up. So that's that's certainly one way to do it. Rid. I think the issue here is that, like, specifically Vercel, they had a couple issues where rid. Somebody wrote something, and it called itself and spun up a $6,000 bill. And props to them because they took care of it right away.

Wes Bos

Rid. And they are working on they said they were working on recursion detection, which I think is what happens a lot with this type of thing. It's not necessarily, Wow. My project got super popular, which can happen, but sometimes it's when, like, you accidentally write a loop and bankrupt yourself, rid. From that type of thing, it's kind of tricky for them because they have lots of customers who rid. Don't ever want their website to go down, you know? And and then you have the hobbyists where they say, I don't ever want to pay more than x, y, and z. So rid. I I often wonder, like, why don't they why don't more companies have that? Like, you could just turn it on. Like, OpenAI does this beautifully. Rid. You can do you can set a soft limit and a hard limit. Meaning, email me when I go over a $100 and turn the thing off When I go to $300. And if you don't want that, you could just just turn it off. Right? Rid. So you got to wonder, like, are how many? Another thing I think about a lot is rid How many big companies just pay the bill? You know? Oh, shoot. That thing spun up an extra $6 worth of rid Serverless functions,

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