Starting Programming Advice

Discussion in 'Mac Programming' started by iAppleMacBook, Jan 31, 2011.

  1. iAppleMacBook macrumors newbie

    Joined:
    Jan 31, 2011
    #1
    Please could someone advise me on what programming language to learn first, I have no programming experience. I would like to learn something that will be beneficial and recognised to help me start a career in programming?
    Also what tools would I need to learn the suggested language?

    Thanks
     
  2. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    First things first you need to download Xcode to get all the compilers, tools and infrastructure installed.

    Opinions are divided some say start with C first, some say Objective-C others say Python or Ruby. All will probably get you to where you want to go and are good quality languages. I started with C myself but understand that not everyone feels comfortable following that approach. Although I do think it did me a great benefit.

    If that is what you want to start with then once you have Xcode installed (you can download it from http://developer.apple.com/iphone - you may as well get the iPhone SDK at the same time in case you ever want to do some iPhone stuff) you should get yourself a decent book. The two books I will recommend are "Pointers on C" and "The C Programming Language 2nd Edition".

    If instead you would rather start with Python you can just head over here and read this tutorial: http://docs.python.org/tutorial/index.html - I have to say that Python is incredibly nice to use and despite what some might say it is as good as any other language I hear people recommend.

    I would personally recommend that you ignore anything with the work BASIC in the title.

    P.S Read the guides at the top of this forum.
     
  3. iAppleMacBook thread starter macrumors newbie

    Joined:
    Jan 31, 2011
    #3
    Thanks a lot, much appreciated. I think I will go with C and see how I get on!

     
  4. iAppleMacBook thread starter macrumors newbie

    Joined:
    Jan 31, 2011
    #4
    What would I use in Developer Tools to compile a C program?
     
  5. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #5
    The terminal and either the gcc compiler or the clang compiler (assuming you are using Mac OS X 10.6+). You'll need to find yourself a decent text editor first though. Vim, Emacs, TextWrangler, TextMate and BBEdit are all commonly recommended. All but the last two are free as well.
     
  6. larswik macrumors 68000

    Joined:
    Sep 8, 2006
    #6
    Yes, I wound up with C. I got the book 'Learning C on the Mac' and it is great! I started with Objective-C using the popular book buy Stephen Kochan that everyone said get and it was hard to read and very boring. If you find C still a little difficult take a step back to Python.

    Also I just start taking Pascal programming class at a local city collage. Learning from a book is good, but it is also good to have people to talk to and ask questions, like this forum.

    -Lars
     
  7. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #7
    As others have said, C is the lingua franca of programming. Many other languages are related to it like C++ and Objective-C. But one thing to note is that most careers in programming will not be in C.

    You'll need to learn other languages and toolkits along the way.

    If the Mac/iOS is your target platform of choice, Objective-C, Foundation then Cocoa and Cocoa Touch will be your next steps, but you will need to learn other specific toolkits and frameworks along the way.

    I'm also of the school that thinks the best way to learn how to program is to do something else you know how to do, or like how to do in code. A business major should learn programming by writing business apps, if you are a musician focus on tools that tie in to music somehow, ....

    B
     
  8. Bill McEnaney macrumors 6502

    Joined:
    Apr 29, 2010
    #8
    I agree with B. So I think that if there's a language programmers usually write when they program for your profession, learn that language. Too often beginning programmers learn a programming language because it's popular or the most popular one they know of. They ignore whether it's the best one for the problems they need to solve. If I wanted to write, say, a natural language interface, I'd write it in Prolog because its designers invented it for natural language processing.
     
  9. chrono1081 macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #9
    Nu uh! C++ is the best language out there and solves everything and is what WoW is written in!!! :rolleyes:

    (I'm kidding OP please don't take the above serious although when learning to program you will see what I wrote in a LOT of different places).

    The biggest thing is to pick a language (C is fine), learn it very well, and then you can hop to other languages. Concepts remain the same for the most part, its mostly the syntax that changes in many cases. Once you learn one language well others are easy to pick up.
     
  10. Bill McEnaney, Jan 31, 2011
    Last edited: Feb 1, 2011

    Bill McEnaney macrumors 6502

    Joined:
    Apr 29, 2010
    #10
    Oh yeah? Dem's fighin' words. Let's see ya do dis in C++. In (http://www.haskell.org/haskellwiki/Why_Haskell_matters#Elegance). :) The Haskell quicksort program is about 23 lines shorter than the C++ template for the same algorithm. The Haskell program will sort any sortable data, but you don't need to declare their type.

    Speaking of Dem's, I'm a very paleoconservative member of the Constitution Party. ;)
     
  11. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #11
    If you want to be a good professional programmer, you should learn more than one language. Pick whatever's the easiest language for you to start with, but move on before you get too used to it, and learn another 2 or 3. Maybe start with an interpretive scripting language, and move on to a compiled language, an OOP language, javascript for web pages, maybe a CGI language, etc.

    For instance for iOS development, I might use Objective C for the UI, plain C for real-time audio processing, Javascript inside the app's UIWebviews, Applescript to help automate Xcode builds, php on the app customer support web site, Perl or Basic to analyze and chart the data from itunes download trend reports. and etc.
     
  12. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #12
    That may very well be true but the quote you posted quite clearly talked about which language to start with.
     
  13. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #13
    I've only skimmed it, but Lifehacker just posted a 4.5 section course for beginning coders based on javascript. http://lifehacker.com/5744113/learn-to-code-the-full-beginners-guide

    It includes a video and is designed to be a bite sized (15 minute-ish intro, so the whole thing shouldn't take longer than 2 hours.)

    I plan to run through it when I'm trapped by snowmageddon XVIII tomorrow.

    B
     
  14. chrono1081 macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #14
    Ha! I was waiting for a Haskell link! You sir did not disappoint!
     
  15. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #15
    Whatever language one finds the easiest to learn. For that, it's best to find what kids like to do.

    Many years ago, the library had dozens of books on Basic and Logo (even Forth), written at a level accesible to the average (non-genius) 12 year old kid. Computer programming literacy (as opposed to computer use literacy) seemed far higher back them, among both kids and adults. Those older languages are now out of fad and the books out of print, and there seem to be very few suitable replacements. Maybe some web sites for Python and Squeak. The Javascript sites I've seen seem to be targeted at adults, not kids.
     
  16. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #16
    I remember learning Basic as a kid from books obtained from my local library. These books were illustrated with robots that had words on them like "print" and "let". The illustrations shows the robots doing things with data represented as cubes with 2 or "hello" in them. For example, I'd see a "let" robot put a data cube into a box labelled "A".

    I'm forever thankful for starting as a kid with these kind of books. I think they were responsible for giving me a really solid foundation. And my transition from procedural to OOP was also relatively easy. I just when back to thinking about the robots again. But now the robots had boxes inside them, and they started talking to each other.

    I really think C is not a good first language. It's full of power and pitfalls that are a curse to a beginner. A beginner needs a language that save them from themselves. Pascal, for example, is still taught for this very reason. I wouldn't suggest Pascal, perhaps something like Ruby or Python.

    Once one is confident with dividing and conquering a problem, then I think it's good to pick up C has a second language, to really start thinking like the computer thinks.
     
  17. Bill McEnaney, Feb 1, 2011
    Last edited: Feb 1, 2011

    Bill McEnaney macrumors 6502

    Joined:
    Apr 29, 2010
    #17
    I'm happy to hear that I did not disappoint, my friend. I always love to promote my favorite programming language.

    I think you can shorten the Haskell quicksort to

    Code:
    qsort [] = []
    qsort(x:xs) = (filter < x xs) ++ [x] ++(filter >= xs)
    In C, you just call the qsort function, but before you call it, you need to write a comparison function. To use the Haskell program to sort data into decreasing order, just swap the relational operators < and >=.

    Haskell's programs collect their own garbage. You can't dangle pointer in that language, you don't need to define constructors or destructors in it, Haskell functions can't cause side-effects . . .

    Curry is even better than Haskell because Curry lets you combine functional programming and logic programming in the same program. Curry and Haskell are great for compiler writers, too, because they'll astound with the tiny parsers you can write in them. So I'll how you guys one.
     
  18. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #18
    If you like that kind of thing you'll love Erlang.

    http://learnyousomeerlang.com/
     
  19. Bill McEnaney, Feb 1, 2011
    Last edited: Feb 2, 2011

    Bill McEnaney macrumors 6502

    Joined:
    Apr 29, 2010
    #19
    Thanks, Cromulent. I do like Erlang, I wanted to install an Erlang compiler on my iMac, too, but I thought no one wrote one for it. I think there are Windows, Unix, and and Linux, compilers for it. I seem to remember that I ran one on my Solaris box before that machine decided to hide under my bed. :) Ooh, I miss the big, old guy.
     
  20. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #20
    Macports has a Erlang port, currently at version R14B01.
     
  21. Bill McEnaney, Feb 2, 2011
    Last edited: Feb 2, 2011

    Bill McEnaney macrumors 6502

    Joined:
    Apr 29, 2010
    #21
    Thanks, jimianus. I'll look into it. Earlier this morning, the "make" command ended abnormally because some program didn't have permission to do something or other. Since I'm a Solaris guy, I'm used to running the "su" command instead of "sudo." Maybe, if I run make with sudo, the program I'll get an Erlang compiler, even without downloading anything from Macports.
     
  22. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #22
    Just download the source code and compile it yourself from http://www.erlang.org. It works a treat.

    I NEVER use Macports or Fink. Its always much better in my opinion to compile it yourself so you can enable or disable features as you need them.

    Just issue the following commands to get it installed and working:

    Code:
    ./configure --enable-threads --enable-smp-support --enable-kernel-poll --enable-sctp --enable-hipe --enable-native-libs --enable-shared-zlib --enable-darwin-64bit --with-ssl --with-javac --with-termcap --enable-dynamic-ssl-lib
    Code:
    make
    Code:
    sudo make install
     
  23. Bill McEnaney macrumors 6502

    Joined:
    Apr 29, 2010
    #23
    Great. I'll do that. Thanks.
     
  24. Mac Player, Feb 2, 2011
    Last edited: Feb 2, 2011

    Mac Player macrumors regular

    Joined:
    Jan 19, 2006
    #24
    O noes!! Teh Haskell fans comparing crappy algorithms written in crappy style in another language. Why don't you use stl's partition? Why are you allocating new arrays? Why are you using arrays instead of iterators?

    So will the C++ program as long as you provide a "<" operator.

    Sketch (using lambdas instead of predicate structures):

    Code:
    #include <algorithm>
    
    template<class Iterator>
    void sort(Iterator first, Iterator last) {
        if (first == last) return;
        Iterator middle = partition(first, last, [=](decltype(*first) a) {
            a < *first;
        });
        sort(first, middle);
        sort(middle, last);
    }
    
     
  25. Bill McEnaney, Feb 2, 2011
    Last edited: Feb 2, 2011

    Bill McEnaney macrumors 6502

    Joined:
    Apr 29, 2010
    #25
    I think you may be blurring the difference between a "crappy" algorithm and a poorly written program that uses it. If the quicksort algorithm is "crappy," why does your program at least seem to use it when it tells your computer how to partition the list it the list the machine sorts? Quicksort works poorly when the list is already or nearly in order. But I think n log n time complexity is quite good. If there's a faster sorting algorithm, why does C's collection of standard functions include a quicksort function rather than, say, a heapsort function or a merge sort function?

    Why use arrays instead of iterators? I don't know. Maybe iterators need more overhead than arrays do. Even if you do use an iterator instead of an array, what kind of data structure represents the list while your computer partitions it? That list just might be in an array.

    Maybe you won't write as though the program sorts the list? Because the computer sorts the list by obeying the program's instructions? A program is like a recipe. The recipe tells the chef what to do, how to do it, and what to do it to. A recipe doesn't make a brownie. The pastry chef makes it when she obeys the recipe's instructions.

    Precision, my friend. Don't blur distinctions when you're talking to a guy who earned a philosophy degree. :D

    Why don't I use C++? I don't need to use it, and I do my best programming in other languages much different from it. For me, C-like languages are last resorts.

    Your quicksort template is a fine piece of code. But it's still longer than the Haskell quicksort.

    Here's another fun fact that may interest some people here, besides me. A list's first element can be the wrong one to use as the pivot when you quicksort a list. The median-of-three algorithm often improves quicksort's performance. To choose a pivot that way, you take an element from the first part of the list, another from the middle of that list, and the third from the last part of the last. The pivot would be the middle element if you sorted those three elements into increasing order.
     

Share This Page