programming environment ?

giovanni

macrumors regular
Original poster
Jul 1, 2002
214
0
manhattan
I want to get back into programming but this time I want to do that on the Mac. Inspite of being a mac user forever (since the old Apple IIe times) I have never programmed on a Mac, well except for the Apple IIe actually. I think the reason is that I never found out where/how to on a Mac.
The reason I finally decided to actually find something for the Mac is that for the first time I saw something available right in the shop: real basic (at the Apple Store).
Anyway, I only do programming for "fun" and for testing stuff I do for work, and my question is, what would you recommend in terms of languages/environment ? all I know exists is real basic, but of course there is plenty others. It has to be somewhat simple and the package should come with a decent manual so that someone like me can get going somewhat quickly.

May be real basic is a good start itself for the Mac ? what else is available... C++ or Java ? or would the latter two be too difficult ?
 

sparkleytone

macrumors 68020
Oct 28, 2001
2,307
0
Greensboro, NC
i would just recommend using project builder and interface builder. cocoa is OS X's language, which is basically objective-c with apples UI builder. these tools are free and are also of professional quality. no real point in buying programming software, especially if its just a hobby.
 

bousozoku

Moderator emeritus
Jun 25, 2002
13,973
3
Gone but not forgotten.
Programming has evolved a bit since the Apple IIe. Apple has finally come into the 1990s. :)

I would suggest getting the Aaron Hillegass book "Cocoa Programming for Mac OS X" and reading tutorials on the O'Reilly network Mac DevCenter at http://www.oreilly.net. Apple also has tutorials, within Adobe Acrobat files on the developer website, for both Carbon and Cocoa.

Project Builder/Interface Builder is the better environment for Objective-C, Java, C, and C++ but Metrowerks CodeWarrior has the better compilers.
 

Nipsy

macrumors 65816
Jan 19, 2002
1,009
0
Along with your chosen IDE, you should have BBEdit (the best Mac text editor).

It integrate well with everything from CodeWarrior, to the command line, and is really a better text editor than is built into IDEs.

I myself use CodeWarrior, Project Builder, BBEdit, and the command line tools, and can say that the Mac has become an awesome dev platform since the intoduction of OSX.

If you are just getting back into things, get BBEdit ($129) and Project Builder ($free [that's not a var]). Once you feel you're taxing project builder's capabilities, look into CodeWarrior, or some of the command line binaries.
 

beatle888

macrumors 68000
Feb 3, 2002
1,690
0
cant he use the free developer tools that
comes with every mac? is that project builder
interface builder?
 

Nipsy

macrumors 65816
Jan 19, 2002
1,009
0
Porject Builder and Interface Builder are part of the dev tools suite.
 

onemoof

macrumors member
Jul 23, 2002
75
0
Minneapolis, Minnesota, USA
I agree. I think Project Builder and Interface Builder are not going to be any harder to learn than RealBasic which also has a fairly steep learning curve. Tutorials are included with the Developer install. I suggest you start with Java if you're starting from scratch considering it does a lot of the difficult stuff for you such as memory management. Objective C is a lower level language that you probably don't need.

Project Builder also lets you create programs with standard text interfaces which anyone should have no problem programming.
 

ryme4reson

macrumors 6502
Mar 5, 2002
259
0
Cupertino CA
programming with C

I am taking a C class and I was having problems doing simple I/O in project builder. I know C++, but I dont know what i could be doing incorrect. Does any1 know of the proper type of project I should select to do simple ANSI C? Also, the exact code worked perfectly in Codewarrior, so my assumption is I am choosing the wrong type of project.
 

bousozoku

Moderator emeritus
Jun 25, 2002
13,973
3
Gone but not forgotten.
Re: programming with C

Originally posted by ryme4reson
I am taking a C class and I was having problems doing simple I/O in project builder. I know C++, but I dont know what i could be doing incorrect. Does any1 know of the proper type of project I should select to do simple ANSI C? Also, the exact code worked perfectly in Codewarrior, so my assumption is I am choosing the wrong type of project.
The tool projects will be what you want to do scanf/printf (C) or cin/cout (C++).

The problem could be the project, but I've found small issues with the standards support in GCC. Remember that it isn't a commercial compiler (collection), CodeWarrior's are.
 

ryme4reson

macrumors 6502
Mar 5, 2002
259
0
Cupertino CA
I was using tools

Here is the code, and the problem is when I use printf and scanf it does not prompt me. I enter 2 and 2 and it should display 4. What happens is it runs w/ a blank screen I enter 2 and 2 and -2(to quit then it shows the "please enter #" 2 times and then "Total is ..." with the correct answer. Maybe the code is wrong, but like I said codewarrior Edu edition works fine. This is compressed so I know the spacing may be hard to read. Thanks for any help.
/*
This program sums all of the positive integers entered and displays the result to the screen once a negative integer as been input.*/
#include <stdio.h>
int main(void)
{
int i = 0,
total = 0 ;
printf("Please enter an integer\n") ;
scanf("%d", &i) ;
while(i >=0){
total = total + i ;
printf("Enter another integer\n") ;
scanf("%d", &i) ; }
printf("The total is %d", total) ;
return 0 ;
}
 

mmcneil

macrumors regular
Sep 4, 2001
219
44
Indianapolis, IN
CodeWarrior vs PB & IB

I use both and for anyone trying to learn programming I would start with PB & IB plus a copy of O'Riellys "Building Cocoa Applications". PB & IB do a lot of things automatically for you which is nice. After you get the hang of programming and the bug really bites you - think about CW, but if you are only developing for OS X, PB & IB may be the best route even then. I'm developing for Windoze on a mac so CW is the only choice for me:rolleyes:

by the way - one of the cocoa apps in the book is a calculator - very cool:D
 

PCUser

macrumors regular
Mar 1, 2002
123
0
It's not GCC. I tested that program with GCC in Linux (x86) and GCC in Windows, and it runs correctly with the proper output. Hope that helps in your search for why it's not working...
 

Doctor Q

Administrator
Staff member
Sep 19, 2002
37,916
4,158
Los Angeles
Re: I was using tools

Originally posted by ryme4reson
Here is the code, and the problem is when I use printf and scanf it does not prompt me. I enter 2 and 2 and it should display 4. What happens is it runs w/ a blank screen I enter 2 and 2 and -2(to quit then it shows the "please enter #" 2 times and then "Total is ..." with the correct answer.
Files stdin (your input) and stdout (your output) and other files opened with fopen() are buffered. The buffer may not be flushed until it fills up or the file is closed. You can probably solve your problem by adding the line

fflush(stdout) ;

after the line

printf("Please enter an integer\n") ;

so the stdout buffer will be flushed (sent to your screen) before scanf() is reached.

I also suggest that you add a period and linefeed after your total display. The resulting program:

/*
This program sums all of the positive integers entered and displays the result to the screen once a negative integer as been input.*/
#include <stdio.h>
int main(void)
{
int i = 0,
total = 0 ;
printf("Please enter an integer\n") ;
fflush(stdout) ;
scanf("%d", &i) ;
while(i >=0){
total = total + i ;
printf("Enter another integer\n") ;
scanf("%d", &i) ; }
printf("The total is %d.\n", total) ;
return 0 ;
}
 

bousozoku

Moderator emeritus
Jun 25, 2002
13,973
3
Gone but not forgotten.
It's not your code, it's ProjectBuilder.

I created the project.
I copied your code into the main.c file.
I renamed the main.c file to ryme4reson.c.
I created the application.
I ran the application and nothing showed up. This is typical PB behaviour concerning command line programmes.

I went to the command line and created the programme. cc -o ryme4reson ryme4reson.c
I ran the programme with ./ryme4reson

It works fine. :)
 

ryme4reson

macrumors 6502
Mar 5, 2002
259
0
Cupertino CA
It's not your code, it's ProjectBuilder

Thanks, I am trying to work with it right now, and again its acting dumb. I wonder how I can contact (or if I need to) Apple to let them know this. I was under the impression I would have not problem with Java, C, C++ with PB. I took 1 year of C++ and had no problems with PB, now I have C and Java coming up and I am running in2 these probs. Its very discouraging. Thanks for your help Bous...
EDIT** I ran my current project via CL, and it worked. If I wanted to code in the CL how would I do it? Could I use vi? i guess I can use PB as an IDE, and compile via CL right? Thanks
 

cubist

macrumors 68020
Jul 4, 2002
2,075
0
Muncie, Indiana
Come on, don't use project builder for this.

For a simple stdin/stdout program, just open terminal and type
cc -o program program.c
./program

And you can use make too, like all good Unix programmers. You can edit with vi, who needs BBedit.

Personally, I don't like IDEs, they are too visually complicated and waste too much time. I want to build Aqua apps using Carbon and a makefile. And I intend to find out how, too. But don't let me bias you. I only wish to point out that for terminal-type programs, you can develop them in terminal with no overhead whatsoever.

:cool: Have fun!
 

ryme4reson

macrumors 6502
Mar 5, 2002
259
0
Cupertino CA
No Overhead

I cannot believe how much fast it is to compile my simple C apps via CL rather than PB. In the CL it is almost instantaneous, in PB atleast 5-7 seconds.
 

mmcneil

macrumors regular
Sep 4, 2001
219
44
Indianapolis, IN
Re: No Overhead

Originally posted by ryme4reson
I cannot believe how much fast it is to compile my simple C apps via CL rather than PB. In the CL it is almost instantaneous, in PB atleast 5-7 seconds.
Ain't Unix Grand:D

Once you learn makefiles they are very powerful - you can build makefiles that automatically find your code, do the right things with it, and build multiple versions all in one swell foop:D
 

bousozoku

Moderator emeritus
Jun 25, 2002
13,973
3
Gone but not forgotten.
Originally posted by scem0
Im not programming expert but can't you put

Int main()
{
blah
blah
blah
return 0;
}

w/o the void etc.
You may either define it to return an integer (int) or nothing (void). If you need the shell to see the errorcode you've set, you need to define it as int.
 

ryme4reson

macrumors 6502
Mar 5, 2002
259
0
Cupertino CA
What does Apple use?

I am here trying the simplest C apps, and in PB it sucks, so my question is: Does Apple us PB for its software development? come to think of it, I have a friend who was an intern @ Apple last summer, I will email 2night and get the answer and post later
 

madamimadam

macrumors 65816
Jan 3, 2002
1,281
0
I use PB all the time for Java work under WO and I think it is fantastic.... apart from the time it takes to compile.

I was going to say that I should not complain about stuff like that with an app that I did not pay for but, in a scene, I did pay for it because I had to purchase the WO kit.... although that was only an add on to PB.
 

Doctor Q

Administrator
Staff member
Sep 19, 2002
37,916
4,158
Los Angeles
I've used vi to write simple (and some not so simple) C programs under Unix for years. It works the same under Mac OS CLI, i.e., really fast. By the time someone else opens a project in Project Builder, I can type

vi myprogram.c
(type type type)
cc -o myprogram myprogram.c
./myprogram


Howevever, I am now teaching myself to use Project Builder because there are good reasons to use such products.

The disadvantage of an integrated development environment (IDE) like Project Builder is that it has lots of overhead, hence the necessarily slower speed to launch, find its resources, compile a trivial program, etc.

The advantage is all the tools it gives you: syntax checking, code coloring, templates, debugging, etc. etc. etc. With vi, you are completely on your own to keep track of all details and find your own mistakes.

It is overkill to use Project Builder to write HelloWorld.c, but it would be quite impractical to use vi to write MyIncrediblyComplicationHugeApplication.c.
 

cubist

macrumors 68020
Jul 4, 2002
2,075
0
Muncie, Indiana
Far larger programs have been written with vi and make...

... than with IDEs such as PB. I doubt that Mac OS X itself, for example, is done with PB/IB (altho perhaps Aqua is). Large programs with hundreds of source files require documented makefiles, perhaps many nested makefiles. Now that we have a real operating system on the Mac, we can bring some real discipline into the programming process. IDEs are for solo programmers writing small- to medium-size programs. They save time only in the short run. Maybe the short run is all that most programmers need. But that's no reason to pooh-pooh techniques that programmers have used for years before the Mac came on the scene, and continue to use, and will continue to use when the Mac is a fond memory. May that day be long in coming.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.