Forums | MacLife
You are not logged in.
Pages: 1
- Index
- » Programming & Web Dev
- » Learning how to code for OS X if all I know is JavaScript and BASIC?
#1 2009-03-14 7:28 pm
Learning how to code for OS X if all I know is JavaScript and BASIC?
I don't know a lick of Cocoa. (Mmmm...) I don't know a lick of C++. I do know a lot of JavaScript. And am fluent in QuickBASIC. Which doesn't get you anywhere these days.
I want to learn Cocoa. Or even C++ if I have to start there. Whatever. I just want to use Xcode to code apps that can run on OS X. Even if for my own amusement. And I want to eventually work up to programming for the iPhone/iPod Touch.
Now here's the kicker, I want to program GAMES. Not regular apps. I have no need for knowing how to program the next big text editor or database program or OS X utility. I'm strictly interested in game programming.
In BASIC everything was done for me. All I had to do was define the SCREEN mode and use simple commands like LINE and CIRCLE or GET and PUT to draw.
JavaScript these days is fast enough to do some pretty good stuff. I've made a few games in JavaScript and it felt almost as easy as BASIC. Using the Canvas element from HTML5 and CSS to draw and move stuff around based on keyboard or mouse input was fairly easy...
But every time I try to get into Cocoa, I open Xcode and create a new project, or open a sample, and the code is just Greek. I can make out hardly any of it. Even the default iPhone "OpenGL ES Program" creates a sample of a rotating colored square, but when I look at all the files it uses I can't understand a single one!
Is there any book out there for Cocoa and OpenGL learning that will walk me through it as if I were a baby? Or should I stick to JavaScript which will never get me anywhere.
JavaScript seemed like a logical next step, but I need to move up! So what's the next step from JavaScript? Hell, I'll even try Java if I have to.
Also, before anyone posts it, cocoadevcentral.com is a dry well. It doesn't help at all. It's still all over my head. I need baby steps!
Offline
#2 2009-03-14 11:43 pm
- Booksley
- Zombie Genocidest
- From: Toronto, Ontario
- Registered: 2001-02-16
- Posts: 5037
Re: Learning how to code for OS X if all I know is JavaScript and BASIC?
You can't jump right into game programming. You need to get a handle on plain old Objective-C Cocoa development first. I highly highly recommend Cocoa Programming for Mac OS X 3rd edition. It covers the new Objective-C features introduced in Leopard, but still applies to Tiger.
Keep in mind that this book is targeted towards exclusively towards development on your Mac, not the iPhone. But many of the concepts are the same, so I'd really recommend starting on your Mac.
Offline
#3 2009-03-15 1:57 pm
Re: Learning how to code for OS X if all I know is JavaScript and BASIC?
Cocoa Programming for Mac OS X is indeed a good book, but it assumes that you know C. If you don't know C, then there will be quite a few places where you will get lost. After looking around for some resources for you, the online manual Learning GNU C seems to be pretty extensive. Once you learn C, then you can pick up The OpenGL Superbible to learn OpenGL.
Just to prepare you, this will not be a quick learning process. Even once you know the basics, if you want to make a complicated game you're going to need to know a decent amount of other computer science concepts such as data structures, basic algorithms, etc. You will also need to be careful about resource usage including memory, OpenGL resources and the like. However, if you're willing to stick with it, and truly enjoy programming, it can be very rewarding in the end.
Offline
#4 2009-03-15 4:33 pm
Re: Learning how to code for OS X if all I know is JavaScript and BASIC?
I'm willing to start low. I just need to start! I'm 29 and still only know BASIC! This isn't the 80's. That ain't gonna get me anywhere.
I'll start as low as I need to, as long as I can do it in OS X and not have to install Windows or anything.
I'm an autodidact. I taught myself BASIC. I taught myself JavaScript. But I can't seem to teach myself C or Cocoa. Or Fortran or Assembly or anything else for that matter. 
What's the best starting point for someone who doesn't know any C/Cocoa? Pretend I'm in Kindergarten and I need some basics to graduate to first grade.
Thanks 
Offline
#5 2009-03-16 4:20 am
Re: Learning how to code for OS X if all I know is JavaScript and BASIC?
I suggest The C Programming Language by Kernnighan and Ritchie.
Learning C is really the Rosetta stone for progressing beyond being a BASIC hobbyist.
One important thing to know is that you don't need to use any mac-specific coding. You don't need to learn Cocoa or Carbon or interface builder or anything to start programming in C. HERE'S THE RUB: Create your projects in XCode as standard tools. They will use the terminal for standard input and output.
This is important as your next step in gaming would be to learn OpenGL, and you can use the OpenGL utility library (GLUT) to design your user interface.
Then you will eventually want to learn Cocoa/Objective-C for that mac look and because its basically brilliant.
Ho Eyo He Hum
Offline
#6 2009-03-16 4:22 am
Re: Learning how to code for OS X if all I know is JavaScript and BASIC?
But I'll be able to code the C projects and compile them in Xcode, right? I won't have to install any other tools I hope. Xcode has C abilities, right?
What's the difference between C and C++? Is C++ more complicated I assume? And not a good first step?
Will they only run in the Terminal though? Will these apps be capable of a GUI, or am I limited to textual? Because I've done text only when I tried to code a little Python..
Last edited by Jasoco (2009-03-16 4:29 am)
Offline
#7 2009-03-16 4:29 am
Re: Learning how to code for OS X if all I know is JavaScript and BASIC?
Yes, they will compile fine in XCode. You don't need to run them from the terminal, but they will automatically open a terminal window.
When you learn C, you can then learn how to use Apple's libraries to do Window based I/O.
EDIT: Mind you, XCode can be intimidating enough, the trick is realizing you can ignore about 90% of the crap it shows you, and basically choose your text file, edit it, and hit the compile-and-run button.
Last edited by Metacell (2009-03-16 4:33 am)
Ho Eyo He Hum
Offline
#8 2009-03-16 9:58 pm
Re: Learning how to code for OS X if all I know is JavaScript and BASIC?
For your first applications, they will be text only through the terminal. Once you start using GLUT (mentioned earlier, and can be run in C) then you can move outside the terminal, and once you start with Cocoa you can do even more. All of this can be done within XCode.
For the difference between C and C++, you can think of C++ as an extension of C. It has everything C has, plus it can do object oriented programming, generics, and a bunch of other stuff. (don't worry if you didn't understand a word of that
) ObjectiveC is similar to C++ in that it is an extension of C that allows object oriented programming, but it is quite different from C++ in a lot of ways.
Offline
#9 2009-05-01 11:48 am
- mrreet2001
- Member

- From: NW Ohio
- Registered: 2005-05-25
- Posts: 4325
- Website
Re: Learning how to code for OS X if all I know is JavaScript and BASIC?
I found this helpful for getting my feet wet
http://www.cocoalab.com/BecomeAnXcoder.pdf
2.66Ghz QuadCore-Nehalem w/24"LED CD ---2.2Ghz BlackMB---15" 2.4Ghz MBP(work)
Dual 2.3Ghz G5 (4G Ram, 2x 250G HD)(10.5 server)--- 400Mhz G4 PM (10.4 Server)
1.5GHz Powerbook---1.6Ghz G5 iMac
"So he fels down in a poisoning gas."
Online
#10 2009-05-01 11:57 am
- Nefarious
- Tuning Fork
- Moderator

- From: 45°22"N 84°57"W
- Registered: 2002-09-30
- Posts: 7996
Re: Learning how to code for OS X if all I know is JavaScript and BASIC?
You need to know how to use Interface Builder, unless you do your own custom interface. Designing an interface is easy with IB. Then you need to know how to connect an interface to a subroutine.
Offline
#11 2009-05-01 12:02 pm
Re: Learning how to code for OS X if all I know is JavaScript and BASIC?
That second part usually ends up being the prat I have trouble with.
It's easy to drag stuff around the UI, put it where you want it, make sure it looks like a Mac app. But I usually fail when it comes time to link the interface to the code. I don't know why. I've followed examples word for word and still failed to get it to work.
Then there's the countless times Apple changes the interface of the two programs so old tutorials still refer to parts of the program that have been moved elsewhere or renamed and don't look anything like the screenshots do now.
I come from a VisualBASIC background. In VB (At least the last versions I used, which were a Windows 3.11 full copy of VB 1.0 and a lite personal version of VB 6.0) all I had to do was arrange the stuff on the window, and double-click it to open its subroutine list. Add the code in for the Click and DoubleClick and MouseOver etc subroutines and run the program and it worked. But in Xcode, I can't just double-click an element in IB and have it open the corresponding functions list in Xcode. There was no linking in VB. The elements had a predetermined set of subroutines already attached and ready to fill.
Offline
#12 2009-05-01 12:35 pm
- mrreet2001
- Member

- From: NW Ohio
- Registered: 2005-05-25
- Posts: 4325
- Website
Re: Learning how to code for OS X if all I know is JavaScript and BASIC?
Thats the huge problem I am having.
I Started on Pascal in early High School then self taught my self javascript. I got VB in late HS and it was really easy because of how close it was to JS. I have been using RealBasic for building my Mac apps ... but alas I want to program on the iphone so I need to learn C ... DOH. C (particularly Objective C) is a very wonky world to come into from where I am use to.
I can get over the syntax differences ... but the bass akwards way of making objects work is kicking my butt.
That pdf that I linked was the first Obj-C program I got to work. It's a huge stride from the clicking and swearing state I was in last week. I am looking into some "real" books now that I actually got something to work.
I am going to try to find the following locally to see if they are what I am looking for:
Learn C on the Mac
Learn Objective–C on the Mac
Beginning iPhone Development
http://www.amazon.com/s/ref=nb_ss_gw?ur … =0&y=0
2.66Ghz QuadCore-Nehalem w/24"LED CD ---2.2Ghz BlackMB---15" 2.4Ghz MBP(work)
Dual 2.3Ghz G5 (4G Ram, 2x 250G HD)(10.5 server)--- 400Mhz G4 PM (10.4 Server)
1.5GHz Powerbook---1.6Ghz G5 iMac
"So he fels down in a poisoning gas."
Online
#13 2009-05-01 1:31 pm
Re: Learning how to code for OS X if all I know is JavaScript and BASIC?
Jasoco will start the next Bungie! YEAH!
http://marathon.bungie.org/story/scrapbook.html
...Alex Dropped his cereal bowl in the sink, jogged down to the campus bookstore and skulked up to the register with a copy of Think C. He returned home to his Macintosh, determined to do whatever was necessary to become a one-man wrecking crew in the software industry, He agonized over what he would name his company, finally settling on “Bungie” because “it sounded fun.”...
Offline
Pages: 1
- Index
- » Programming & Web Dev
- » Learning how to code for OS X if all I know is JavaScript and BASIC?


Get it
Stack it!