Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

The Cockney Rebel

macrumors 68030
Original poster
Nov 16, 2018
2,921
3,589
I recently started to learn to code, and decided to start with Swift as I want to develop for Apple's platforms.

However, I'm finding it so hard to "get" any of it?

I have numerous books, and have subscribed to decent courses on Udemy (free) but it's like there's a brick wall in my brain, preventing anything from getting in.

Can anyone please advise on techniques/ways/tips to learning this, for an absolute beginner?

Thanks in advance for any assistance.
 
I’ve written several posts about good learning resources in the past. If you just go to the developer forum and go just 2 or 3 threads back there’ll be a list of resources there as well as more further back I’ve written out.

As always I’ll also offer mentoring if you want, code review and helping you along with everything you might come across.

What’s causing you issues at this moment?
I can honestly advice not bothering with Udemy courses. I’ve not found anything worthwhile on there.

In essence, programming is just 3 things.
Sequence - instructions one after another
Selection - Conditionally doing one thing or another based on some state
Iteration - Repeating something a number of times


That’s it. That’s the root of all programming. Everything else is abstractions, notation, and figuring out which sequences, selections and iterations are needed to achieve your goal.

Good code is about structuring it so it’s easy to read and understand and that often involves pushing things up the ladder of abstraction, object oriented style for example may favour polymorphic calling structures rather than if statements or switches but it’s still just a form of selection.

As with most things you learn, the more you know the more you begin tying things together in your mind and making further understanding easier.
For this reason I honestly think everyone, after sufficient experience, should also learn some assembly - At one point you get to a point where you can look at high level code in your language of choice and see how it might be translated to machine code. - Not how it will be necessarily; Compilers can do a lot of fancy stuff for us; But one way it could be.

You can always reach me on here or as always contact me through any of the listed options on my site:
 
I’ve written several posts about good learning resources in the past. If you just go to the developer forum and go just 2 or 3 threads back there’ll be a list of resources there as well as more further back I’ve written out.

As always I’ll also offer mentoring if you want, code review and helping you along with everything you might come across.

What’s causing you issues at this moment?
I can honestly advice not bothering with Udemy courses. I’ve not found anything worthwhile on there.

In essence, programming is just 3 things.
Sequence - instructions one after another
Selection - Conditionally doing one thing or another based on some state
Iteration - Repeating something a number of times


That’s it. That’s the root of all programming. Everything else is abstractions, notation, and figuring out which sequences, selections and iterations are needed to achieve your goal.

Good code is about structuring it so it’s easy to read and understand and that often involves pushing things up the ladder of abstraction, object oriented style for example may favour polymorphic calling structures rather than if statements or switches but it’s still just a form of selection.

As with most things you learn, the more you know the more you begin tying things together in your mind and making further understanding easier.
For this reason I honestly think everyone, after sufficient experience, should also learn some assembly - At one point you get to a point where you can look at high level code in your language of choice and see how it might be translated to machine code. - Not how it will be necessarily; Compilers can do a lot of fancy stuff for us; But one way it could be.

You can always reach me on here or as always contact me through any of the listed options on my site:
Than you, buddy.

I really appreciate you taking the time to compose such a detailed response.

I think one (major) thing that’s holding me back is my mental health issues, for which I take quite a bit of medication. This in turn “slows me down” and makes it difficult for anything to stick in my mind.

Code With Chris on Udemy has been quite good, but it’s reached the point where I’m just not able to absorb the information.

I have some books, but the example code is too small for me to read in some of them.

Not making excuses, but these are my barriers.

Thanks again for your time; it’s much appreciated.
 
I think one (major) thing that’s holding me back is my mental health issues, for which I take quite a bit of medication. This in turn “slows me down” and makes it difficult for anything to stick in my mind.

Code With Chris on Udemy has been quite good, but it’s reached the point where I’m just not able to absorb the information.

Sorry to hear about mental health issues. - It's likely something different but I've had plenty of fights with depression which is seriously demotivating, so yeah that sucks.

With code though it may be nice to know that you don't need to remember very much. You can easily be overwhelmed with all the API calls and such in some tutorials and such, but you don't need to remember all that. You're not a "real programmer" by remembering how to do every kind of API call. It's OK to look things up when you need them, and in fact we (we here being computer scientists and programmers) almost always have API documentation and Stack open along with our code. The APIs you often engage with you'll remember at some point - but even though I've a distributed messaging system in Go; I cannot for the life of me remember how to start listening on a specified TDP socket in Go. - But you don't need to remember. You just need to know what you want to achieve and you look up how to achieve it in small chunks and put it together.

Also remember to actually try and code your own things based on what you learn. Just copying what's shown in a tutorial doesn't help understanding anywhere near as much as taking the general concepts and playing around with them on your own.

Normally I'd also recommend reading through other people's code on GitHub, but I don't actually have any good examples of Swift projects - I'm sure there are many good ones, I don't know any that are approachable though.
I have two up there in Swift, a macOS Manu Bar app and a Linux CLI program (also works on Mac, but intended for Linux) that is meant to interact with cron - But they're not really cleanly coded since I just wanted to quickly push them out there for personal usage and they do what I need even though HexHelper specifically doesn't give the best UX possible.
if you want to have a look
Unfortunately most of my repositories are private and I'm not allowed to publish them so I only have those two Swift projects publicly visible.

I also recommended him in the prior post I made about resources, but I really recommend checking out Paul Hudson's work for learning Swift. Along with his app with daily small simple challenges and such.

If you have any small ideas; Things that feel like they should be super simple to make, either GUI programs or command line tools - I think just try working on your own ideas. Throw away guides, tutorials, courses and books for a bit and just jump into it. No sample code, all just your code. Start with one problem at a time; Write a list of what you want to achieve, like

TODO APP:
• A list view with pre-programmed todo items
• Make list dependant on stored data.
• Make user able to add to the list in memory
• Save edits to stored information
• Allow deleting from the list

And figure out how to achieve each part one at a time until you've built your first simple program all on your own. And more importantly, where you made all the decisions about how to structure it.
 
  • Like
Reactions: The Cockney Rebel
Sorry to hear about mental health issues. - It's likely something different but I've had plenty of fights with depression which is seriously demotivating, so yeah that sucks.

With code though it may be nice to know that you don't need to remember very much. You can easily be overwhelmed with all the API calls and such in some tutorials and such, but you don't need to remember all that. You're not a "real programmer" by remembering how to do every kind of API call. It's OK to look things up when you need them, and in fact we (we here being computer scientists and programmers) almost always have API documentation and Stack open along with our code. The APIs you often engage with you'll remember at some point - but even though I've a distributed messaging system in Go; I cannot for the life of me remember how to start listening on a specified TDP socket in Go. - But you don't need to remember. You just need to know what you want to achieve and you look up how to achieve it in small chunks and put it together.

Also remember to actually try and code your own things based on what you learn. Just copying what's shown in a tutorial doesn't help understanding anywhere near as much as taking the general concepts and playing around with them on your own.

Normally I'd also recommend reading through other people's code on GitHub, but I don't actually have any good examples of Swift projects - I'm sure there are many good ones, I don't know any that are approachable though.
I have two up there in Swift, a macOS Manu Bar app and a Linux CLI program (also works on Mac, but intended for Linux) that is meant to interact with cron - But they're not really cleanly coded since I just wanted to quickly push them out there for personal usage and they do what I need even though HexHelper specifically doesn't give the best UX possible.
if you want to have a look
Unfortunately most of my repositories are private and I'm not allowed to publish them so I only have those two Swift projects publicly visible.

I also recommended him in the prior post I made about resources, but I really recommend checking out Paul Hudson's work for learning Swift. Along with his app with daily small simple challenges and such.

If you have any small ideas; Things that feel like they should be super simple to make, either GUI programs or command line tools - I think just try working on your own ideas. Throw away guides, tutorials, courses and books for a bit and just jump into it. No sample code, all just your code. Start with one problem at a time; Write a list of what you want to achieve, like

TODO APP:
• A list view with pre-programmed todo items
• Make list dependant on stored data.
• Make user able to add to the list in memory
• Save edits to stored information
• Allow deleting from the list

And figure out how to achieve each part one at a time until you've built your first simple program all on your own. And more importantly, where you made all the decisions about how to structure it.
Hey mate, thanks a lot for that.

You make perfect sense, and I have taken all of your advice onboard.

I’ll be sure to have a look at your available apps (I’ve already visited your site.)

I don’t want to give the “dream” up, seeing as I’ve just bought an M1 MBP, and one of the reasons for me buying it is to learn to code.

Thanks again for your assistance ... you’re a great fella.
 
Hey mate, thanks a lot for that.

You make perfect sense, and I have taken all of your advice onboard.

I’ll be sure to have a look at your available apps (I’ve already visited your site.)

I don’t want to give the “dream” up, seeing as I’ve just bought an M1 MBP, and one of the reasons for me buying it is to learn to code.

Thanks again for your assistance ... you’re a great fella.

Always happy to do whatever I can to hopefully help.

At some point you'll crack through I'm sure so definitely keep the dream alive :)

Actually; The Swift you've looked at - Have you only looked at GUI apps or have you also looked at code that has its own entry point? With GUI apps like the ones written in UIKit and AppKit the code you write is never the start of the program. The framework starts and then calls your code, so control sort of passes back and forth. Might be a good idea to also peel back that abstraction somewhat and first understand code you fully control for command line tools. Then get a feel for a very basic UI app - like if you just start a single-view app template in Xcode the main program loop is handled by the framework that then gives you specific control points to respond to events like "The app has started [run your code]"
Might aid understanding to know that when the app is clicked the first lines of code executed are not yours, but UIKit's; That then calls your code - the functions that are already made in the templates; Those are not for you to call like functions normally are; Those are the ones UIKit calls. So for UI apps there's that to keep in mind. You're not always using your code yourself. You're sometimes making code available for the framework to call
 
  • Like
Reactions: The Cockney Rebel
Always happy to do whatever I can to hopefully help.

At some point you'll crack through I'm sure so definitely keep the dream alive :)

Actually; The Swift you've looked at - Have you only looked at GUI apps or have you also looked at code that has its own entry point? With GUI apps like the ones written in UIKit and AppKit the code you write is never the start of the program. The framework starts and then calls your code, so control sort of passes back and forth. Might be a good idea to also peel back that abstraction somewhat and first understand code you fully control for command line tools. Then get a feel for a very basic UI app - like if you just start a single-view app template in Xcode the main program loop is handled by the framework that then gives you specific control points to respond to events like "The app has started [run your code]"
Might aid understanding to know that when the app is clicked the first lines of code executed are not yours, but UIKit's; That then calls your code - the functions that are already made in the templates; Those are not for you to call like functions normally are; Those are the ones UIKit calls. So for UI apps there's that to keep in mind. You're not always using your code yourself. You're sometimes making code available for the framework to call
I’m actually thinking of switching to Python.

From what I’ve read, and watched on YouTube, it’s a higher level language, so should be an “easier” way to get myself into. Coding?

Rather than just give up, I think this would be the best way to start.
 
I’m actually thinking of switching to Python.

From what I’ve read, and watched on YouTube, it’s a higher level language, so should be an “easier” way to get myself into. Coding?

Rather than just give up, I think this would be the best way to start.
I would not define Python as inherently higher level than Swift.

Swift is generally fairly high level, it just also has the option of exposing lower level concepts, but unless you're doing intense performance optimisations, inter-operating with C, or writing Metal you won't see or touch that.
Every conceptual way of programming Python should be conceptually the same in Swift so I advice against switching if you've already begun with Swift.

When I first started programming I got almost nowhere because I started learning, then changed language cause I felt I got stuck - this happened like 4 times. You're better served just picking something and pushing through. Instead of relearning the basics over and over in new languages, graduate yourself to understanding one language better and you'll be better off and able to learn other languages later in the blink of an eye, instead of climbing the same hill over and over.
 
  • Like
Reactions: The Cockney Rebel
I would not define Python as inherently higher level than Swift.

Swift is generally fairly high level, it just also has the option of exposing lower level concepts, but unless you're doing intense performance optimisations, inter-operating with C, or writing Metal you won't see or touch that.
Every conceptual way of programming Python should be conceptually the same in Swift so I advice against switching if you've already begun with Swift.

When I first started programming I got almost nowhere because I started learning, then changed language cause I felt I got stuck - this happened like 4 times. You're better served just picking something and pushing through. Instead of relearning the basics over and over in new languages, graduate yourself to understanding one language better and you'll be better off and able to learn other languages later in the blink of an eye, instead of climbing the same hill over and over.
Thanks for the heads up.

Maybe I’ll stick with Swift, then.

It’s all just so overwhelming.

I think I’ll leave it alone for today, then have another go tomorrow.

What YouTube channels would you recommend? I’ll also try to work my way through the course I started on Udemy.
 
What YouTube channels would you recommend? I’ll also try to work my way through the course I started on Udemy.

Paul Hudson is the only YouTube source I would describe as "fantastic". Everything else I think is "as needed". Paul Hudson I could recommend watching everything of, but other YouTube sources I would mostly just say that if you're stumped by a specific thing, search and find something appropriate

There's a Playlist of just some of his work; Tiny, digestable videos that each cover a small thing.
He also does streams where he builds an app in 2 hours or so.
There are also videos where he digs into the source files of the Swift standard library to show that implementations of standard features are actually understandable, etc.

He's doing a series on SwiftUI too that's quite far along (maybe done)
 
  • Like
Reactions: The Cockney Rebel
Paul Hudson is the only YouTube source I would describe as "fantastic". Everything else I think is "as needed". Paul Hudson I could recommend watching everything of, but other YouTube sources I would mostly just say that if you're stumped by a specific thing, search and find something appropriate

There's a Playlist of just some of his work; Tiny, digestable videos that each cover a small thing.
He also does streams where he builds an app in 2 hours or so.
There are also videos where he digs into the source files of the Swift standard library to show that implementations of standard features are actually understandable, etc.

He's doing a series on SwiftUI too that's quite far along (maybe done)
Once again, thank you so much.

I shall check out this fellow, and hope that his tutorials are easy to follow.

I can’t thank you enough for your help, and encouragement.

Thank you.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.