PDA

View Full Version : First programming language (yet another thread)




Keytachi
Sep 3, 2008, 06:39 AM
Hi everyone! Next year i'm going to college, and it's about time i learn some programming languages (i want to join the informatics and computers engineering course).
My goal is to be able to create applications for mac. I have already done some tiny stuff in AppleScript, but it doesn't serve me that well.

I read somewhere that Objective-C isn't that simple, and that i should learn some language thats more simple before moving on to Obj-C.
Which languages should i learn before heading for Obj-C? Or should i start right away with Obj-C? Any idea is welcome!

Thank you, Keytachi



richard.mac
Sep 3, 2008, 06:43 AM
learn C. its a cousin of Objective C and C++ and is a very old and fast programming language. its pretty hard! well for me! if you can get your hear arround that them im sure you be ready to learn Objective C.

Cromulent
Sep 3, 2008, 06:59 AM
Most Universities start with a language like Scheme or Java. You may want to bear that in mind. Can you link to your modules so we know what to recommend?

If you are purely interested in the Mac I'd go for C first then Objective-C. Learning C is also learning Objective-C as it is a proper subset so don't think you are wasting time.

mobilehaathi
Sep 3, 2008, 07:01 AM
C/C++

You might even start with it at University.

Keytachi
Sep 3, 2008, 07:12 AM
Thanks for the replies. Here is the link to the classes i'll have: link (https://fenix.ist.utl.pt/publico/degreeSite/showDegreeCurricularPlanBolonha.faces?degreeID=146&degreeCurricularPlanID=431&executionPeriodOID=88&organizeBy=groups&showRules=false&hideCourses=false&contentContextPath_PATH=/cursos/leic-a/plano-curricular&_request_checksum_=d9036ae4dc51173a31faf9db77c9fae00eb02aee).
I haven't read all the info of the classes, so i don't know if i will learn a specific language somewhere along the line.

I need to focus on my studies this year, so i'll probably buy a book on learning C (instead of looking for extracurricular classes).

Cromulent
Sep 3, 2008, 07:22 AM
Ah, it's in Spanish. Sorry my language skills suck :).

Keytachi
Sep 3, 2008, 07:25 AM
Actually its portuguese. And there is a button to the top right corner with an UK flag :)

mobilehaathi
Sep 3, 2008, 07:25 AM
Well, my Portuguese is pretty lousy, but from what I can tell Fundamentos da Programação might have you programming C++. Memory management, pointers, object oriented programming, and inheritance I think are mentioned, and I can't imagine any other language to use other than C++ for that stuff.

Cromulent
Sep 3, 2008, 07:29 AM
Yep definitely Java you want to be looking at.

Edit : and it looks like the AI course uses LISP as well.

Looks like a very good course by the way :).

Keytachi
Sep 3, 2008, 07:30 AM
Yep definitely Java you want to be looking at.

So, start with java, move to C and then head to Obj-C?

mobilehaathi
Sep 3, 2008, 07:36 AM
Oh, I guess it could be Java...

(Now I don't know Java so smack me if I'm wrong.)

If I recall, Java does all the garbage collection for you...seems silly to learn about memory management but not implement it yourself?

Oh well, you'll learn a lot either way. You should be able to pick up C/C++ and later Obj-C once you know all those concepts.

Edit: Oh and programming in LISP will blow your mind...its such a cool language.

edenwaith
Sep 3, 2008, 08:17 AM
So, start with java, move to C and then head to Obj-C?

Java wouldn't be a bad decision, either, since its syntax is very similar to C/C++ (well, at least when compared to other languages, such as BASIC or Ada).

If you are looking at learning a "proper" programming language, then I echo what others have mentioned by learning C and C++, since you can make use of those skills when moving over to Objective-C.

edenwaith
Sep 3, 2008, 08:19 AM
Yep definitely Java you want to be looking at.

Edit : and it looks like the AI course uses LISP as well.



Ah, good old LISP! I wore out the Shift, 9, and 0 keys on my keyboard from typing all of those parentheses!

Does anyone know if there is a LISP interpreter available for Mac OS 10.5 available? The last time I programmed in LISP, I used Mac OS 10.1, but the interpreter I had didn't work under Mac OS 10.2 for some reason...

Cromulent
Sep 3, 2008, 08:24 AM
Ah, good old LISP! I wore out the Shift, 9, and 0 keys on my keyboard from typing all of those parentheses!

Does anyone know if there is a LISP interpreter available for Mac OS 10.5 available? The last time I programmed in LISP, I used Mac OS 10.1, but the interpreter I had didn't work under Mac OS 10.2 for some reason...

Ready Lisp (http://www.newartisans.com/software/readylisp.html).

Keytachi
Sep 3, 2008, 08:26 AM
I'll take on Java first, and then move on to C (and later to Obj-C). I hope it will give me the foundations i need :P

Also... this might be a very stupid question... but where is the Java Development Kit?!? Spotlight doesn't find anything!

Cromulent
Sep 3, 2008, 08:29 AM
I'll take on Java first, and then move on to C (and later to Obj-C). I hope it will give me the foundations i need :P

Also... this might be a very stupid question... but where is the Java Development Kit?!? Spotlight doesn't find anything!

Have you installed Xcode?

Keytachi
Sep 3, 2008, 08:31 AM
Yes, i have the developer tools installed

EDIT:
I have found the Java class option in XCode.
I'm reading the tutorials in the Sun website, but it doesn't have any Mac OS specific tutorial (only with the NetBeans IDE), and i'd prefer to use XCode.
Any tips on what to do/follow?

Cromulent
Sep 3, 2008, 08:42 AM
Use the Java Tool template, type your code in and click build and go pretty much. You'd probably be better off using the command line though.

rev316
Sep 3, 2008, 08:45 AM
Just start with Obj-C. Advise I've received and now give to inspired Macintosh programmers.

lee1210
Sep 3, 2008, 08:47 AM
Yes, i have the developer tools installed

EDIT:
I have found the Java class option in XCode.
I'm reading the tutorials in the Sun website, but it doesn't have any Mac OS specific tutorial (only with the NetBeans IDE), and i'd prefer to use XCode.
Any tips on what to do/follow?

Don't use XCode right now.

Once you're finding yourself burdened by having to build quite a few classes at one time for a particular project, or you're really having trouble with what you need to import for something, etc. that's when you need an IDE. Smultron seems to be a popular editor, though I prefer vi at the commandline over any other editor. Others tend to be quick to disagree on vi, so use whatever you're comfortable with to edit the code. Then use javac from the commandline to compile and java to run the generated classes.

Java will help you catch some beginner errors like array overflows that in C will behave in unexpected ways. Do make sure you get the basics of arrays down first, before moving to the more dynamic data structures like lists, sets, etc. The other things are great, but knowing how to properly manipulate an array is crucial.

There are a few others around here that are just getting into Java as well, so we're in a pretty good position to assist you as you run into problems.

This:
http://java.sun.com/j2se/1.5.0/docs/

and more specifically, this:
http://java.sun.com/j2se/1.5.0/docs/api/index.html

should become your best friend. Being able to navigate and parse the API documents is as important a skill as being able to pick up syntax and apply, etc.

Good luck!

-Lee

Keytachi
Sep 3, 2008, 08:48 AM
Use the Java Tool template, type your code in and click build and go pretty much. You'd probably be better off using the command line though.

Ah, yes. I'll use the command line. It has been working with the windows commands (yay! i made an Hello World app!) so i'll keep using that.

Thanks a lot for all the help!

mobilehaathi
Sep 3, 2008, 09:55 AM
Ah, yes. I'll use the command line. It has been working with the windows commands (yay! i made an Hello World app!) so i'll keep using that.

Thanks a lot for all the help!

Ewwww, Windows command line!:D

I'd go with Terminal, but don't necessarily listen to me. I wouldn't want to needlessly derail your learning!:)

fluidedge
Sep 3, 2008, 09:59 AM
can i recommend learning HTML.

hang on before you shoot me down.

HTML is a nice simple language that teaches good structure and makes you think about your code. I think it's a nice way to get into the mind set of learning another language.

Get one of those learn HTML in a month books and work through it cover to cover.

just a thought.

lee1210
Sep 3, 2008, 10:20 AM
can i recommend learning HTML.

hang on before you shoot me down.

HTML is a nice simple language that teaches good structure and makes you think about your code. I think it's a nice way to get into the mind set of learning another language.

Get one of those learn HTML in a month books and work through it cover to cover.

just a thought.

I mean no disrespect, but HTML is not a programming language, it is a text markup language. There are some print/display languages that are turing-complete, like postscript, but HTML is not one of them.

You didn't mention javascript, so I'm not sure if that's what you meant. If so, javascript would be a fine place to start, but... it's a little "floppy" in terms of being loosely typed, which makes me uncomfortable for a beginner. That would be my primary complaint against starting with javascript.

-Lee

Cromulent
Sep 3, 2008, 10:24 AM
I'd steer clear of HTML. It does not teach you anything about programming really, it is mearly a document formatting tool (and arguably LaTeX would be better to learn if that was your goal).

fluidedge
Sep 3, 2008, 10:28 AM
furry muff

I was just thinking of a simple language to start with.

I remember being overwhelmed by C when i started learning it. Pointers, arrays etc. I hated it some much i've never used it since my exam in it.

Aranince
Sep 3, 2008, 10:30 AM
Python is actually a language and its very easy to learn and get a program running in the matter of seconds.

As for HTML: Its not a language, its a document format just like XML. It doesn't have variables, methods, functions, flow control, etc.

robbieduncan
Sep 3, 2008, 10:32 AM
I'd steer clear of HTML. It does not teach you anything about programming really, it is mearly a document formatting tool (and arguably LaTeX would be better to learn if that was your goal).

The only document formatting language I consider to be a programming language is PostScript. But I'm not sure learning that teaches much about general purpose programming!

mobilehaathi
Sep 3, 2008, 10:33 AM
furry muff

I was just thinking of a simple language to start with.

I remember being overwhelmed by C when i started learning it. Pointers, arrays etc. I hated it some much i've never used it since my exam in it.

I think their point is that since its not turing complete, it is not a programming language. You also don't learn basic concepts of flow and control with HTML, or basically anything that is actual programming...

Sorry you didn't like C too much! :(

Cromulent
Sep 3, 2008, 10:45 AM
The only document formatting language I consider to be a programming language is PostScript. But I'm not sure learning that teaches much about general purpose programming!

I didn't say it did :). I said "it doesn't teach you anything about programming really" and then went on to state that if your goal was to learn a document formatting tool then LaTeX would be a better bet than HTML.

Maybe I should have left the really off to sound more decisive on that statement.

fluidedge
Sep 3, 2008, 10:46 AM
Expressions like "Turing Complete" are what drove me away from programming software and into using software.

I once had a double lecture on the Godel Completeness theorem and the lecturer proved a bit of it. I knew then i was never destined to become a computer scientist/programmer. :(

I now do special effects :)

lee1210
Sep 3, 2008, 10:49 AM
furry muff

I was just thinking of a simple language to start with.

I remember being overwhelmed by C when i started learning it. Pointers, arrays etc. I hated it some much i've never used it since my exam in it.

My response seemed to get lost at the end of the first page, but I was at least trying to be civil about it. =) I think HTML is nice because you can very quickly make changes and see the results, which can be rewarding, but i've never taken what I've learned from HTML and applied it to programming elsewhere. It's certainly not a waste, especially in this day-in-age in which so much is being pushed to browser-based applications. HTML has become the front-end for a lot of very complex applications.

-Lee

P.S. I guess i started in with "turing completeness"... I guess we computer science folk can be a bit uppity and droll at times. I am a language nerd, and when I think "general purpose" I just say "Turing complete".

P.P.S. Since you brought up Gödel, it reminded me of this: http://xkcd.com/468/

fluidedge
Sep 3, 2008, 10:54 AM
My response seemed to get lost at the end of the first page, but I was at least trying to be civil about it. =) I think HTML is nice because you can very quickly make changes and see the results, which can be rewarding, but i've never taken what I've learned from HTML and applied it to programming elsewhere. It's certainly not a waste, especially in this day-in-age in which so much is being pushed to browser-based applications. HTML has become the front-end for a lot of very complex applications.

-Lee

P.S. I guess i started in with "turing completeness"... I guess we computer science folk can be a bit uppity and droll at times. I am a language nerd, and when I think "general purpose" I just say "Turing complete".

I know you were :)

I think you know what i meant - learning and using HTML you can quickly enter gobbledy gook and quickly get back something nice and pleasing. The number of times i've sat tearing my hair out at compiler errors :( - Another reason i don't go anywhere near terminal/textEdit/Xcode these days.

fluidedge
Sep 3, 2008, 10:56 AM
P.P.S. Since you brought up Gödel, it reminded me of this: http://xkcd.com/468/

I'm very pleased to say i don't understand that

2 years ago i might have :)

robbieduncan
Sep 3, 2008, 11:03 AM
I didn't say it did :). I said "it doesn't teach you anything about programming really" and then went on to state that if your goal was to learn a document formatting tool then LaTeX would be a better bet than HTML.

Maybe I should have left the really off to sound more decisive on that statement.

I wasn't trying to disagree with you, rather expand on the point. I qualified my statement as I didn't want anyone rushing off to learn PS and then coming back saying it didn't help!

I 100% agree that HTML teaches nothing about programming.

Bad Paper
Sep 3, 2008, 11:16 AM
Keytachi, I don't see why you need to learn any languages right now. Go run around outside in the sunshine. This is the last chance for you to do that sort of thing for years.

fluidedge
Sep 3, 2008, 11:18 AM
Keytachi, I don't see why you need to learn any languages right now. Go run around outside in the sunshine. This is the last chance for you to do that sort of thing for years.

Sun is bad for future programmers - you must build up an immunity to sunlight so you can work for weeks in your curtain drawn hovel

Cromulent
Sep 3, 2008, 11:29 AM
Sun is bad for future programmers - you must build up an immunity to sunlight so you can work for weeks in your curtain drawn hovel

I like my hovel :).

lee1210
Sep 3, 2008, 11:35 AM
Sun is bad for future programmers - you must build up an immunity to sunlight so you can work for weeks in your curtain drawn hovel

=) One of the 4 windows in my office has the shades 1/4 open! We get some sun!

Keytachi, I don't see why you need to learn any languages right now. Go run around outside in the sunshine. This is the last chance for you to do that sort of thing for years.

I don't know where you went to college/university, but I was outdoors constantly. And sometimes even running out there! In the 10 minutes I had between 2 classes I had to make it half a mile (.8km for our metric-using friends) after going down 3 stories of stairs, then make it up another 5 stories of stairs.

-Lee

lee1210
Sep 3, 2008, 11:39 AM
I like my hovel :).

Since we're so far OT by now anyway, you got started in these forums the same way the OP is. When does your first term at university start? With our help do you feel you've gotten yourself far enough ahead to embarrass your peers?

-Lee

Cromulent
Sep 3, 2008, 12:11 PM
Since we're so far OT by now anyway, you got started in these forums the same way the OP is. When does your first term at university start? With our help do you feel you've gotten yourself far enough ahead to embarrass your peers?

-Lee

Yep, very true.

I think I've come far enough along to do some damage. Although now I just know exactly what is I don't know, rather than what it is I do know :). I feel like I know less now than I did when I started :D.

Still I can work out how to put a program together, I can follow the flow of programs and have spent some time following open source software mailing lists (OpenBSD at the moment) and while there are things I don't understand, at least I know where to look for information which is the number one lesson I have learnt. Learning to find and use information is essential.

I still manage to make a tit out of myself with spectacularly simple mistakes though :p.

As for the course I had to delay for a year for financial reasons :(.

mobilehaathi
Sep 3, 2008, 12:16 PM
I still manage to make a tit out of myself with spectacularly simple mistakes though :p.


Hey I once spent 4 hours trying to debug code when it turned out I forgot to put semi-colons after two of my class declarations.....

Not that g++ gave me very useful error messages...telling me there was a syntax error in iostream!:eek:

Cromulent
Sep 3, 2008, 01:17 PM
Or the infamous = instead of == :). That's always a fun one.

lee1210
Sep 3, 2008, 01:27 PM
Or the infamous = instead of == :). That's always a fun one.

That one is a killer. Since = evaluates to the right-hand operand, and C treats any non-zero as true in conditionals, it can be pretty hard to track. One nice thing about Java (ha! back on topic!) and other languages that have a real boolean type (and force its use) is that you'll get a compiler error if you make that sort of mistake. That's to say, == evaluates to a boolean, and = evaluates to the type of the right-hand operand. I guess you could still make the mistake if you were testing a boolean value, but normally you'd just say:
boolean enterIf=true;
if(enterIf) {
System.out.println("Entered 'then' section");
} else {
System.out.println("Entered 'else' section");
}

rather than
if(enterIf == true)
which might be mistaken for
if(enterIf = true)

which would always evaluate to true, which would be unfortunate. I hadn't actually thought about this until today, so it's something to watch for. The point is that it's very easy to mess this up in C because anything you can use the assignment statement with can be evaluated in an if, even if some implicit casts are required.

-Lee

Cromulent
Sep 3, 2008, 01:47 PM
Do you guys use the method like this:

if(NULL == someVar)

or this:

if(someVar == NULL)

?

The first gives a decent compiler error but it is not as easy to read if you ask me. Maybe it is just getting into the habit of using it. I guess I should try.

lee1210
Sep 3, 2008, 02:11 PM
Do you guys use the method like this:

if(NULL == someVar)

or this:

if(someVar == NULL)

?

The first gives a decent compiler error but it is not as easy to read if you ask me. Maybe it is just getting into the habit of using it. I guess I should try.

I'd like to say that if I have a modifiable lvalue and a constant that I try to keep the lvalue on the right hand side of the == just in case, but in practice i probably vary. I'm mostly using Fortran and Java these days, and Fortran requires a scalar logical for conditions and Java requires a boolean, so it's not as serious of a problem for me anymore.

I think that most programming texts and teachers try to make examples "readable" and it seems more natural to say: "if X is equal to 10 then add 7 to Y" than "if 10 is equal to X then add 7 to Y". I think it's just the way we parse language... if 10 is equal just doesn't make sense. It's always equal to 10! Why would you even ask? I think we just like having a variable first.

-Lee

Berlepsch
Sep 3, 2008, 02:27 PM
Or the infamous = instead of == :). That's always a fun one.

For that reason alone, I use the -Wall switch as much as possible.

In university, I once spent hours to figure out why my program didn't work. Turned out, I defined a loop for(i = 0; i <... , but inside the loop, I used n as index variable :rolleyes:

yeroen
Sep 3, 2008, 07:45 PM
Or the infamous = instead of == :). That's always a fun one.

I injected this very bug into some production C++ code at work very recently, as part of some complicated conditional clause. The ill effect only surfaced some of the time due to the short circuiting of the logical || operator within said conditional clause.

Indeed, spending the two hours or so to track it down (down some blind alleys too) was a hoot.

lee1210
Sep 3, 2008, 07:52 PM
I injected this very bug into some production C++ code at work very recently, as part of some complicated conditional clause. The ill effect only surfaced some of the time due to the short circuiting of the logical || operator within said conditional clause.

Indeed, spending the two hours or so to track it down (down some blind alleys too) was a hoot.

But did you find and fix any other bugs in the process?

-Lee

yeroen
Sep 3, 2008, 09:57 PM
But did you find and fix any other bugs in the process?

-Lee

oddly enough, yes

lee1210
Sep 3, 2008, 10:05 PM
oddly enough, yes

That's what counts. What would it have taken for you to find those other, perhaps more devious, bugs if you hadn't made a silly mistake?

I am reasonably confident that there is a memory leak in one of our background processes, and i knew debugging it in it's current form (~1300 lines of Fortran 77, ~20 years old) was going to be damn near impossible. I'm sure I haven't gotten rid of all of the problems, but it made me bite the bullet and refactor the accursed thing down to about 800 nicely indented lines using Fortran 95 features like internal functions/subroutines, using non-dotted operators (== instead of .eq.), etc. When it starts acting up again, I won't mind looking at it nearly as much, and I won't feel as bad if I need to have someone else look at it.

-Lee

Bad Paper
Sep 5, 2008, 08:33 PM
That's what counts. What would it have taken for you to find those other, perhaps more devious, bugs if you hadn't made a silly mistake?

I am reasonably confident that there is a memory leak in one of our background processes, and i knew debugging it in it's current form (~1300 lines of Fortran 77, ~20 years old) was going to be damn near impossible. I'm sure I haven't gotten rid of all of the problems, but it made me bite the bullet and refactor the accursed thing down to about 800 nicely indented lines using Fortran 95 features like internal functions/subroutines, using non-dotted operators (== instead of .eq.), etc. When it starts acting up again, I won't mind looking at it nearly as much, and I won't feel as bad if I need to have someone else look at it.I'm forbidden to do this sort of thing at work. I play with 10-20 yr old SAS code, and nothing. is. ever. removed. Nothing. is. ever. fixed. unless. specifically. asked. for. It is maddening.

ChiltonWebb
Sep 6, 2008, 12:19 AM
SuperCard FTW.

http://www.SuperCard.us/

-Chilton