Page 1 of 1

C++ for first language?

Posted: Mon Mar 12, 2012 6:10 pm
by Vegerot
So I never did get to teaching myself C. But I signed up for the programming elective at my school for the last trimester. But the only programming class there is is teaching C++. So that'll be an interesting first language to learn.

Re: C++ for first language?

Posted: Wed Mar 14, 2012 1:32 pm
by Sparky
It's a fun one to learn in school; I learned C++ in high school also! Go for it, and take notes really well so you can make a smooth transition to Objective-C after that.

Re: C++ for first language?

Posted: Wed Mar 14, 2012 7:47 pm
by nil
I think C++ is a bad beginner's language, and that it is also not a good language, but that may not mean your course will be bad. Seeing that you're running on a trimester schedule and that this is high school, chances are you'll only learn a small portion of the language and instead primarily focus on basic imperative concepts like loops, variables, functions, and what not. If I were to guess, you may learn very little in C++ that differs from C and you will not learn important concepts in C that relate to C++ (and Objective-C) like pointers. If you've never programmed before, it may be worthwhile experience anyway teaching you the basic programming concepts (C++ is just a poor language choice).

Also, wrong forum, should go to Programmer's section.

Re: C++ for first language?

Posted: Fri Mar 16, 2012 11:35 am
by Vegerot
Oh god. This class is gonna suck. There are a bunch of people in the class who didn't even pick it, but they were put in because their other choices were full. We're using a teacher brought in from somewhere else, so nobody has any respect for him. The whole class, people were just talking, running around the room, girls were sitting on guys laps, someone was taking a nap, and everyone was acting like a fuckwad. Granted, the school didn't install the software the teacher wanted, so the whole class the application was just downloading, so nobody actually had to DO anything. But because of that, the teacher decided he would spend the whole class just telling us about programming and verbally telling us basic things, but of course nobody was listening. But I had Xcode, and thankfully the teacher was well-versed with Mac and Xcode too (I figured we were going to go into so little depth that the operating system wouldn't make a difference), so he started to show me some stuff, but he had to deal with all the other people being retards. So all he showed me is that if I change "Hello world" and press the "run" button, I can change the text.

So all I learned that first class was that that the "run" button activated your program, computers are idiots (a better word would be unintelligent), and that there's this thing called "X" and that "X"--like in algebra-- is a variable. But unlike in algebra, "X" doesn't have a fixed value, so you can change it to mean other things. I have no clue what X is though, and what the value would address.

Also, this class is just once a week...for one trimester...with people who have no will to learn anything. So given these things I'll pretty much learn nothing about the language.

and this is in the Programming section.

Re: C++ for first language?

Posted: Fri Mar 16, 2012 12:04 pm
by Sparky
That was similar to my high school experience in the class, although some were really into it while others decided to goof off and play games.

I'd say do what you can in the situation and let the instructor be disciplinarian if they so decide.

Also, get into a habit of never using capital letters in programming unless you have to do that; use comments instead.

x is a variable, meaning it can take any value. When you are solving a single algebraic equation, you assume that x has a single value. In programming, a variable can hold a single value also, but its value can change later if you make it change later. A number like 4 will remain that value indefinitely, but a variable "holds" a value like 4 or 3 or 2.93013 and so on, in the computer's memory. The memory can hold a different number later, so that's why the value of a variable can vary.

It's actually the same as algebra and math, where x can be called y or z or a or any letter or word, and that particular variable name remains the same as it is defined until it is changed later on in the program.

x = "Hello World" will mean that the string "Hello World" will replace every instance of the variable x when you use it. Typically, you would be more descriptive with your variable names, for example:

my_homework_assignment = "Answer questions 1-4 on page 223 in my math textbook. After that, work on my english essay for next week."

In this way, you don't have to type the same exact phrase over and over when you want to use it. You can do something simple like:

cout << my_homework_assignment;
and it will print the string value for you. cout and cin are two simple commands which are used to receive user input and print to the screen. Your starting programs will use the command-line interface. You would use the Mac OS windows and such with Objective-C programs.

Here are some old programs I wrote as high school homework assignments:
http://www.angelfire.com/nj/peanutbutte ... amming.htm

Re: C++ for first language?

Posted: Fri Mar 16, 2012 12:16 pm
by nil
Vegerot wrote:...But I had Xcode, and thankfully the teacher was well-versed with Mac and Xcode too (I figured we were going to go into so little depth that the operating system wouldn't make a difference)
Differences come from different compilers. Xcode nowadays either uses apple-gcc or clang. I've found that it's surprisingly easy to write incorrect code that won't pass in gcc but will in Microsoft's compiler (eg: omitting return statement at end of main()). Just shows C++ portability is a joke I suppose.
Vegerot wrote: and this is in the Programming section.
Only because someone moved it here.
Sparky wrote:Also, get into a habit of never using capital letters in programming unless you have to do that; use comments instead.
I don't quite get what this means, so I don't think it's good advice =P.
Sparky wrote:x is a variable, meaning it can take any value. When you are solving a single algebraic equation, you assume that x has a single value. In programming, a variable can hold a single value also, but its value can change later if you make it change later. A number like 4 will remain that value indefinitely, but a variable "holds" a value like 4 or 3 or 2.93013 and so on, in the computer's memory. The memory can hold a different number later, so that's why the value of a variable can vary.
Good explanation for imperative languages like C++, but for "in programming" is actually incorrect since functional languages abide more closely to mathematical definition that a variable does not vary.

Re: C++ for first language?

Posted: Sat Mar 17, 2012 1:25 pm
by Sparky
Make it a habit to only use lower-case letters and a generous measure of underscores in your variable names:

counter ≠ Counter
increment_brightness ≠ incrementbrightness

Separate words in your variables with underscores, and use lowercase letters in all your variables.

Re: C++ for first language?

Posted: Sat Mar 17, 2012 4:58 pm
by nil
Sparky wrote:Make it a habit to only use lower-case letters and a generous measure of underscores in your variable names:

counter ≠ Counter
increment_brightness ≠ incrementbrightness

Separate words in your variables with underscores, and use lowercase letters in all your variables.
That's just a stupid style preference. From my experience with various languages, local variable names and function/method names are either camel case like incrementBlueBrightness or with underscores like increment_blue_brightness (also: local variable names have same style as function/method names). Class names are usually capital case like MyClass. I sometimes switch from using under_scores or camelCase depending on the language I use. For instance, Ruby programmers heavily make use of under_scores while Objective-C programmers heavily make use of camelCase (and you really can't work around this for Obj-C method names without suffering). Although, not all languages have strong conventions like this.

Re: C++ for first language?

Posted: Sun Mar 18, 2012 5:42 pm
by Fonzeh
c++ is my first language and im kinda soaking it up like a sponge, although the gui portion does intimidate me. i have new sources to post for you guys on what ive been doing, but im trying to get used to using multiple classes for different functions. its pretty easy going for me, just so easy to get lost in my code lol.

anyway ill post my sources later so nil can tell me what i did wrong lol.

Re: C++ for first language?

Posted: Wed Mar 21, 2012 4:31 pm
by nil
Programming languages aren't bound by a "GUI." There is no GUI portion in C++. Yet there are GUI libraries, each which may support a number of programming languages. Learning a programming language and learning how a GUI library works are two distinct things.

Re: C++ for first language?

Posted: Thu Mar 22, 2012 1:21 pm
by Vegerot
So, today, again, people were being total assholes. But I did learn how to comment.

Now what we're doing is that we're making a game where a computer randomly comes up with a number 1-100 and we have the guess what the number is, and the computer will either say "higher" or "lower" until we get the number right.

He gave us this packet that we're supposed to just read over, because we haven't gone over it yet in class.

(Sparky, next week we're Mumblin' during this class kaye?)

Also random links to shit I did today. http://www.mediafire.com/?2yibexj41ihbhlj (written by my teacher, but he wants us to use this in our app) http://www.mediafire.com/?vebk24trdh7491j (MY first application!!! I'm pretty sure I broke it during the last 30 seconds of class, but didn't have time to compile my changes so I couldn't check) http://www.mediafire.com/?czwz4xgi4251i0e (along with the past link are the first things I've made. I forget exactly what the different between these two are, guess it's bad to already be mixing my stiff up <.<)

Edit: can you guys also help me out with my packet? I'm 99% sure I'm going to be the only one to actually read the assignment but I want to do it anyways.

Re: C++ for first language?

Posted: Fri Mar 23, 2012 12:32 pm
by Monoman
From images in the packet, that isn't an assignment just an explanation of different constructs in the language. I didn't look at the other downloads.

Re: C++ for first language?

Posted: Fri Mar 23, 2012 12:44 pm
by Vegerot
yeah, our assignment is to read it, but I'm having trouble understanding it.

Re: C++ for first language?

Posted: Sat Mar 24, 2012 6:53 pm
by Fonzeh
nil wrote:Programming languages aren't bound by a "GUI." There is no GUI portion in C++. Yet there are GUI libraries, each which may support a number of programming languages. Learning a programming language and learning how a GUI library works are two distinct things.

I know this man thats why i haven't learned it yet. But you DO have the write the CODE to CREATE the GUI in C++. I DONT know how to DO that yet because I havent WENT OVER that because I haven't had TIME yet.

All I was saying. Sorry if there was some kind of miscommunication.