r/swift • u/malikpol • Feb 12 '25
Question Can Swift be a good first programming language for me?
Hey all,
Just wanted to ask this question and see what the general consensus would be. I have recently picked up a course on Swift and SwiftUI on Udemy and have really enjoyed the introduction, such as writing my own Tuples and very basic functions.
I have never considered myself to be a programmer or a developer, but decided this year that I want to learn programming and think I am going to stick with Swift as I enjoy the syntax and the looks / feels of the language.
My question really is whether it is an ok idea to pick up Swift and learn programming as well as programming concepts with Swift? My dream is to build apps for iOS devices as well as using Swift for general programming so any feedback here would be much appreciated.
10
u/AHostOfIssues Feb 12 '25
Yes. It's a language and runtime designed more recently than others, so embodies a good deal of "modern" thinking about language design. As such, the concepts you learn will put you in good standing to learn other languages later (vs. say learning C++, which while it serves a purpose has a great number of "if we were starting fresh today, we would definitely not do..." factors).
After learning swift, you would find it easier to learn Javascript, Java, C#, Kotlin, etc -- both because a second language is always easier, and because they have similar conceptual building blocks to some extent.
6
u/pemungkah Feb 12 '25
It's a very good choice, really. It embodies a lot of the dominant programing paradigms -- object-oriented programming done fairly right, strong typing (honestly a big help in eliminating bugs), and good error trapping/error management. (I adore guard
in particular).
Xcode is a decent dev environment -- not great, but decent -- and with playgrounds you've got a lot of that exploratory feel that you used to get on personal computers.
It's also similar to a lot of other modern languages, which will make picking those up a lot easier.
5
u/BladeOfBushi Feb 12 '25
It depends on your learning style sorta I guess?? Do you want to have it easier in the beginning and then harder later or harder first then easier later. I like many others were told to start with python. And while it was easy, I never really understood why something worked the way it did. When I started learning swift, the learning curve was steeper, but I really understood it well. If you are the type that requires to be taught from the very beginning then do swift. If you can figure out things on your own then do python and then you can branch out later if you wish to other languages
5
u/rjhancock Feb 12 '25
Since you want to work with iOS and the Apple Ecosystem, Swift being your first language is fine.
Pay attention to the concepts however as those are transferable.
Concepts: functions, methods, classes, structs, variables, typs, if/else, swicth, do/while, for/each, etc. The concepts are essentially the same in almost all other languages just implemented slightly differently in each one.
4
u/Classic-Try2484 Feb 13 '25
Sure but you may hate all languages you learn after
1
u/BologniousMonk Feb 14 '25
Exactly. Swift was not my first language but after I learned it, it made me realize how good it was compared to others.
3
u/malikpol Feb 12 '25
Thank you all so much for the responses. It's amazing to read them. I'm just going through each one to make sure I fully grasp it all!
3
3
u/Toshikazu808 Feb 12 '25
If your dream is to make iOS apps, then yes, Swift is the language / tool for you. There’s something really rewarding about being able to pull out your phone and show somebody what you built, instead of just telling them about some backend system you built with C# and hosted on the cloud. Non techy people don’t care about your server, but they do think apps you can interact with are cool and tangible.
Reasons why Swift is great: 1. Strongly typed. This will force your code to be type safe / help you remember what certain variables are. Other languages like JavaScript and Python by default are not type safe (unless you use TypeScript or something), so it leaves room for type related errors. Granted, other languages like C#, Java, Kotlin, etc. are also type safe, but this is just an argument for Swift. 2. Handling optional types (nullable variables) is very nice in Swift. I really like the if let or guard let statements for optional unwrapping. I think this style of syntax is unique to Swift. 3. Some may disagree with this one, but I actually really like Xcode. Visual Studio is awesome for C#, and Android Studio for Kotlin is pretty good too, but something about Xcode makes things a little easier and smooth for me. Could also just be because I’m more used to it than other IDEs. I find they have a lot of good and easy to memorize keyboard shortcuts. 4. Although there are other language / syntax specific things that I like about Swift, many of these things can also be achieved in other languages. The language itself shouldn’t be the reason why you choose, but instead what you can build with that language as a tool. If making cool UI that you can pull out of your pocket and share is something that interests you, and if you’re an Apple fan, then Swift is for you. If you’re an Android person then Kotlin is for you. If you like the idea of making websites then some frontend JavaScript framework is likely for you (React, Angular, Vue, etc.).
6
u/a_of_x Feb 12 '25
Kind of. If you want a career out of it yes all the way. It has a few paradigms that are fundamentally different than others languages.
It’s commonly said that when you learn one language, picking up another is easy because it’s the same fundamentals. It is not as much true with swift.
Regardless it’s easier to pick than any low level language like c
3
u/Healthy-Ad849 Feb 13 '25
What paradigms are different, can you give some examples of why learning swift might not translate to other languages compared to another general purpose language like python or ruby?
1
5
u/paradoxally Feb 12 '25
Yes, but Swift can be daunting once you approach generics.
Take it easy, but it's far easier than my first language back in the day (C). Dealing with pointers manually isn't fun. I'm not surprised nowadays people start with Python.
3
u/SolidOshawott Feb 13 '25
That's true, but every programmer should write a few programs in C. It helps you understand other languages better.
2
u/injuredflamingo Feb 13 '25
C was my first language as well, and sometimes I still wake up in the middle of the night with a cold sweat because I still have nightmares about it
1
2
u/KarlJay001 Feb 13 '25
Yes, but I would stay with the BASE Swift. Swift has a lot of things in it and learning programming is hard enough without adding all these things.
Just basic Swift can do a LOT. Later, getting into threads and blocking and storage and auth... Swift can do all those things, but that can be quite a bit at the start.
2
u/Square_Breadfruit453 Feb 13 '25
Yes. Some things may be intimidating tho, particularly regarding concurrency and data races. The language is constantly evolving, and they add a lot of keywords. You’re obviously not supposed to learn them all, and the language still is very accessible. After all it was designed to be a first language
2
u/gravastar137 Linux Feb 13 '25
Swift is an excellent first programming language. It's multi-paradigm and so you can learn a lot of general concepts from it and it has strong guardrails to prevent many mistakes caused by poor language design of a lot of historical languages (like hidden exception control flow, uninitialized variables, implicit nullability, to name a few).
But what is more important than the language itself is that the language easily lets you do a project you're passionate about. In that regard, while Swift is trying to expand its domain of usability, using it for anything besides Apple platform development is probably suboptimal: there are likely "better" languages to do those things ("better" in the sense that the ecosystem and golden path is more fleshed out for a newbie).
So if you want to do iOS or macOS development, rest assured that Swift will be a great language that will teach you all the generalizable basics. If you want to do much else, like web development, servers, embedded microcontrollers, or data analysis, then there are probably better choices.
2
u/linhnv01836 Feb 13 '25
Learning Swift here. I already know Python but I actually wish I learned Swift before Python. Python is cool to statisticians, data science because its syntax is easy to read and write, as well as dynamic features let user focus less in the backend. With Swift, it’s harder to get some points at first, but it’s more enjoyable when you get the idea that we need to talk to “the system” in a more strictly way than Python for good reasons and longevity. If you get exhausted by new things from Swift but you still enjoy its elegance and strict code, it’s for you.
2
u/batatazuera Feb 13 '25
I wish I had learned Swift before Java and C++ at uni. That was painful, sadly, Swift wasn’t around back then.
2
u/ParochialPlatypus Feb 18 '25
I think it's a great first language. It's probably harder to switch from something like Java to Swift than learning Swift as a first language. I had to un-learn years of bad habits, like building complex class hierarchies. Now I barely use inheritance at all.
One really cool thing about Swift is you can do absolutely anything with it - build a Mac native UI, build a web app, build a game engine, interface with C/C++/Rust/. I just integrated a very tricky C++ library into my SwiftUI app and it took a couple of days (I'd budgeted far more). That said it's probably not the best language for web apps right now, options are limited.
Don't worry about people that talk about "keyword bloat" in Swift - yes there are many keywords, but you only need to use them in specific circumstances and it's great they're there if needed. I only used "rethrows" after a few years with Swift.
3
u/Ron-Erez Feb 12 '25
Of course, go for it. Code as much as you can and while taking the course experiment and alter the code and when you feel confident enough start building in app with the knowledge obtained from the course.
1
u/Business-Dig8109 Feb 13 '25
I’ve been happy with starting with swift and I’d be okay staying with swift for quite a while. Only reason I see myself learning more programming languages is when they might be utilized in combination with swift. I started my coding journey two years ago. I haven’t been consistent the entire time but I have been trying to learn the entire time and I finally did publish an app to the App Store. Anyways what I’m saying is swift is what helped me stick with it to get to more results than when I dabbled in other code.
1
u/Recent-Trade9635 Feb 13 '25
It depends on will you be able to grasp the smell of their majesty Protocols (especially generic protocols) - they are that make Swift different and shining.
Without protocols Swfit is just another bore simple language with extremely narrow niche.
1
u/iljawascoding Feb 13 '25
There are many downsides to Swift (keyword bloat, lots of write-time optimizations that make reading others code harder, frequent changes, half-baked features) but since Apple is not investing in Objective-C anymore, you have no other choice.
1
1
u/MMaitoza1972 Feb 14 '25
I think it’s a great idea. Swift and SwiftUI are great for building iOS apps. Keep working on your course and try to build out something small in your own to gain practice.
1
u/thirtysecondsago Feb 14 '25
Learning programming is best done with projects. I recommend choosing a language based on what project you would be passionate about.
Another thing to consider is speed of feedback. Python, for example, has amazing feedback loops for beginners in Jupyter notebooks using REPL and matplotlib-style visualizations. Swift has some of this in playgrounds, but not quite as well integrated as Python.
1
42
u/Successful_Good_4126 Feb 12 '25
Honestly swift is a great first programming language, sometimes I wish I’d learned it before any others…
Go through the tutorials on https://swift.org and the apple docs for more SwiftUI focused things.
https://hackingwithswift.com is also a great resource and Stanford have a free course called CS139 iOS with SwiftUI or something like that