PDA

View Full Version : What's Programming??




hob
Aug 14, 2006, 01:17 PM
Hey everyone, I'm a totally newbie to programming on the mac!

Infact, the furthest I ever got was doing a tiny bit of Visual Basic at school.

So I was just reading the wiki guide, and I am still confused. I don't know what I need to start learning in order to make a nice app. There's nowhere I can see that nicely defines all the concepts such as cocoa/carbon etc.

I just want to make a program that interacts with the iTunes library, and helps users add MP3s to the library a little easier (I just got annoyed after adding a new album and having to number all the tracks one by one...)

So do I need to learn C++?



CANEHDN
Aug 14, 2006, 01:31 PM
You should get a book. O'Reily books are really good. You could probably start with cocoa. It's muchly derived from C++ that if you ever needed C++ you would have a firm grasp on it already. And cocoa will make it easier when dealing with OS X.

MrFusion
Aug 14, 2006, 01:38 PM
You should get a book. O'Reily books are really good. You could probably start with cocoa. It's muchly derived from C++ that if you ever needed C++ you would have a firm grasp on it already. And cocoa will make it easier when dealing with OS X.
He or she should start with objective-c, and then move on to cocoa.
If you can program shell-like programs with obj-c, then it's time to move on to a GUI. If you don't know how to program, GUI's are nothing but distractions. Don't assume that because you know how a for loop or while loop works, that you know how the program in obj-c or any other syntax than the one you learn the basics with.

notjustjay
Aug 14, 2006, 02:28 PM
Could this be done with an AppleScript?

or even Automator?

plinden
Aug 14, 2006, 02:28 PM
Take a look at Automator first. It's a pretty simple way (for me anyway - I've heard that it's still difficult for non-programmers, but I can't see that myself since there's no programming involved.) of creating small apps like what you're suggesting. There are built in tasks for e.g. interacting with iTunes.

mduser63
Aug 14, 2006, 02:32 PM
I'm not by any means trying to discourage you from learning programming, including C/C++/Objective-C/Java (in fact I would encourage it), but I have to say that what you're talking about can be done with AppleScript, and it probably already mostly has been done. For example, I already have a script that will automatically number tracks. I have another script that will automatically name them based on the contents of a plain text file. Some of the scripts I have I downloaded, others I wrote myself.

hob
Aug 14, 2006, 02:33 PM
Yeah it's not such an Automator kinda thingy, and I thought it'd be a good way of getting into making my own little apps! Thanks for the advice :)

Soulstorm
Aug 14, 2006, 03:22 PM
I'm not trying to discourage you, but programming is much more difficult than you think. But when you have learnt the basics, programming in general can be very rewarding.

First of all, you will have to decide what programs you want to make, and for what platform. Forget GUI programs at the moment, since you firstly have to know the basics for a language, then use that language with the Application Programming Environments distributed with each system to create User Interfaces.

C is a good language to start from, and it's cross-platform too. It is widely supported by every modern operating system. C++ is the Object-Oriented evolution of C, but it is 2 times harder to master, although the basics of it can be easily learnt. It is widely supported on modern operating systems, and is the programming language of choice of most professional programs. Objective-C is required to program in Cocoa on OS X, but it is not widely supported on other platforms.

My advice: Start with C++ or Objective C. They are both Object-Oriented, which I think is the most important thing in modern programming languages. Then, you can move to Cocoa with Objective C, or Carbon, with C++.

But forget graphic user interfaces for now. If you are a complete newbie, you will have to do a lot of work to create the applications you want (especially if you use C++). But the most important thing is that programming is the most rewarding thing in the world. Once you get the basics, you will feel that nothing can stop you, and everything will be easier from then on...

Also, do not be discouraged by the number of all the languages that are out there. Learning a language doesn't prevent you to from learning somehing else, too! In programming you learn ways to solve many problems in general, and not just simple commands. The way in which you solve the problem is a matter of good thinking, and that can be applied into every aspect of programming life (and real life, too!).

Good luck!

bousozoku
Aug 14, 2006, 03:46 PM
...
I just want to make a program that interacts with the iTunes library, and helps users add MP3s to the library a little easier (I just got annoyed after adding a new album and having to number all the tracks one by one...)

So do I need to learn C++?

Learn AppleScript. It's easier and can interact directly with iTunes. Anything else would be too complicated for a beginner trying to do complex interactions and you'd probably give up.

Skeeball236
Aug 14, 2006, 04:12 PM
del

MacRumoron
Aug 14, 2006, 06:58 PM
I just want to make a program that interacts with the iTunes library, and helps users add MP3s to the library a little easier (I just got annoyed after adding a new album and having to number all the tracks one by one...)

have you tried "Get Track Names" under the "Advanced" menu item?

whenever i import a CD with iTunes, i just go to Advanced -> Get Track Names and it automatically adds the titles, album, artist, etc..

edit: nvm didn't read your post carefully, you want to number your tracks

VanMac
Aug 14, 2006, 08:28 PM
What do you think of Python or Ruby?

Oh, and *??? ??? ???????, ????? ???????* :)

edit: why won't greek characters show up?
Java is a pretty good language to learn. Can run on most any OS. Also very prevelant in the work force, so good skill to have.

http://java.sun.com

Good tutorials and what not on sun's site. You dont need a complex IDE (Integrated Development Environment) to get going. Just a text editor, and download the JDK (Java Development Kit).

iMeowbot
Aug 14, 2006, 08:37 PM
What do you think of Python
It's a lovely language, but it's painful to do Mac GUI programs with it. It works very nicely as an embedded interpreter though, so you can have it both ways.
or Ruby?
Python for people who don't want to admit they like Python :D

Oh, and *??? ??? ???????, ????? ???????* :)

edit: why won't greek characters show up?
Check out this thread (http://forums.macrumors.com/showthread.php?t=81954) for an awkward but functional way to make it work.

Skeeball236
Aug 14, 2006, 08:47 PM
del

hob
Aug 14, 2006, 10:20 PM
Learn AppleScript. It's easier and can interact directly with iTunes. Anything else would be too complicated for a beginner trying to do complex interactions and you'd probably give up.
Applescript seems really stupid to me.

I get why it exists, it's to make programming easier for people who aren't programmers, like me. But in truth, it's not near-english, it's in english, but that's about as close as it gets.

Near english would be: "Make a big box that the user can drag some tracks into, and arrange how they would like. Then make a big button with the words "import into iTunes" on it. When this button is pressed, transfer all of the files from the box, into iTunes in the order specified - making sure to add track numbers to each track in order".

Which is basically the thing I want to make.

But at the same time, I do want to break into programming, so I guess obj-c would be a good place to start :)

EDIT: I forgot the point I was trying to make! Which was that you write an AppleScript in English, you have to learn a whole new way of writing english. Which defeats the point. I'd rather go straight into Obj-C

(Oh, and iMeowbot, plinden! I believe we have crossed paths before - but I didn't know this was where you hung out! )

ham_man
Aug 14, 2006, 10:25 PM
Applescript seems really stupid to me.

I get why it exists, it's to make programming easier for people who aren't programmers, like me. But in truth, it's not near-english, it's in english, but that's about as close as it gets.

Near english would be: "Make a big box that the user can drag some tracks into, and arrange how they would like. Then make a big button with the words "import into iTunes" on it. When this button is pressed, transfer all of the files from the box, into iTunes in the order specified - making sure to add track numbers to each track in order".

Which is basically the thing I want to make.

But at the same time, I do want to break into programming, so I guess obj-c would be a good place to start :)

EDIT: I forgot the point I was trying to make! Which was that you write an AppleScript in English, you have to learn a whole new way of writing english. Which defeats the point. I'd rather go straight into Obj-C

(Oh, and iMeowbot, plinden! I believe we have crossed paths before - but I didn't know this was where you hung out! )
The English language is a pretty complicated thing...compromises are needed...

viccles
Aug 14, 2006, 10:28 PM
Gee I didn't realise there were so many Apple languages to learn. I thought as a hobby over the holidays I could try and learn a programming language for macs. I did a LITTLE visual basic when I was younger but nothing major. I wouldnt mind learning javascript or C++ I'm going to ask a REALLY stupid noobie question *waits for people to pounce* but what compiler do you use to write those languages? I literally know nothing about programming but I would like to do some :)

bousozoku
Aug 14, 2006, 10:54 PM
Applescript seems really stupid to me.

I get why it exists, it's to make programming easier for people who aren't programmers, like me. But in truth, it's not near-english, it's in english, but that's about as close as it gets.

Near english would be: "Make a big box that the user can drag some tracks into, and arrange how they would like. Then make a big button with the words "import into iTunes" on it. When this button is pressed, transfer all of the files from the box, into iTunes in the order specified - making sure to add track numbers to each track in order".

Which is basically the thing I want to make.

But at the same time, I do want to break into programming, so I guess obj-c would be a good place to start :)

EDIT: I forgot the point I was trying to make! Which was that you write an AppleScript in English, you have to learn a whole new way of writing english. Which defeats the point. I'd rather go straight into Obj-C

(Oh, and iMeowbot, plinden! I believe we have crossed paths before - but I didn't know this was where you hung out! )

Natural language programming has never been successful. Compromises must be made to facilitate effectiveness. AppleScript is pretty useful, regardless of level.

When your tiny 20 minute AppleScript application requires months in Objective-C or some other language, you start to realise that simple tasks are better out of the way. :)

Sayer
Aug 14, 2006, 10:59 PM
Uhm, why on earth would you want to number the tracks themselves? You can create a playlist in iTunes in any order you want without changing the file's on-disk name at all.

You should think of iTunes as a "Finder" for music files (and videos, and podcasts, and...). What the file is named on disk is almost immaterial as iTunes *knows* what and where all the files are.

Are you trying to kludge some DJ-ing software into existence? Or what?

I often read about people wanting to manage the *files* iTunes uses/creates for some reason instead of managing the *playlists* and smart playlists, which makes the most sense (to me, at least, and I have been using computers a long time). Files on disk are just an implementation detail for music these days.

*shrug*

iMeowbot
Aug 14, 2006, 11:08 PM
Uhm, why on earth would you want to number the tracks themselves? You can create a playlist in iTunes in any order you want without changing the file's on-disk name at all.
There is a track number field in the iTunes database. If you rip music from vinyl or tape, or from a CD that isn't in CDDB, it won't automatically be filled in. So, if you want to play that album in its original order, you have to fill in the numbers.

A little program to help with that task makes oodles of sense.

slooksterPSV
Aug 15, 2006, 01:01 AM
1 - Programming is awesome, you can control any aspect you'd like of your application as long as you know how to.
2 - A good book and a great place to start is to buy the book Programming in Objective-C by Steve Kochan
3 - After learning Objective-C play around with it, make some test apps, learn the flow and use of Objective-C
4 - After that get the book Cocoa Programming for Mac OS X by Aaron Hillegass to learn how to make GUI apps.

Any time - Ask questions here on the forums, send myself PM's, cotact me on AIM or MSN and I can give you advice or tips - or I can refer you to someone else and have them help you out.

5 - Read the Apple Documentation for the intricate parts of your apps, such as how to interact with iTunes, QuickTime, etc.

To get you started here's a simple app that just display's "Hello World!" - it's file type is .m which is an Objective-C file, but its C Programming - don't worry when you read the books you'll find out the difference.


#import <stdio.h>

int main()
{
printf("Hello World!\n");
return 0;
}


When you execute this program this is what happens:

computer-name:~ username$ ./a.out
Hello World!
computer-name:~ username$


EDIT: In response to the title of the post, I personally define programming as the way a user uses code that tells the machine to execute specific operations depending on an algorithm. -- its somewhere on that line - you use a language to communicate with the machine components - e.g. video output, print output, keyboard input. and you can execute specific items depending on the algorithm that is defined in order to achieve a result.

Soulstorm
Aug 15, 2006, 02:11 AM
What do you think of Python or Ruby?

Oh, and *??? ??? ???????, ????? ???????* :)

edit: why won't greek characters show up?
I have never used Python or Ruby, but I keep hearing that Ruby has great potential, and that it definitely has a bright future. I heard that from the creator of The D programming Language during an interview.

Oh, and as for the greek characters, I think this site, has not support for greek characters.

**Giati, ti eixes grapsei kai emfanistike me erwtimatika?**

bousozoku
Aug 15, 2006, 02:36 AM
I have never used Python or Ruby, but I keep hearing that Ruby has great potential, and that it definitely has a bright future. I heard that from the creator of The D programming Language during an interview.

Oh, and as for the greek characters, I think this site, has not support for greek characters.

**Giati, ti eixes grapsei kai emfanistike me erwtimatika?**

Γιατι, τι ειχεσ γραπσει και εμφανιστικε με ερςτιματικα?

Does that work for you?

Soulstorm
Aug 15, 2006, 03:10 AM
WTF is going on here?

Oh, here it is!

Skeeball236, γιατί, τι είχες γράψει και εμφανίστηκε με ερωτηματικά??

Skeeball236
Aug 15, 2006, 03:57 AM
del

notjustjay
Aug 15, 2006, 08:47 AM
It's all Greek to me...

mduser63
Aug 15, 2006, 08:47 AM
There is a track number field in the iTunes database. If you rip music from vinyl or tape, or from a CD that isn't in CDDB, it won't automatically be filled in. So, if you want to play that album in its original order, you have to fill in the numbers.

A little program to help with that task makes oodles of sense.

Here you go:

tell application "iTunes"
if selection is not {} then
copy (track number of selection) to theTrackCount
copy selection to theTracks
else
return
end if
end tell

copy theTrackCount's length to theTrackCount

repeat with i from 1 to theTrackCount
tell application "iTunes"
copy (a reference to item i of theTracks) to theTrack
copy theTrackCount to track count of theTrack
copy i to track number of theTrack
end tell
end repeat

hob
Aug 15, 2006, 03:15 PM
Here you go:

tell application "iTunes"
if selection is not {} then
copy (track number of selection) to theTrackCount
copy selection to theTracks
else
return
end if
end tell

copy theTrackCount's length to theTrackCount

repeat with i from 1 to theTrackCount
tell application "iTunes"
copy (a reference to item i of theTracks) to theTrack
copy theTrackCount to track count of theTrack
copy i to track number of theTrack
end tell
end repeat
Gee, thanks for spoiling months of intense research and development :p

But seriously, thank you! That's great, I can start looking at it and poking it around and stuff :)

Is there a way of integrating Applescript into a GUI?

bousozoku
Aug 15, 2006, 05:54 PM
Gee, thanks for spoiling months of intense research and development :p

But seriously, thank you! That's great, I can start looking at it and poking it around and stuff :)

Is there a way of integrating Applescript into a GUI?

Yes, there is. Enjoy your 10 minutes of research. :)

slooksterPSV
Aug 16, 2006, 12:17 AM
Yes, there is. Enjoy your 10 minutes of research. :)
Need a hint? XCode.

bousozoku
Aug 16, 2006, 01:21 AM
Need a hint? XCode.

That works, too.

slooksterPSV
Aug 16, 2006, 11:23 AM
That works, too.
For a gui for AppleScript? What other way is there... AppleScript studio?

bousozoku
Aug 16, 2006, 11:26 AM
For a gui for AppleScript? What other way is there... AppleScript studio?

Script Editor is how I've always done it.