Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mduser63

macrumors 68040
Nov 9, 2004
3,042
31
Salt Lake City, UT
Use XCode. Don't waste time with VIM or any other editors some "hardcore programmer" will guide you to. You'll know when you need to learn such a thing, but not when you are starting.

I agree completely. VI/VIM, and to a lesser extent emacs, are some of the best examples of awful computer/human interaction design out there. I realize that those who are used to them are fast with them and find them powerful, but I can honestly say that if someone had forced me to use either one when I was just starting programming, I likely would haven given up after less than a day because they're so frustratingly obtuse to a beginner. Not only that, but they're hardly necessary. There are very good GUI based editors on all the platforms, and they have enough in common that switching between them is no big deal. I recommend TextMate on the Mac. It's not free, but it's very good and while it's incredibly powerful, it is also dead simple to use just for basic editing. If you want/need free, TextWrangler is also a good choice.

If no one taught you how to use VI and just sat you down in front of it, you'd probably guess that your keyboard was broken because its behavior is so obscure and unexpected compared to every other application the average person is used to.

(This is coming from someone who writes code all day both for my day job as an EE and on my own as a shareware developer. I'm fully capable of using both VI and emacs and have used them fairly extensively on UNIX workstations. Frankly I think they're horrible.)
 

yeroen

macrumors 6502a
Mar 8, 2007
944
2
Cambridge, MA
I agree completely. VI/VIM, and to a lesser extent emacs, are some of the best examples of awful computer/human interaction design out there. I realize that those who are used to them are fast with them and find them powerful, but I can honestly say that if someone had forced me to use either one when I was just starting programming, I likely would haven given up after less than a day because they're so frustratingly obtuse to a beginner. Not only that, but they're hardly necessary. There are very good GUI based editors on all the platforms, and they have enough in common that switching between them is no big deal. I recommend TextMate on the Mac. It's not free, but it's very good and while it's incredibly powerful, it is also dead simple to use just for basic editing. If you want/need free, TextWrangler is also a good choice.

If no one taught you how to use VI and just sat you down in front of it, you'd probably guess that your keyboard was broken because its behavior is so obscure and unexpected compared to every other application the average person is used to.

(This is coming from someone who writes code all day both for my day job as an EE and on my own as a shareware developer. I'm fully capable of using both VI and emacs and have used them fairly extensively on UNIX workstations. Frankly I think they're horrible.)

I love that vi enables me to edit w/o ever leaving the terminal (less so emacs, which I never quite warmed up to). It also comes in handy when a GUI isn't an option, say the X server on your linux box is hosed due to a corrupted config file. When I first learned vi as part of a fortran programming course >15 years ago, I was repulsed. With some practice it became second nature and soon I was editing faster and more efficiently than I ever was, or have since, been able to with a GUI editor.

That being said, for a newbie starting out, learning vi/emacs should be something that they learn eventually as part of the culture, but it's no longer strictly necessary. TextMate is really nice, but being priced in euros makes it a very expensive (for a text editor) option at $60.
 

noelister

macrumors 6502
Jan 15, 2005
275
0
I'm going to have to disagree with starting with Xcode for your first program. It's like using a high-powered laser cannon to open a can. Someday when you need to open a 20-story can, you might start considering the laser, but for your first program I would stick to a can opener.

A vi(m) cheatsheet can be be found here:
http://www2.cs.uidaho.edu/~rinker/ed03.pdf

To run vim you'll need to open terminal in OS X. from there, you can start with:
vi helloworld.c

This will open vi with a new document called helloworld.c. Open a second terminal window with ctrl+n.

In the vim window, enter (i)nsert mode with the i key. Then type:
Code:
#include <stdio.h>
int main(int argc,char *argv[]) {
  printf("Hello World!\n");
}

Once you've entered this text, press esc to exit insert mode. Then type :w<enter>. This will (w)rite the changes you've made.

In your second terminal window, enter:
gcc -o helloworld helloworld.c
./helloworld

The commands in vim will be confusing at first. However, knowing how to use this editor, if you will ever work on another unix-like system, will be invaluable. For starters what's in this post, plus :q to quit are all you'll need. You can then move on to deleting characters, words, etc. Eventually working up to replacement, undo and redo, etc.

Hello,

how do I run this little guy from the command line... I can navigate to the file with finder and run the file by double clicking on it but I cannot seem to run it from the command line.

Thanks
 

Cephus

macrumors newbie
Jun 22, 2008
4
0
Salt Lake City, UT
May I ask why you want to learn C instead of C++? C++ is better than C in every way, so learning C is backwards seeming.

As someone else commented in this thread, I'm learning C to program PIC microcontrollers. I'm also dabbling in assembly language which is also used with the microcontrollers.
 

Cephus

macrumors newbie
Jun 22, 2008
4
0
Salt Lake City, UT
I'm going to have to disagree with starting with Xcode for your first program. It's like using a high-powered laser cannon to open a can. Someday when you need to open a 20-story can, you might start considering the laser, but for your first program I would stick to a can opener.

A vi(m) cheatsheet can be be found here:
http://www2.cs.uidaho.edu/~rinker/ed03.pdf

To run vim you'll need to open terminal in OS X. from there, you can start with:
vi helloworld.c

This will open vi with a new document called helloworld.c. Open a second terminal window with ctrl+n.

In the vim window, enter (i)nsert mode with the i key. Then type:
Code:
#include <stdio.h>
int main(int argc,char *argv[]) {
  printf("Hello World!\n");
}

Once you've entered this text, press esc to exit insert mode. Then type :w<enter>. This will (w)rite the changes you've made.

In your second terminal window, enter:
gcc -o helloworld helloworld.c
./helloworld

The commands in vim will be confusing at first. However, knowing how to use this editor, if you will ever work on another unix-like system, will be invaluable. For starters what's in this post, plus :q to quit are all you'll need. You can then move on to deleting characters, words, etc. Eventually working up to replacement, undo and redo, etc.

Wow! It works! My Macbook responded "Hello World" at the ./helloworld command!

There is so very little documention online that give tutorials that work on a Mac. I tend to forget that OS-X is Unix based and includes many of the tools so common on Unix/Linux.

I did load the XCODE off my Leopard CD since I didn't otherwise know how to get just the command line stuff. I do think I'll use a different editor other than VI - perhaps Smultron (Mac freeware). Never liked the quirkiness of VI.
 

neonblue2

macrumors 6502a
Aug 25, 2006
523
0
Port Pirie, South Australia
I agree completely. VI/VIM, and to a lesser extent emacs, are some of the best examples of awful computer/human interaction design out there. I realize that those who are used to them are fast with them and find them powerful, but I can honestly say that if someone had forced me to use either one when I was just starting programming, I likely would haven given up after less than a day because they're so frustratingly obtuse to a beginner. Not only that, but they're hardly necessary. There are very good GUI based editors on all the platforms, and they have enough in common that switching between them is no big deal. I recommend TextMate on the Mac. It's not free, but it's very good and while it's incredibly powerful, it is also dead simple to use just for basic editing. If you want/need free, TextWrangler is also a good choice.

If no one taught you how to use VI and just sat you down in front of it, you'd probably guess that your keyboard was broken because its behavior is so obscure and unexpected compared to every other application the average person is used to.

(This is coming from someone who writes code all day both for my day job as an EE and on my own as a shareware developer. I'm fully capable of using both VI and emacs and have used them fairly extensively on UNIX workstations. Frankly I think they're horrible.)

Totally agree. Terminal-based text editors are as user friendly as some as the people here. The best way to learn something is to find a good way to learn. Chucking a new programmer into VI when they don't even know how it works is just plain wrong, like putting a learner driver onto a highway without any experience.
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
Totally agree. Terminal-based text editors are as user friendly as some as the people here. The best way to learn something is to find a good way to learn. Chucking a new programmer into VI when they don't even know how it works is just plain wrong, like putting a learner driver onto a highway without any experience.

It's exactly like that, except in one case you're likely to be killed or total the car, and in the other you'll have to spend a few days with a cheat sheet and then you'll be able to use a great text editor available on practically any *nix machine. They are practically identitcal! =)

As for the friendliness of people here, I've only seen rudeness in pretty rare circumstances. Generally people get comprehensive help with a bevy of subjects very quickly.

-Lee
 

Denarius

macrumors 6502a
Feb 5, 2008
690
0
Gironde, France
Some code (in a new thread) would probably help people assist you. If you are working with classes (if you aren't, it's pretty much just C), you'll probably be using a lot of pointers. I have done very little Obj-C programming, but essentially anything with an init method is going to give you a pointer. The possible exception would be when using what is essentially a struct. An example is NSRange. You don't have to call anything on it, you just set its fields. There are some methods, but you don't need to initialize it.

As for TextWrangler, if you will only program on the Mac, I'm sure it would fit the bill. TextWrangler is not cross platform, though. That's the only reason I will, stubbornly and annoyingly, continue to insist on vim.

-Lee

Way I look at it, if you've got the brains to write good programs, you've easily got the brains to get the hang of vi pretty quickly. TextWrangler is a nice bit of software though.

Damn, what was that command for search backwards again? Oh and now I've gone and broken my script again. D'oh! ;)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.