First Time Programming - I'm Confused?

Discussion in 'iOS Programming' started by Futhark, Jun 23, 2012.

  1. Futhark macrumors 65816

    Futhark

    Joined:
    Jun 12, 2011
    Location:
    Northern Ireland
    #1
    Ok I've decided I'd love to try some programming (Apps for iPhone, iPad or Mac) but I'm getting mixed reports where to start. I've no background in any programming language but have purchased several books on C & Objective-C.

    Some people say I should be starting with C to get the fundamentals of programming and then learn Objective-C but one of the books highly recommended to me "Programming in Objective-C 4th Edition" by Stephen Kochan has this at the beginning of his book, please read and give me your honest opinions please.

    What You Will Learn from This Book


    When I contemplated writing a tutorial on Objective-C, I had to make a fundamental decision. As with other texts on Objective-C, I could write mine to assume that the reader already knew how to write C programs. I could also teach the language from the perspective of using the rich library of routines, such as the Foundation and UIKit frameworks. Some texts also take the approach of teaching how to use the development tools, such as the Mac’s Xcode and the tool formerly known as Interface Builder to design the UI.

    I had several problems adopting this approach. First, learning the entire C language before learning Objective-C is wrong. C is a procedural language containing many features that are not necessary for programming in Objective-C, especially at the novice level. In fact, resorting to some of these features goes against the grain of adhering to a good object-oriented programming methodology. It’s also not a good idea to learn all the details of a procedural language before learning an object-oriented one. This starts the programmer in the wrong direction, and gives the wrong orientation and mindset for fostering a good object-oriented programming style. Just because Objective-C is an extension to the C language doesn’t mean you have to learn C first.

    So I decided neither to teach C first nor to assume prior knowledge of the language. Instead, I decided to take the unconventional approach of teaching Objective-C and the underlying C language as a single integrated language, from an object-oriented programming perspective. The purpose of this book is as its name implies: to teach you how to program in Objective-C. It does not profess to teach you in detail how to use the development tools that are available for entering and debugging programs, or to provide in-depth instructions on how to develop interactive graphical applications. You can learn all that material in greater detail elsewhere, after you’ve learned how to write programs in Objective-C. In fact, mastering that material will be much easier when you have a solid foundation of how to program in Objective-C. This book does not assume much, if any, previous programming experience. In fact, if you’re a novice programmer, with some dedication and hard work you should be able to learn Objective-C as your first programming language. Other readers have been successful at this, based on the feedback I’ve received from the previous editions of this book.

    This book teaches Objective-C by example. As I present each new feature of the language, I usually provide a small complete program example to illustrate the feature. Just as a picture is worth a thousand words, so is a properly chosen program example. You are strongly encouraged to run each program (all of which are available online) and compare the results obtained on your system to those shown in the text. By doing so, you will learn the language and its syntax, but you will also become familiar with the process of compiling and running Objective-C programs.
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    What kind of opinions do you want? Are you asking about the accuracy of Kochan's rationale for why the book is written the way it is? Seems accurate to me.

    Are you asking for some other honest opinion, like how well you as an individual will succeed with this particular book? How could we answer that? Think about exactly what you're asking, and see below for an honest opinion.


    The most important thing in learning programming (or learning anything, really), is to Try It and see what happens.

    Try reading Kochan's book. If you get lost on the first page of Chapter 1, then you need to describe what the problem is. If you don't try it, there's no way anyone can tell you whether you'll succeed or not. All anyone can tell you is that by not doing anything at all, failure is certain.

    There's no way to know which book will work best for you, other than by you actually trying it and seeing what happens. Different people learn in different ways. Trying to predict how you specifically will fare with any given book is pointless. Our opinions are inapplicable, even if some of us may have been programming or teaching for decades. Even the most informed and experienced opinion is still a gamble. We have no in-depth knowledge of your learning style. There is no universal approach that works for all students. Some people will always struggle, even after years of trying.

    Long ago, I read a book that said you don't learn to program by reading books about programming. You learn to program by writing programs. Yes, you will need guidance in the early stages, and the programs will be very simple. But if you don't actually write programs, you won't learn how to write programs. If that seems self-evident, think about how many people you know who think they can write a book because they have lots of experience reading books.
     
  3. Mike73, Jun 23, 2012
    Last edited: Jun 26, 2012

    Mike73 macrumors newbie

    Joined:
    Jun 23, 2012
    #3
    Ok, here we go.
    I started out at the same point as you in Oct. 2011. I did some MS Access and LabView before, so logics wasn't the problem, but I never ever did actual programming before.
    I probably read the same tips and hints as you. Here's what got me started:

    I started out on C++ because I only owned a Windows PC at that time and didn't know then that iOS programming is an absolute no go on a PC. I thought that there may be a workaround, but well, getting a macbook pro was much easier.
    After getting the macbook, I started reading a book on Objective-C. Actually, most of the stuff was very similar to the C++ book I had, but an Objective-C book will get you started on the proper language right from the start.
    As for books, you have to see which one works best for you. I think it comes down to your own preference. So check out several books and see which one works for you.
    Ok, so the start is fairly boring up until you hit stuff like: "now it's time to start your first iOS app" sentences in the books.
    If you made it to here, you at least understood some of the basics. If you get confused, it'll probably go away the more practice you get. Things got clearer for me after some time, even though I didn't understand everything right from the start.
    The first app will get you something like a "Hello World" app. Fairly basic.
    If you follow some of the first examples of your first iOS programming book, there'll be different approaches to programming. Some prefer to stick to fixed programming principles, some stick to the "get started without thinking too much about it" approach. I guess that I mixed this all up, but I got it to the point where I can make it work for me.
    A big thing about iOS books is, that the SDK is being updated constantly. So it won't be easy finding a good book on the most recent SDK. So if you want to stick to the book, get the SDK it was written for. I don't know if this is still possible as XCode is now an app on the appstore, but when I started, it was a standalone installation package. I still have XCode 4.2 on my machine, but could install the most recent version (4.3.3) via the appstore parallel to the old one. Great.
    If you need the book to just get started, then start there and check out forums like stackoverflow.com as soon as you have examples that won't properly work on your SDK.
    As for Objective-C, there seem to be only minor changes over time. So you probably can use any book here. Most books start out with command line programs, so no big thing here.
    Once I had some examples from books running, I had the idea to DIY a gas calculator for fuel consumption (Gas By Numbers, http://itunes.apple.com/us/app/gas-by-numbers/id531541048?mt=8).
    So I just started programming with what I knew. Every time I wanted to implement something I didn't know yet, I googled different solutions to my problems. I must say that I learned a lot over the last 6 months.
    A thanks here to all iOS devs blogging about programming, putting up tutorials or forum posts.
    By the way, I have a blog where I write about my experiences I made over time instead of the technical stuff, which is greatly covered on other blogs already. I rather wanted to focus on the road bumps, the ups and downs you experience while becoming an app developer (link removed as per the forum rules).
    So I made my app work technically first, and every time I stumbled over posts saying that this and that would not be according to apples guidelines, I want back to my machine and changing my code so that it fits. It may have been some extra work, but some guidelines are written like legal text or technical standards. So understanding everything may not be easy and getting the info via a forum post in layman terms is easier.

    Ok, so far here. If you want to know more, let me know. Glad if I can help. I received so much help via forums and tutorials so that I'd love to give something back, too.

    Mike
     
  4. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #4
    Ignore the Objective C book preface. He's just trying to keep the book short and to the point.

    Do you want to be any good at programming?

    Good iOS programmers learn both Objective C and C (any maybe a little bit of Javascript, Python and ARM assembly as well. Perhaps C++ as well.).

    I might start with learning Python scripting on a Mac first (it will eventually be useful to script Xcode builds), then move to all the other useful programming languages.
     
  5. MattInOz macrumors 68030

    MattInOz

    Joined:
    Jan 19, 2006
    Location:
    Sydney
    #5
    I started with this book and it got me to the point I could take on some of the harder challengers of what I have in mind for my app. It also got me to the point I realized even though I had working code I knew there were parts that should have been easier not so convoluted. Then went back to learn more C.

    Then again my background is very object oriented so it did gel well with me.
    The point is if you get started and get in to it you will never stop learning.
    The important thing is to start.
     
  6. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #6
    My thoughts:

    You want to know C. I have not read the book in question, but I suspect that if you learn from it, you may become confused between C and Obj-C (which may become an issue if you later decide to learn other derivatives of C, like C++ or D.)

    You've already asked before and I believe I already told you what I believe to be the quickest route to being able to program for iOS without causing yourself confusion. (It's also a free path.)

    Read and do the exercises from this free ebook:
    http://c.learncodethehardway.org/book/
    It has 50+ chapters, but I suggest starting with exercise 0 and going up through and including exercise 17. If you can learn all of those topics, then you should know enough C to advance on to learning Obj-C.

    For that, I suggest Stanford's free online iOS tutorials.
     
  7. larswik macrumors 68000

    Joined:
    Sep 8, 2006
    #7
    Programming should be fun.

    If you are struggling like I was your trying to move to fast to soon. I gave up on Objective C and went back to C.

    I then took a Pascal programming class (best thing ever) and they taught me things I can not learn in a C book. How to break down a problem in to small parts. How to tackle projects with "top down design" and more.

    As for procedural code, Objective C is some what procedural. When you enter a Method it start executing line by line working its way down.

    If your goal is to make an app over night you will more then likely fail. If you want to be a programmer you will take your time and learn at a good constant pace. I spent over a year learning before I ever started an app.
     
  8. Futhark thread starter macrumors 65816

    Futhark

    Joined:
    Jun 12, 2011
    Location:
    Northern Ireland
    #8
    I've read all your replies and they are really appreciated and i thank you all for going into so much depth.

    I started reading the Programming in Objective-C 4th Edition book but found after the first few exercises which i was able to follow i then started getting a little confused when he started creating Objects, I then watched a few videos on Objective-C by Simon Allardice which helped me understand the concepts i was confused about before (A Lightbulb moment) so i was then able to progress into a new chapter of the book.

    It was at this point i was wondering if i was doing the right thing by trying to learn Objective-C as my first ever programming language so i purchased C for dummies.

    To be honest once i started reading this i found i was understanding things fairly quickly, i'm not sure if it was because i grasped some of the fundamentals from the other book or this was explained better but none the less i'm LEARNING & ENJOYING IT !!!! After each lesson you have exercises to do to see if you understand what has been taught, the beauty of this book is at the very back of the book the author gives you the code answers to the exercises, this way you can compare what you've done to his method.

    As for the Objective-C book i'm sure it will be GREAT to continue with but at this point in time i'm feeling comfortable working through this C for Dummies book and i'll keep at it until completion (i'm on Pages 131 of 993) on route as i learn new skills i'll try little programmes of my own to test my understanding and once happy i've got the hang of things i'll introduce Objective-C.

    Once again thank you all so much for your wonderful answers.
     
  9. Mike73 macrumors newbie

    Joined:
    Jun 23, 2012
    #9
    That's right. It's important to start. Following all possible examples will only get you so far. It's important that you try out stuff you think you learned by using it for your own ideas. Otherwise you'll never know whether or not you have understood what you did.
     
  10. Futhark thread starter macrumors 65816

    Futhark

    Joined:
    Jun 12, 2011
    Location:
    Northern Ireland
    #10
    Yes that came to mind, it's easy following an example but try and solve a problem for myself might be another thing :)

    The C for Dummies is 6 in 1 books. I'm now on Chapter 8 of Book 1 so almost finished it. Once it's done I'm going to review what I've learned so far by trying a few basic apps of my own.

    Wish me luck hehehehe :D
     
  11. larswik macrumors 68000

    Joined:
    Sep 8, 2006
    #11
    Yes.... Reading and the tutorials are different then understanding the concepts and being able to build your own programs.

    I mentioned this before in threads but I didn't leave C until I could write my own console based blackjack game. If you ask yourself now "How would I even start such a thing?"

    I look at it like this. You have all the parts of a car engine on your floor in front of you. As you read you learn about the different tools. You just learned about an IF statement, that's a hammer. You learned about a Switch statement that's a screwdriver and so on. So you start getting all of your tools together to tackle a project and when you have enough tools to do the job you realize that you have no idea how to build an engine? You stand there scratching your head saying "Where do I start?"

    This is when you take pen to paper and start to outline what you want to do. Then break that down into small manageable parts you can convert to code. Tackling a project as a whole for me is impossible. Taking it on as small parts you can do anything!
     
  12. Futhark thread starter macrumors 65816

    Futhark

    Joined:
    Jun 12, 2011
    Location:
    Northern Ireland
    #12
    Someone told me to write pseudo code (I think that's the right name) on paper, basically the program instructions from start to finish in everyday English that I understand then break it down and start coding. This sounds a little like what your saying.
     
  13. larswik macrumors 68000

    Joined:
    Sep 8, 2006
    #13
    Yep, plan it out first.

    But I would not worry about that until you have a grasp of the different tools to use to write code with.

    I had a good friend of mine start to learn how to program so he can work with Android phones. He is slowly working his way through C to learn the basics.
     
  14. Mike73, Jun 26, 2012
    Last edited by a moderator: Jun 26, 2012

    Mike73 macrumors newbie

    Joined:
    Jun 23, 2012
    #14
    I surely cross my fingers for you :)
    But only until I start my next app ;) Haha, just joking.

    A little luck may be needed, but it all comes back to being dedicated to what you want to do. It worked for me, even if I got frustrated some times.
     
  15. Futhark thread starter macrumors 65816

    Futhark

    Joined:
    Jun 12, 2011
    Location:
    Northern Ireland
    #15
    Book 1 finished and thoroughly enjoyed it. That's the basics covered and I've done all the exercise without too many issues but I did try an app of my own mixing up everything I've learned so far. It worked well so I've tried to add a little more to it and now it's not running as expected. Who wants to check my code? :D
     
  16. Mike73 macrumors newbie

    Joined:
    Jun 23, 2012
    #16
    Hi Futhark,
    I'd suggest you post this on stackoverflow. You'll surely get an answer and the forum allows for code posting. It seems you can use the "code" tag here in the forum, too. So if the code isn't too long (the part you suspect which isn't working) just post it here.
     
  17. Futhark, Jun 27, 2012
    Last edited: Jun 27, 2012

    Futhark thread starter macrumors 65816

    Futhark

    Joined:
    Jun 12, 2011
    Location:
    Northern Ireland
    #17
    Cheers Mike it's quite a tiny project so I'll post it in here if it's allowed.
     
  18. Futhark, Jun 27, 2012
    Last edited: Jun 27, 2012

    Futhark thread starter macrumors 65816

    Futhark

    Joined:
    Jun 12, 2011
    Location:
    Northern Ireland
    #18
    Code:
    #include <stdio.h>
    int main()
    {
        float monday,tuesday,wednesday,thursday,friday,saturday,sunday;
        char ch;
        
    	printf("How many hours did you work on Monday?\n");
    	scanf("%f",&monday);
    	printf("How many hours did you work on Tuesday?\n");
    	scanf("%f",&tuesday);
    	printf("How many hours did you work on Wednesday?\n");
    	scanf("%f",&wednesday);
    	printf("How many hours did you work on Thursday?\n");
    	scanf("%f",&thursday);
    	printf("How many hours did you work on Friday?\n");
    	scanf("%f",&friday);
    	printf("How many hours did you work on Saturday?\n");
    	scanf("%f",&saturday);
        
        /* The code below isn't working as it should.  */
        
    	printf("Do you work on a Sunday? (Y/N)?\n");
    	ch = getchar();
    	if(ch == 'N' || ch == 'n')
    	{
            printf("This week you worked:\n%f hours!\n",monday+tuesday+wednesday+thursday+friday+saturday);
    	}
    	else if(ch == 'Y' || ch == 'y')
        {
            printf("How many hours did you work on Sunday?\n");
            scanf("%f",&sunday);
            printf("This week you worked:\n%f hours!\n",monday+tuesday+wednesday+thursday+friday+saturday+sunday);
    	}
        return(0);
    }
     
  19. ianray macrumors 6502

    Joined:
    Jun 22, 2010
    Location:
    @
    #19
    What is not working?

    Is the getchar() failing to wait?

    What character does it return? And why?

    Hope this points you in the right direction :)
     
  20. Futhark thread starter macrumors 65816

    Futhark

    Joined:
    Jun 12, 2011
    Location:
    Northern Ireland
    #20
    Once i get to the line that prints on screen "Do you work on a Sunday? (Y/N)? the program stops running.

    I tried this code also with exactly the same results:

    Code:
    	printf("Do you work on a Sunday? (Y/N)?\n");
    	scanf("%c",&ch);
    	fpurge(stdin);
    	if(ch == 'N' || ch == 'n')
    	{
            printf("This week you worked:\n%f hours!\n",monday+tuesday
            +wednesday+thursday+friday+saturday);
    	}
    	else if(ch == 'Y' || ch == 'y')
        {
            printf("How many hours did you work on Sunday?\n");
            scanf("%f",&sunday);
            printf("This week you worked:\n%f hours!\n",monday+tuesday
            +wednesday+thursday+friday+saturday+sunday);
    	}
        return(0);
    }
    Any ideas what i've done wrong? :confused:
     
  21. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #21
    What indicates to you that the program has ceased running? If you're running in terminal, does it eject you back to the shell or does it just hang and do nothing? Is it crashing?
     
  22. Futhark thread starter macrumors 65816

    Futhark

    Joined:
    Jun 12, 2011
    Location:
    Northern Ireland
    #22
    When run in terminal and it gets to my Y/N question it ejects me back to the shell and if run in Xcode when it gets to the same question it doesn't allow me to type anything.

    I wrote to the author of the C for Dummies book and he said the following:

     
  23. balamw, Jun 28, 2012
    Last edited: Jun 28, 2012

    balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #23
    Try to see if you can answer this question. When it seems to fail, what is the character in "ch"?

    EDIT: What do you expect getchar to do in your code? Is that the behavior you really want?

    B
     
  24. Futhark thread starter macrumors 65816

    Futhark

    Joined:
    Jun 12, 2011
    Location:
    Northern Ireland
    #24

    AHHHHHHH SORTED !!!!! :D i had forgotten to use

    Code:
    fpurge(stdin);
    My program was still carrying the int for Saturdays hours so once i cleared that it works perfectly hehehehehehe D'OH!
     

Share This Page