Swift Toolkit with Natan Rolnik
[00:00:00] Nathan's Work and Contribution
---
[00:00:00] Leo Dion (host): Welcome to another episode of Empower Apps. I'm your host, Leo Deanne, and today I'm joined by Nathan Rolnick. Nathan, thank you so much for coming on the show.
[00:00:12] Natan Rolnik (guest): Hey. Hi Leo. Thank you for having me.
[00:00:15] Leo Dion (host): Before we begin, let you do your own introduction.
[00:00:20] Natan Rolnik (guest): Alright so I'm Nathan. I've been doing iOS for a while, since iOS three four. I learned to program in objective C and that, that's mostly my passion. Along the way I've learned other stuff and. Nowadays I work at as a senior iOS dev at monday.com. And in my free time, I also write content mostly around the tooling and server side Swift, in my, website, swift toolkit.dev. That's really like a passion of
[00:00:55] Leo Dion (host): Have you written? Have you written for code? Go?
[00:00:59] Natan Rolnik (guest): Yeah. In the past, I also I wrote some articles for Kodeco.
[00:01:03] Leo Dion (host): So Monday
[00:01:04] Natan Rolnik (guest): That's how I started writing also,
[00:01:07] Leo Dion (host): okay, so Monday has two Israeli CCO Kodeco. That's pretty awesome
[00:01:14] Natan Rolnik (guest): month, yes. Yeah, we have a few more in here in the country we have a few more people that contributed to Kodeco, but
[00:01:20] Leo Dion (host): But previous guests, we were just chatting before the show, previous guest Shai is also at Monday. A pretty, sounds like a pretty great place,
[00:01:29] Natan Rolnik (guest): Yeah, we have,
[00:01:30] Leo Dion (host): people.
[00:01:30] Natan Rolnik (guest): Yeah. I can't say that about myself, but yeah, we have a growing team.
[00:01:36] Leo Dion (host): Yeah.
[00:01:37] Natan Rolnik (guest): It's a, it's an interesting product.
[00:01:40] Leo Dion (host): Yeah. It is an interesting product. We we were just talking a lot online and you've been posting a lot of great stuff that I wanted to chat about on the
[00:01:48] Leo Dion (host): We've been talking a lot online about. Some of the stuff you've been working on and some of the stuff on your blog. I wanted to maybe let you introduce what you've been talking about and what you've been working on lately when it comes to Swift.
[00:02:01] Natan Rolnik (guest): What I've been, my, my goal of this website was to produce some content that I feel that the community lacked a little bit with good tutorials, practical tutorials, and and even sometimes interactive stuff on the web of content focused on, on tooling and server side. For example, one of the things that I did was a package swift syntax file cheat sheet.
[00:02:28] Natan Rolnik (guest): That, that was one of the, that was actually one of the first posts. Another one that I'm really proud about it was a. The Swift argument parser interactive guide, so we co like it. This is divided in three sections and explaining options and flags and arguments. What are the difference between them and option groups and how to handle errors.
[00:02:50] Natan Rolnik (guest): So I built a little terminal simulator where people can actually run commands that run executables that are in the sample code so they can see the result of how, what that code means. So mostly it's been content around CLI stuff a little bit about the server side that I wanna write more about it now that we just had Hummingbird two released by Adames,
[00:03:21] Leo Dion (host): Yeah, you just
[00:03:22] Natan Rolnik (guest): yeah, I just published,
[00:03:23] Leo Dion (host): of the recording.
[00:03:24] Leo Dion (host): So people should definitely check that out. Hummingbird is fantastic. I
[00:03:28] Natan Rolnik (guest): Yeah, it is. There, I think both, both Vapor and Hummingbird, they are, they're amazing. And I think that connects a little bit to, what I wanted to say is that I, I think that Swift is, empowers us so much in ways that 10 years ago we couldn't as iOS developers that you had to learn other errors.
[00:03:48] Natan Rolnik (guest): You still have, and I don't think that you shouldn't learn other stuff but it gives so much power. Cons in comparing to where we were 10, 15 years ago.
[00:03:59] Leo Dion (host): Could you imagine this stuff in objective C, like
[00:04:02] Natan Rolnik (guest): Yeah. I actually, I.
[00:04:04] Leo Dion (host): or command line objective C? It's just I'm sure it's a possible, right?
[00:04:10] Natan Rolnik (guest): but Swift is great in so many ways. You can talk about that later,
[00:04:14] Leo Dion (host): Yeah.
[00:04:14] Natan Rolnik (guest): that makes it
[00:04:15] Leo Dion (host): let's I wanna talk. Go ahead. Sorry.
[00:04:18] Natan Rolnik (guest): I know that makes it much more of a fit. I'm sure like you could write all these things with objective C, but not only the verity, but language features and that SWIFT allows us.
[00:04:30] Natan Rolnik (guest): I, in one of my talks that I gave recently about, was like a quick introduction to Vapor. I actually had a screenshot of a service that was called Objective Cloud. I'm not sure you remember that.
[00:04:41] Natan Rolnik (guest): Gave a framework. They gave a framework that you could write. servers just like vapor, but not just like vapor, but in, in the same sense that vapor or express.
[00:04:53] Natan Rolnik (guest): So you could write objective stuff and they had a cloud that ran on Mac and could help with deploying. So Swift is may, maybe that the vision is the same, that you can share code may, that you can use knowledge or models and deploy that on the cloud and have that as part of your app in another place.
[00:05:14] Deep Dive into Swift CLI Tools
---
[00:05:14] Leo Dion (host): Let's deep dive a little bit more into the CLI part yeah. What, why do you think SWIFT is a good option? Just let's start particularly when it comes to CLI tools.
[00:05:28] Natan Rolnik (guest): Yeah. I like to divide that in three or four areas where I see the advantages. And the first one is the language itself. Like it has so many great features. It has all the foundation, API that we already, we are used to date and gets improved and like date formatting and whatnot. Like all foundation.
[00:05:49] Natan Rolnik (guest): We have I don't know, e enums, like the associated values, like all this can live inside a CLI tool. We have macros. You can use macros from your own, from your tools. You can use as in Kuwait, which is. For CLI tools, they're super helpful as well. Like all the time you have to do either network requests or disc operations that they are, they might take some time, so writing them with as in Kuwait, is much, much better than completion blocks or promises and futures.
[00:06:24] Natan Rolnik (guest): And ma many things like that. The language is, we all are used to it, right? So that's number one. Number two I think is if you're running on a Mac, you can access UI kit and app kit, APIs, and even Swift ui. If you wanna draw some stuff you can generate images. That's a second advantage.
[00:06:44] Natan Rolnik (guest): The third one is the whole ecosystem, right? We, you, we can use packages that run on Linux, but they also run on Mac. And they are packages that maybe you are already familiar with and you can also share code with your own I dunno, within your team and iOS app and CLI and maybe a server component that uses the same models.
[00:07:06] Natan Rolnik (guest): And I think that the most important of them, like the fourth one is that if you have a team of iOS developers, they all are gonna know swift. Like one, one person might know more, no, the other one might know Python, the other one might know Ruby and Rust. But if it's a team of mobile developers and iOS developers, they all should know Swift and they could be able to jump in and improve and fix and add features and stuff like so I think that there, like there are four different, these are four different advantages that.
[00:07:38] Natan Rolnik (guest): They're very powerful.
[00:07:40] Leo Dion (host): do you think it's easier to go from being an iOS developer in SWIFT to a CLI tool developer in Swift, or is it easier to go from a node or Python developer of CLI tools to a SWIFT developer in CLI tools. Does that make sense?
[00:08:01] Natan Rolnik (guest): It makes, I think that's, I think that maybe I'm not sure about the answer, but I think that because the node ecosystems started more from the backend, like end point, like from the backend view. So they probably started off with more tooling around that. And
[00:08:18] Leo Dion (host): Did it though, like Node is JavaScript based? It was
[00:08:22] Natan Rolnik (guest): Yeah. Oh
[00:08:23] Leo Dion (host): is actually all browser. Browser base. So technically
[00:08:27] Natan Rolnik (guest): No, but let's say Ruby.
[00:08:28] Leo Dion (host): mean it's node but
[00:08:30] Natan Rolnik (guest): Yeah, but let's
[00:08:31] Leo Dion (host): it is more, yeah. Yeah. Okay. There we go.
[00:08:34] Natan Rolnik (guest): like they're by definition they have this more purpose of, I'm not sure about the purpose, but if you say Ruby, you're probably gonna think about Ruby on Rails, or if you say no, you're probably gonna think about Express or other framework. So that, that's basically where I wanna go. So I think that as a consequence that their ecosystem is much more robust in that sense. And they're good options. They might be a better option from, I dunno if you are a programmer that knows both languages, but. You are not specifically coming, like from a, focusing on a team of five OS developers or might be probably that no is a better choice.
[00:09:22] Natan Rolnik (guest): I don't know, maybe.
[00:09:23] Leo Dion (host): right,
[00:09:23] Natan Rolnik (guest): but but I think that the ecosystem is growing and the, there's been a lot of evolution and work on that. So I think that time makes, it makes it roll here as more and more efforts are invested and we have more packages around it, I think it's a matter of time and, the community realizes that this is a really good option and as it grows, right?
[00:09:46] Natan Rolnik (guest): How do you see this?
[00:09:47] Leo Dion (host): Yeah. I think as we'll talk about later, I feel like the ecosystem when it comes to CLI tools has really seen like a big. It seems like there's been a lot going on lately in the last six months as far as what's out there. Obviously we've had argument par parser which has been a big benefit and I've even given a talk at, it was like five years ago, I think I gave a talk on it.
[00:10:14] Leo Dion (host): But it's like there's a lot you can do. Let's talk a little bit more about argument parser specifically. What so you, what did you learn when you built that interactive tool? As far as how it works or how the mechanics of it work or what are some quirks about it that people don't realize?
[00:10:31] Leo Dion (host): When you built the interactive tool that you don't think most people know.
[00:10:34] Natan Rolnik (guest): The interactive guide actually made me learn other things about Lambdas and 'cause they actually run, they run in a lambda and I just returned the result. I actually learned more in the last few weeks. I had the chance to give it a try to Swift Cloud by Andrew Barber, which I also wrote a little bit about it.
[00:10:56] Natan Rolnik (guest): And the argument parser is it actually has it, it does a few things. It's not only parsing, it does parsing of commands and translates the them into structs that you can that where code lives.
[00:11:12] Natan Rolnik (guest): Sorry, but, and, but it also does all the handling of the main, of like the entry point of your tool.
[00:11:19] Natan Rolnik (guest): Like you don't need to, you don't need to write the main function, right? You just mark your str your, like your root command with at main and possible possible command takes care of getting the inputs translate, like doing the parsing, calling the validate function first.
[00:11:39] Natan Rolnik (guest): First it validates, then it runs and it wraps that in a dual catch block in a look at statement and if it errors, it also outputs there, error. It, so it does a lot around it. So that's what I learned in more in the bit in, in the last few weeks. I. And it's great.
[00:11:56] Natan Rolnik (guest): I just felt that it's a bit limited if you want a bit more control. And if you want
[00:12:01] Leo Dion (host): do you mean exactly?
[00:12:02] Natan Rolnik (guest): If you wanna add colors and displayers with with styling or I don't know if you wanna add loaders or interactive input. we were just talking about Node, right? Like it they support this.
[00:12:21] Natan Rolnik (guest): They have packages that they do this right away. And let's say we have console kit from the folks at Vapor that it does some sort of of interactive stuff, but it's not in the same package as the Arwin parser. So I'm also not sure if that's their goal.
[00:12:38] Leo Dion (host): Like it makes sense that argument pars are, is good about the front end part, but I do agree that there's like something missing when it comes to. Not the front end part. The, they, they've, they have a tool that's really good at parsing arguments and just running a thing. And what I do agree is missing is some of the pieces that you mentioned.
[00:13:01] Leo Dion (host): So let's go over what you mentioned. You said loaders. What do you mean by loaders? Exactly.
[00:13:06] Natan Rolnik (guest): In the same way that you, when you have a UI on, on an app, that you'll see a loader and then data shows. Sometimes you, let's say you wanna authenticate with some service or you wanna run a service that takes a while. I don't know. It's gonna build a docker image or download a docker image. It's nice to see some output in the same way that you don't wanna see a blank screen on an app. You also don't wanna see in the terminal that it's stuck 'cause you dunno what's going on.
[00:13:31] Natan Rolnik (guest): So another thing that I learned recently is like how, let's say loaders work. They actually in CLI tools, they, they actually print stuff and delete and update that.
[00:13:43] Natan Rolnik (guest): And it, it keeps changing the output without pre, without adding more. It just replaces the current state. So
[00:13:51] Leo Dion (host): What we're talking about is the like VT 100 commands basically, where you can do control commands to say, move the cursor to the left, move the cursor
[00:14:00] Natan Rolnik (guest): yeah our printing stuff.
[00:14:02] Leo Dion (host): Colors, printing, all that
[00:14:04] Natan Rolnik (guest): yes. And console kit has a lot of that stuff but
[00:14:08] Leo Dion (host): Oh, really? Okay.
[00:14:09] Natan Rolnik (guest): console, kt they have manuals and there's also a great a great package. It's called Swift, TUI, with a capital t. That it has a similar
[00:14:17] Leo Dion (host): about that in this show.
[00:14:19] Natan Rolnik (guest): Yeah. And
[00:14:20] Leo Dion (host): UI.
[00:14:21] Natan Rolnik (guest): yeah and you can use that for terminal apps, CLI apps.
[00:14:26] Natan Rolnik (guest): And, I don't think that's the goal of the argument parser. Like it's so good at parsing and the way they designed all the property wrappers options, option groups, flags, arguments. It's super powerful. But in the same way so let's say I, I was looking for interactivity in the argument parser, and I found that there's a branch that it's 1-year-old it's been stale and it's a bit of a bu bummer 'cause we have no idea what, where that's gonna hap, like where it's headed and what's the direction and what's.
[00:15:03] Leo Dion (host): how is argument parser working with? When it comes to Swift six type stuff
[00:15:09] Natan Rolnik (guest): that's a good question.
[00:15:10] Leo Dion (host): You know if there's no issues with like Sendible or anything like that?
[00:15:13] Natan Rolnik (guest): I'm not sure they're marked with it. It's worth checking. I'm not a hundred percent sure
[00:15:19] Leo Dion (host): Yeah, it's fine. I figured I'd ask. I, the other thing you had on here was Specter kit. Did you look at that as well?
[00:15:28] Natan Rolnik (guest): I didn't try it yet. It's in my wishlist of posts that I wanna, of, packages that I wanna highlight. I want to play around with it and see, but it's, yeah it, I don't think it's similar to swift ey to the other package we mentioned.
[00:15:42] Natan Rolnik (guest): It's also nice for building UIs and borders and tables and things like that.
[00:15:49] Leo Dion (host): Okay. Yeah, I'm looking at this stuff. It's amazing what people have done and
[00:15:53] Natan Rolnik (guest): Oh yeah. It's incredible. 'cause like
[00:15:55] Leo Dion (host): I think, I don't know, I've started three or four different projects where I played with a VT 11 a hundred stuff in the codes. And it's all, it's just like a rabbit hole for me. I think what for me is missing and we've, me, I, maybe I've mentioned this on the previous podcast, but is more stuff hooked up to observable.
[00:16:13] Leo Dion (host): I know that's what's going on with Swift two E, but with the new change from combine I'm not sure that it's compatible with the new Yeah, the new observable stuff. So that's really what I'd like to see is something like that. The other tool I'm gonna
[00:16:28] Natan Rolnik (guest): I think that all this is eventually they're gonna arrive.
[00:16:31] Natan Rolnik (guest): But I I'm not sure if disappointing is the word, but I would be nice to see more efforts on those areas from everyone. And I include myself there
[00:16:41] Leo Dion (host): If only we had infinite time.
[00:16:43] Natan Rolnik (guest): Yes.
[00:16:43] Leo Dion (host): I wanted to mention that I use a lot. It's not swift based, but it's definitely used in my iOS development and that would be Fast lane. It has a really nice terminal interface where it doesn't try to do everything, but it tries to do enough that I feel like there's a lot of great ideas there that we in the SWIFT community could use when
[00:17:03] Natan Rolnik (guest): Yeah. I think that they also have.
[00:17:05] Leo Dion (host): an interactive app
[00:17:08] Natan Rolnik (guest): Yeah, they have the advantage that in Ruby they, they can do all the plugins stuff and it's like much more dynamic and they plays together much more nicer than Swift it, it's super, it's much harder to do that in Swift, if you wanted to have plugins for cli and I know that Ruby is much more friendly on, in this aspect.
[00:17:28] Leo Dion (host): Anything else you wanna talk about when it comes to CLI Tools?
[00:17:32] Natan Rolnik (guest): I just think that ui and experience of CLI tools, they're, there's an. Even when we write for ourselves, like we could do better in, in terms of explaining what's available, like what commands are available and help and things like that.
[00:17:51] Natan Rolnik (guest): And like dividing dividing s commands and sub commands into sections like in, of different of different different areas or different domains. And also output, like being able to control output and instead of like just excode build, like just spitting out information and
[00:18:11] Natan Rolnik (guest): That's why there are many parser or I think it's XY pretty or X, that does
[00:18:18] Leo Dion (host): Yeah. XY pretty, yep. That's a big one.
[00:18:21] Natan Rolnik (guest): Yeah. So I think that's, I. It's worth, like in general, tooling investing time in tooling and in tooling UI and in tooling experience is one of those things that you never regret. ' cause in the end of the day it's a tool that it's gonna help you. So I've, and anytime you spend on it, you're gonna, you're gonna get a, get it back pretty quick once you use it.
[00:18:46] Leo Dion (host): So there was a really interesting article you had out a few weeks ago about this kBox idea.
[00:18:53] Leo Dion (host): Explain what that means exactly and why you built a macro
[00:18:58] Natan Rolnik (guest): no I, that was, that's not mine actually. The macro itself is written by Rick Vanden. is he's from la. No it's fine. So all credits go to him.
[00:19:09] Understanding Copy-on-Write in Swift
---
[00:19:09] Natan Rolnik (guest): 'cause I actually, I met him and I saw this him, I saw him presenting about it in, in a conference and before that I actually, I didn't invest time in really understanding what copy on the right means and all the consequences and how, and what's the impact it, it can have in your in apps.
[00:19:28] Natan Rolnik (guest): And so basically this goes back the basics of reference types and value types.
[00:19:36] Natan Rolnik (guest): And copy and write goes to the concept that when you use value types, whenever you copy those types, they actually take memory. And instead of, differently than reference types where just copy a pointer.
[00:19:56] Natan Rolnik (guest): But the memory is the same. The memory address of all the copied objects are the same. When you use value types, you actually use more ram memory, right?
[00:20:06] Natan Rolnik (guest): So if you copy thousands and thousands of STRs that have many integer and strings and other primitives, it actually takes more space on all of these.
[00:20:19] Natan Rolnik (guest): So copy and write is actually a, it's not a new concept in computing. It's like from the eighties that says you just copy if you're gonna change, you just copy the value if you're gonna change it. If you're not gonna change it, just use a pointer. So instead of replicating this this value types everywhere and having them redundantly in many places in the memory, just keep a pointer.
[00:20:47] Natan Rolnik (guest): Like you, you usually use a storage, like you use a class, internal class that is storage and you only really copy it in the memory if you are gonna modify the value. So that's actually what copy on the right means. It's copy whenever you're gonna do a right, if you're not gonna change or if not gonna do a right.
[00:21:06] Natan Rolnik (guest): Don't copy it. So in Swift you can do that using the function that is called is unique is uniquely referenced.
[00:21:15] Leo Dion (host): Is known, uniquely referenced. Yep.
[00:21:17] Natan Rolnik (guest): known, uniquely referenced. Yeah. So you can do that in your own properties. And you can write a storage and it's fairly easy. Like it's a few lines of code to do this for properties but whenever you have more and more properties that you wanna include in this copy and write pattern, it gets more, it's more work.
[00:21:38] Natan Rolnik (guest): And then if you have a lot of STRs with a lot of properties that you wanna support this, it gets really it's a lot of boilerplate code. So what Rick wrote is, yeah, go
[00:21:49] Leo Dion (host): I just, sorry, I had a couple of questions. So why use obstruct if anyways? If you're just gonna use pointers in the long run?
[00:21:58] Natan Rolnik (guest): Because you still wanna be able to wait. Let me think a little bit more about it.
[00:22:06] Leo Dion (host): No
[00:22:07] Natan Rolnik (guest): No that, that's a good question. '
[00:22:09] Leo Dion (host): cause somebody's gonna be like, okay, why do I have to add all this cruft? Why not just use a class anyways and call it good?
[00:22:18] Natan Rolnik (guest): right, because Oh, okay. So when we added to, we could keep that part out. But so the problem is that when you have classes everywhere, whenever you change a property of one object, it's gonna change all
[00:22:35] Leo Dion (host): all of 'em.
[00:22:36] Natan Rolnik (guest): for all of them.
[00:22:37] Leo Dion (host): Okay. That makes total
[00:22:39] Natan Rolnik (guest): so with STRs you keep with copy and write, you keep the best of both words.
[00:22:43] Natan Rolnik (guest): That's what I used in my article explaining it.
[00:22:45] Leo Dion (host): Yeah, that's a really good point.
[00:22:47] Natan Rolnik (guest): You use
[00:22:48] Leo Dion (host): So basically it's a struct. It's a
[00:22:50] Natan Rolnik (guest): wraps a class,
[00:22:53] Leo Dion (host): right? And then this
[00:22:55] Natan Rolnik (guest): you share memory. When I, whenever it's the same, you share the
[00:22:58] Leo Dion (host): same thing. There you go.
[00:23:00] Natan Rolnik (guest): Change, you copy that
[00:23:01] Leo Dion (host): Okay.
[00:23:03] Natan Rolnik (guest): and that macro does it in a really smart and short way. You just declare you, you attach the macro to your struct and you declare which properties you want to be supporting, you want to support copy and write and it'll do all the code generation behind the scenes for you.
[00:23:24] Leo Dion (host): yeah, where I've seen this is and you mention it here, is Swift Neo, but specifically like Vapor, a lot of the Vapor Storage stuff uses this kind of idea where they have it's a struct, but then the properties are all like with a class inside it. That's where I've seen this a lot.
[00:23:42] Practical Applications and Performance Considerations
---
[00:23:42] Leo Dion (host): And is it like, is this something you should be doing when you're building an iOS app or is it more useful on the server
[00:23:50] Natan Rolnik (guest): No, I actually think it's very relevant to iOS and Mac OS apps because it can, this can affect performance. Not only you waste more memory, but you also waste computing processing for copying all this stuff. So if you pass around a lot of data between views, like between view models or between different objects.
[00:24:09] Natan Rolnik (guest): If you are in the scale in like in high scales and property and these drugs, they are big, it might also like, it might be very relevant, but it, but you also need to take into account some considerations that. When using copy and write in, in, in some place, like in some conditions it can lead to performance issues as well.
[00:24:31] Leo Dion (host): It has to do with the check or what specifically is
[00:24:34] Natan Rolnik (guest): yeah. Be because if you're, like, let's say you have a, an array of values and you're iterating over them, and inside a for loop, you have, you are modifying something. And so let's say you, you're gonna have you, you're gonna be at every, right? You're gonna be copying stuff. And this is inside for loop, so you can that's called accidental quadratics.
[00:24:59] Natan Rolnik (guest): It's a concept that I mentioned in the, in that blog post that I also had no idea that existed before learning about copy and write. And I linked there some to some talks about performance in Swift. They're very they explain this concept in a more friendly way than just a scary name. So it can actually lead to issues if you don't know what you're doing, like it needs to be used with not knowing what you're doing. Like just don't throw it everywhere. And I think it's also worth mentioning the, in the cowbox repo, they have another repo that they link to another repo of benchmarks and it shows data how much data is consumed and how much memory is consumed and what the real impact can be in an app.
[00:25:46] Natan Rolnik (guest): And I think it you can run them both, the food truck sample app from from the last DD. So what Rick did, Rick took that project, and he applied the Carbox macro in some, in, in some of the str there. And he compared that performance and memory and pro, he did profiling and he explains everything in the in, in that ripple.
[00:26:09] Natan Rolnik (guest): So if you, if for people who are into this kind of into this kind of work and analysis and getting into the lower levels of how your code performs, that's definitely like a, that's a feast for people who like this.
[00:26:25] Leo Dion (host): And we'll put a link to that in the show notes as well. Of course, your article and the repo.
[00:26:30] Swift Package Manager and Development Tools
---
[00:26:30] Leo Dion (host): What do you think is, what do you think is missing when it comes to Swift Package Manager right now?
[00:26:37] Natan Rolnik (guest): There's one thing that really annoys me is whenever I wanna spin off a new project that I know exactly what I want that I don't have the option to get a template and start using that. For example, if you wanna start a new vapor project, you probably should use the vapor CI It's gonna ask you a few questions.
[00:26:57] Natan Rolnik (guest): Do you want fluent, do you want, do you wanna use which database do you want? Do you want Leaf, which is a template, temp, templating engine. And then it's gonna, it's gonna take all that and create for you a starter project. And for people who worked with NPM, that's, let's say I, my website is built on in, I just like you do N-P-M-N-P-M create and it follows all the instructions that template has. And that's also an interactive thing that you interact with the questions and based on our, on your answers, it's gonna create your template. So I feel that for these projects so I want to create a lambda. Okay. Where do you start from in Swift? Okay. There's a. I go to the Swift AWS Lambda run runtime repo.
[00:27:51] Natan Rolnik (guest): And then I read the, read me and I copy where with whatever package dependencies I need to add. Then I create, I go to the terminal and I do swift packaging. It there just type executable and I start manually doing stuff. So e even if there were templates for this, I would need to go manually and clone the repository and remove the gate remote and do a lot of, there's a lot of repetition and things that in other ecosystems, they already solved that with templates.
[00:28:26] Leo Dion (host): well, Nathan, can't you just use Xcode to create your Swift Pro package? Won't that do everything? Not really.
[00:28:34] Natan Rolnik (guest): Yeah. Not really. So well, we could all write a tool that would do this, but let's say NPM has this built in do NPM create and I feel that some of these, this things we're still not sure if limited or
[00:28:50] Leo Dion (host): already talked about like a, we have a terminal front end, right? What would you we're, let's just say we had that right where it could ask you questions, like you're just talking purely about creating a swift package through the terminal and like asking certain questions, right?
[00:29:07] Natan Rolnik (guest): Based on, yeah, based on a template that some organization or some individual put it out there to help, to ease.
[00:29:15] Leo Dion (host): How, yeah, I wouldn't be, would you want something to where you had like NPM install save where it actually adds the dependency for you?
[00:29:25] Natan Rolnik (guest): Do you know what I learned not recently that SPM supports that? There was a great article we can link to that. I'm, I don't remember. I'll send you later. Verwer mentioned it in iOS that weekly, a few weeks ago, I think.
[00:29:40] Leo Dion (host): Okay.
[00:29:42] Natan Rolnik (guest): I think it was two
[00:29:43] Leo Dion (host): work like pretty well or like I do now? I re I'm actually remembering what you said. Yeah.
[00:29:50] Natan Rolnik (guest): But with n pm it's much easier, right? You just do. 'cause in, in SPM we have a few layers. We have there's the package dependency and there's the target dependency. So first you need to add your package dependency to your package, and once you have that, you can add two different target dependencies. With NPM, I don't think that you can have multiple targets or you just add there's, there are dependencies and they have dependencies, but you just run one command and it installs.
[00:30:19] Leo Dion (host): So you had an episode with them a few weeks ago,
[00:30:22] Natan Rolnik (guest): Yes. Was a
[00:30:23] Leo Dion (host): they? Is that what he was talking about
[00:30:26] Natan Rolnik (guest): No, I think he published it. Someone else who published this second I could find it.
[00:30:33] Leo Dion (host): yeah, we'll put a link to that in the
[00:30:35] Natan Rolnik (guest): We'll put a link to that. Yeah.
[00:30:37] Leo Dion (host): Yeah. Yeah, no, I agree. A hundred. I've gone down that rabbit hole too. So I'm looking for something where I can create a package and be like, do you want to build a command line tool? Do you want to build a server? Do you want to build a Lambda? And then.
[00:30:54] Leo Dion (host): Just gets it started for you. 'cause I do feel like that's missing a lot.
[00:30:59] Leo Dion (host): Yeah, totally. Though let's, let me just be devil's advocate, even though I agree with you. But there are tools out there no problem. There are tools out there like Vapor, CLI essentially for JavaScript, stuff like that's not.
[00:31:18] Leo Dion (host): Unreasonable that you build a custom command line tool for your I agree. It's not great, but like I've used V
[00:31:26] Natan Rolnik (guest): it's,
[00:31:27] Leo Dion (host): I've done I've done stuff with React native where it's like basically you run the command and it creates a whole package, Dutch a for you. So there, there is a lot of stuff in the JavaScript community out there specifically for this case where it's what I'm trying to say is like the vapor CLI is not totally unreasonable approach to that.
[00:31:49] Leo Dion (host): Even though I wish it was more
[00:31:50] Natan Rolnik (guest): No, for sure. But what I mean is that I feel would be very helpful to the H ecosystem is having this baked into, like having a standard that whoever wants to offer a template that, that is SPM compatible would be helpful and nice.
[00:32:08] Leo Dion (host): So I would like to do that. So I've published my own DSL for SWIFT packages that I use now for server side and iOS applications. And like for me, it wouldn't be that hard to go take the next step and like basically turn it into a command line tool. That's what I'd like to do with it, to where there would be a lot, I don't know if you've looked at package DSL, but basically the idea being like, yeah, no problem.
[00:32:36] Leo Dion (host): But like the idea being is you create, you put all your dependencies and stuff in separate files and use like a SWIFT ui, DSL to
[00:32:44] Natan Rolnik (guest): Nice Results builders.
[00:32:46] Leo Dion (host): yes, lots of result builders. And that would even make it easier. 'cause all you have to do is create a new file or remove a file and there you go.
[00:32:55] Leo Dion (host): So yeah, that's you're motivating me. Thanks. 'cause I need more stuff to do right now, obviously
[00:33:02] Natan Rolnik (guest): Yes.
[00:33:03] Natan Rolnik (guest): Could just publish it in using Homebrew.
[00:33:07] Leo Dion (host): Yeah.
[00:33:08] Natan Rolnik (guest): You know what maybe this could be swift evolution proposal, especially if maybe the Swift Server work group could
[00:33:19] Leo Dion (host): I do think the package dot Swift is a bit dated for a lot of reasons, so I wouldn't be surprised if in the next year or two we get a new
[00:33:30] Natan Rolnik (guest): new one.
[00:33:31] Leo Dion (host): Yeah. Just 'cause there's a lot of stuff to it that's awkward.
[00:33:36] Natan Rolnik (guest): Standards are hard to replace. One can hope.
[00:33:40] Leo Dion (host): What else did you wanna talk about before we close out? We had a few other topics on the doc, but I want, what are you most interested in talking about before we close out?
[00:33:49] Natan Rolnik (guest): no, I think we covered a lot. What my main message with this with my website is basically we can much easier than five, not even 10 years ago, five, four years ago. We can build tools and even server stuff in a much more easier way than a while ago. And they help us.
[00:34:10] Natan Rolnik (guest): Like I I've done stuff that I'm happy, I invested time on them and. And it pays off. It's worth investing it. We have tons of opportunities for automating processes or improving processes.
[00:34:26] Natan Rolnik (guest): But if you're like just focused on, on the app itself we don't, like if we leave this little box of getting things done and thinking more about this processes and how you can, like, how you can help your team and how you can help your future self like that's the main message is. You can go out and build stuff for you and for our team and it's gonna be worth it and it's gonna be maintainable think that again, we are in a different place that we were not five, four years ago. So I think that everyone should try to familiarize themselves with these tools and this giving, at least giving a try for, I dunno deploying a little function or deploying stuff even for personal stuff for fun.
[00:35:15] Leo Dion (host): Do you think any of the stuff that you've picked up is applicable? Specifically to the typical, 99% of us are Swift UI iOS developers. What do you think you've picked up in your development tools that has helped you when it comes to just your day-to-day iOS development stuff, I do think like you get a greater appreciation of the language and what you could do with the language and understanding it's for versatility and how so I actually give you an ins example is when I was at the server site Swift conference Franz gave a really good talk on this width pattern that he used with non sendable objects.
[00:35:56] Leo Dion (host): And this was specifically for the server, right? And it occurred to me that this is a, this is this issue while it's more applicable to the server is something I've run into when it comes to certain non sendable types stuff concerning swift data. And it was like a eureka moment for me of something that I could directly apply to my Swift UI work that's not even server related, but it's oh wow, yeah, this is really cool.
[00:36:22] Leo Dion (host): And. That's a specific instance, but there's little things where you pick up on stuff in the server. Like I've seen, like the stuff you talked about the copy on, I'm sure that's more on the server, but it's definitely, like you said, applicable in
[00:36:35] Natan Rolnik (guest): Oh, it's totally, yeah.
[00:36:37] Leo Dion (host): Yeah.
[00:36:37] Natan Rolnik (guest): I think that, let's say
[00:36:38] Leo Dion (host): I think that's the thing that grew out of, that's a thing that grew out of the server community, I'm sure, but it's definitely, like you said, applicable for iOS development. So there's things like that I find when it comes to to, to working on this stuff.
[00:36:50] Natan Rolnik (guest): No, I think even if you learn other languages, you can learn things that are relevant to like concepts or even limitations, like some languages they have limitations that with those limitations you learn new techniques or new patterns that in some more advanced you cases you don't have to use or but I don't know.
[00:37:10] Natan Rolnik (guest): But I think that, answering to your question, maybe, I don't know the concept of fu futures and promises, I. I learned a little bit of js and a little bit of vapor
[00:37:20] Leo Dion (host): Sharp and js. That was it for me. And then going into Vapor, it was like, yeah, I get totally what's going on? And then I was like, man, I wish they had async weight though. And then Eureka, here we are. Yeah.
[00:37:33] Natan Rolnik (guest): And so I, even though I had never used promises in, in, in the iOS domain, it's it's good to know more techniques and more patterns and more you think about things as streams. So for example, if you are gonna work with reactive stuff or com combine and even async, async sequences it's the same, it's the same thought, right?
[00:37:56] Natan Rolnik (guest): It's the same way of thinking like that every, everything is a stream. I think that even talking about swift concurrency, on the server. You also have you, you have to deal with sandal, maybe non copyable, maybe all the strict concurrency. And maybe it's gonna be easier to learn there than in, on the, on an iOS app case.
[00:38:21] Natan Rolnik (guest): And from there you could start applying. Or maybe you have a smaller app on the server that's easier to start migrating to start migrating to, to the SWIFT six strict mode. And once you're ready and you understood how it works you could apply that to a bigger scale iOS app or framework.
[00:38:40] Leo Dion (host): exactly. Exactly. 100%. Nathan, thank you so much for coming on the show. This is really
[00:38:47] Natan Rolnik (guest): Thank you for reaching
[00:38:48] Leo Dion (host): Where can people find you online?
[00:38:49] Natan Rolnik (guest): I'm on both X and Mastodon as Nathan Ron without an H. We can leave the link and I've been, so the website we mentioned it's Swift Toolkit, do Dev also on X and Masteron. I've been posting weekly for a little bit more than four months. The, there's, I've, again, I've been focusing on on content that is not sure if different than, but I try to make stuff that's sometimes interactive, sometimes with tutorials.
[00:39:21] Natan Rolnik (guest): So if you're interested in this domain, I'll definitely. Go there. Yeah, these are the places I can, I'll be happy to chat with anyone that
[00:39:30] Leo Dion (host): I definitely check out the articles on their, on Nathan's website. There's a lot of good stuff. And subscribe or follow 'cause yeah. People can find me on Twitter at Leo g Dion. My website is bright digit.com. I'm Leo GD on at C Im on Mastodon. Yeah, if you're watching this on YouTube, please and subscribe.
[00:39:52] Leo Dion (host): And if you're listening to this on a podcast player, please put a review. If you have any requests for topics let me know. Reach out to me. I'd love to hear what you think. Join our Patreon to get early access to episodes like this and subscribe to the newsletter so that way you can catch some more content as well.
[00:40:11] Leo Dion (host): Thank you everybody, and have a good rest of your week. Bye.
[00:40:15] Natan Rolnik (guest): Bye-Bye.