DEV Community

Cover image for Learning Swift, iOS, and Vapor in one week
Sylvia Pap
Sylvia Pap

Posted on • Updated on

Learning Swift, iOS, and Vapor in one week

I always think of a line from Silicon Valley where the main character says, to prove how smart/good at coding he is, "I learned Ruby on Rails in a weekend"

gif

My bootcamp taught RoR in 6 weeks so maybe I can't say this, but I think if you had a solid coding background in other frameworks, learning RoR in a weekend wouldn't be hard, so that's just a funny TV vs. reality tangent. The wonderful world of internet commenters have also pointed out that the episode's timeline/character's age imply RoR wasn't around when he would have been 17 so... it might not be the show's most technologically accurate line!

But it's relevant to me because now I'm like, is it impressive to say I learned Swift, iOS, and Vapor in one week? Can I even really say I did learn it? It's kind of like saying I 'learned' a language by coding a hello world - not wrong per se, but it would obviously be a lot more impressive to say I built a full stack application with mobile/iOS frontend and backend REST API using Swift - and I didn't do that lol! I just did (parts of) a ton of tutorials and videos, used XCode for the first time, and used Vapor - a framework I had never even heard of before - all in about a week, so I'm feeling accomplished.

I had also been feeling pretty down/discouraged about the whole job search process, and this kind of revived me. I mean there were also times where I was literally pulling my hair out at 2am wondering why I'm the dumbest person on earth. But equal amounts of feeling like a genius. Classic coding ups and downs.

I might never be able to brag about learning iOS in a week to sound smart, but I definitely dove into a whole new world of programming in a relatively short amount of time, and I learned some interesting things.

Background

I find it hard to say exactly when I started coding or first learned to code. But I'd say I really started down the path to becoming a true and obsessive coder in October 2019. I read a book on Python, took an online course in web dev using Python/Flask, and in January 2020, I did the whole in person web dev bootcamp thing for Ruby, Rails, and React.

A very common question for beginners is Where to start? What language to learn first? and a probably even more common response is, It doesn't matter. Just start somewhere, and then it's relatively easy to learn new languages, etc. from there. And it still amazes me how true that is!

For me, looking back, starting with Python was great. But Python/Flask was hard. Very new and confusing, almost entirely self-taught. Then Ruby/Rails at bootcamp - still hard, but a lot better. I noticed small connections to what I already knew and had instructors to help me in person. Now Swift/Vapor - super hard, all on my own, very rushed, but also really cool, and I think kind of tied together for me how similar these 3 major backend frameworks can be. And also different! Same same but different.

Comparing backend/server-side frameworks

I'm not entirely sure what the best way is to compare backend frameworks. But I did recently see this video, and thought it was just a generally super cool visualization, comparing "popularity" based on GitHub stars:

The real difficulty over the last week was learning Vapor - a backend framework for Swift. At the time of writing this, vapor has about 19k stars. And Rails (the main backend framework I knew before this/compared almost everything to) has about 46k.

So why did I choose to learn these things?

Well I'm probably too much in a quantity over quality stage in my programming life. I know the very standard advice about jack of all trades, master of none, don't just list as many tech terms as possible on a resume to look good. But these are desperate times. I'm looking for anything to distinguish myself from all the bootcamp grads who know React.

So when my bootcamp put up a free Swift course for us after graduation, I thought I'd check it out. XCode was a little scary - I still need to figure out all the shortcuts, and I still prefer my VSCode - but I liked it, so I put Swift/iOS on my resume (I'll admit this sounds sleazy, but I promise I didn't lie, and I said 'beginner in Swift/iOS').

And then I got an interview for a Swift backend position. I almost didn't even apply because it seemed so specific and out of reach. I'm not complaining or questioning it, but it is crazy to me how the world works out. I'm still in the interview process though, so I hope writing this doesn't jinx anything.

But I didn't learn Swift just for this interview. I had only just started learning it, so when I got the interview, I spent the entire week leading up to it trying to become an expert in Swift and iOS. iOS wasn't as important for this specific interview - the position is backend, but for a mobile app company. But I wanted to be familiar with the basics of iOS development just in case.

Swift and iOS

At first, I grouped these together. Of course, later, I get to the web/backend API side of Swift. But I started off just thinking ok, I need the basics of Swift and mobile. I still don't know the fundamentals of Swift that well. If you asked me to whiteboard a simple function, I probably could not do it. But I started off kind of skimming the resources from my bootcamp on Swift fundamentals, which helped to get a general vibe and at least be aware of the major differences from the languages I knew before. I checked out the Apple developer docs and Swift.org.

If you really want to learn iOS, I think this video was the best resource I found:

I skimmed/watched the first few minutes of many videos like this, and I thought this one was the best, especially if you're a total beginner. If for nothing else, it was really cool to see a Hello world app on my iPhone. It was like falling in love all over again 🥺

Vapor

GitHub logo vapor / vapor

💧 A server-side Swift web framework.

Vapor

Documentation Team Chat MIT License Continuous Integration Swift 5.2 Twitter

Vapor is a web framework for Swift. It provides a beautifully expressive and easy to use foundation for your next website, API, or cloud project.

Take a look at some of the awesome stuff created with Vapor.

💧 Community

Join the welcoming community of fellow Vapor developers on Discord.

🚀 Contributing

To contribute a feature or idea to Vapor, create an issue explaining your idea or bring it up on Discord.

If you find a bug, please create an issue.

If you find a security vulnerability, please contact security@vapor.codes as soon as possible.

💛 Sponsors

Support Vapor's development by becoming a sponsor.

Nodes Skelpo Transeo Gwynne Raskind Joannis Orlandos Kyle Browning Jari

💚 Backers

Support Vapor's development by becoming a backer.

analytics

I started off doing the tutorial with the most recent version of Vapor (4) but then my code challenge was in Vapor 3. It wasn't that difficult to go back to Vapor 3 but I did encounter some unrelated brew cleanup issues. Either way - check out the Vapor docs if you want to try out the basic setup.

There aren't a lot of blog posts on Vapor, as you might expect! React and JS are the top tags on here for a reason. But this was a very good, comprehensive blog post on Vapor that I found:

PostgreSQL and Fluent

This code challenge required PostgreSQL for the database, and Vapor uses Fluent as its ORM. This reminded me of my Flask experience back in the day, and Fluent reminded me of SQLAlchemy. I thought Postgres was just really hard to learn as a total beginner - but honestly I still struggle with it, even now, as a medium-beginner! And there aren't a lot of posts/explicit tutorials on how to use it. I always end up finding a mess of various docs/examples and typing so many wrong things into the command line before I finally come back to the same obvious, correct one.

This is just to say - if you're a beginner using Postgres, don't be discouraged. There must be a reason why my bootcamp, and so many others I assume, start us off with SQLite and ActiveRecord in Rails. Again, totally might just be because anything feels easier in a structured, in-person context. But this bit from the Rails/Active Record docs makes me think I'm not wrong in thinking it's more beginner friendly:

Convention over Configuration in Active Record

When writing applications using other programming languages or frameworks, it may be necessary to write a lot of configuration code. This is particularly true for ORM frameworks in general. However, if you follow the conventions adopted by Rails, you'll need to write very little configuration (in some cases no configuration at all) when creating Active Record models.

This 'convention v. configuration' thing was a very interesting concept I remember loving at bootcamp. Like, it's so simple and obvious when you hear it, but I hadn't had the words for it before. This might be an oversimplification, but to me, convention over configuration means less writing actual code. Someone far more experienced than you has written the standard stuff. Almost like using a website creator template. You sacrifice flexibility (configuration), but you get more ease, speed, and reliability for basic use. When you're a beginner - you want convention.

So in my limited experiences with postgres and its relevant ORMs, I struggled with the heavier configuration aspect. Small side note for beginners - postgres/SQLite are examples of a database management system (DBMS) and ActiveRecord/Fluent are the Object-relational mapping framework (ORM). Overall, if you're reading this and you want yet another person's specific advice, start with something like ActiveRecord/Rails before something like PostgreSQL/SQLAlchemy.

SwiftNIO

I noticed NIO a lot while debugging/seeing errors building my HTTP REST API with Vapor, so I thought it was worth mentioning. As far as I can tell, in simplest terms, it is a building block within Vapor for routing/creating API endpoints.

GitHub logo apple / swift-nio

Event-driven network application framework for high performance protocol servers & clients, non-blocking.

sswg:graduated|104x20

SwiftNIO

SwiftNIO is a cross-platform asynchronous event-driven network application framework for rapid development of maintainable high performance protocol servers & clients.

It's like Netty, but written for Swift.

Repository organization

The SwiftNIO project is split across multiple repositories:

Repository NIO 2 (Swift 5+) NIO 1 (Swift 4+)
https://github.com/apple/swift-nio
SwiftNIO core
from: "2.0.0" from: "1.0.0"
https://github.com/apple/swift-nio-ssl
TLS (SSL) support
from: "2.0.0" from: "1.0.0"
https://github.com/apple/swift-nio-http2
HTTP/2 support
from: "1.0.0" from: "0.1.0"
https://github.com/apple/swift-nio-extras
useful additions around SwiftNIO
from: "1.0.0" from: "0.1.0"
https://github.com/apple/swift-nio-transport-services
first-class support for macOS, iOS, tvOS, and watchOS
from: "1.0.0" from: "0.1.0"

Protocol Implementations

Below you can find a list of a few protocol implementations that are done with SwiftNIO. This is a non-exhaustive list of protocols that are either part of the SwiftNIO project or are accepted into the SSWG's incubation process. All of the libraries listed below do all of their I/O in a non-blocking fashion using…

SwiftNIO is focused on providing the low-level building blocks for these higher-level applications. When it comes to building a web application, most users will not want to use SwiftNIO directly: instead, they'll want to use one of the many great web frameworks available in the Swift ecosystem. Those web frameworks, however, may choose to use SwiftNIO under the covers to provide their networking support.

Debugging in Vapor

This was, again, harder than debugging I've done in other programs. This could definitely be a lack of research issue, but from the brief googling I did do, it doesn't seem like an uncommon feeling.

I relied on writing my own tests, and adding basic breakpoints manually in XCode. In Rails, I used byebug and rails console a lot, and I didn't find anything analogous in vapor. All just things to get used to and keep researching.

Conclusion

I actually loved trying to learn vapor, Swift, and iOS. I would highly recommend for anyone in a similar medium-level of experience range. I'd probably also recommend Swift and basic, frontend iOS dev for someone with no coding experience at all, because I found XCode to be generally more of a familiar user experience. It's a lot more visual, like you can manually drag and size a button to your iPhone simulator screen without even having to write code.

This ended up being more of a reflection on my experience with this pretty wide range of technologies. I hope it was helpful. Maybe I'll do some more focused tutorials on specific Vapor examples next! Either way, if you made it this far, thanks for reading.

Resources

Top comments (6)

Collapse
 
sinrock profile image
Michael R.

I would definitely say that's something to be proud of! Great article, reading your blog posts makes me motivated to step my own game up! Fantastic writing job!

Collapse
 
djamaile profile image
Djamaile

If you had more time would you use other resources?

Collapse
 
sylviapap profile image
Sylvia Pap

Hmm sorry I’m not quite sure what you mean by other resources. Like, other technologies/frameworks or other tutorials/videos/docs for learning? I’m definitely going to continue reading all the docs, and watching more youtube tutorials

Collapse
 
djamaile profile image
Djamaile

Yeah that is what i meant. Did you get the job?

Collapse
 
omawhite profile image
Omar White

This is really cool! I’ve been wanting to dive into iOS but I have been procrastinating and trying to decide if I want to learn react native first or just skip straight to swift.

Collapse
 
cedricbahirwe profile image
Cedric Bahirwe • Edited

As an iOS Developer, I find this blog post wonderful, this is the definition of learning!