Old 4th September 2007, 01:56   #1
fastingaciu
Major Dude
 
fastingaciu's Avatar
 
Join Date: Dec 2005
Location: Canada
Posts: 940
C++

Well basically I want some pointers on how I should start learning some C++. Right now I'm 16 and my mind is kinda set for become a computer engineer but unfortunately the Programing Computer Courses in my high school are crap. The hardware, software, networking parts on the courses are pretty good. Last course I took they thought us a language called Touring.

Almost anyone I've asked does not know of Touring so thats why I want to start learning C++ on my own. Any help would be appreciated.

Flo

Those who can do, do; those who can't do, teach.
fastingaciu is offline   Reply With Quote
Old 4th September 2007, 02:00   #2
k_rock923
\m/
(Forum King)
 
k_rock923's Avatar
 
Join Date: Jul 2003
Location: /bin/bash
Posts: 7,850
Send a message via AIM to k_rock923
hahaha, pointers on C++, what a pun! Sorry.

What is Touring? Sounds almost like Turing machines to me.

Anyway, just start with a good book. Also, do not learn C before C++.

Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway.
k_rock923 is offline   Reply With Quote
Old 4th September 2007, 05:54   #3
fwgx
Rudolf the Red.
(Forum King)
 
fwgx's Avatar
 
Join Date: Nov 2000
Posts: 9,314
A good book, and an evening class are good ideas. There's a lot of value you can get out of talking to people about the language in a practical sense then just reading about it.

Be warned that C++ is hard, especially if you don't have much grasp of programming to start with. Don't expect to master it for 10 years and even then you wont know it all.

.: fwgx.co.uk.:.My art:.

"We think science is interesting and if you disagree, you can fuck off."
fwgx is offline   Reply With Quote
Old 4th September 2007, 09:14   #4
gaekwad2
Foorum King
 
gaekwad2's Avatar
 
Join Date: Jul 2003
Location: bar2000
Posts: 11,424
If you don't have programming practice and don't have lots of patience better start with another language.

At first glance Turing doesn't look too bad, but if you want something that's also used outside of school try Python.
gaekwad2 is offline   Reply With Quote
Old 4th September 2007, 11:56   #5
J.Melo
Senior Member
 
J.Melo's Avatar
 
Join Date: Oct 2006
Posts: 327
You must mean Turing. Turing is the lang they use at my school. I don't think they teach things like C++ in high school.

Well, here's an okay place to start: http://www.cprogramming.com/

EDIT: And you'll need a good compiler to go with it: http://www.bloodshed.net/devcpp.html
J.Melo is offline   Reply With Quote
Old 4th September 2007, 12:44   #6
zootm
Forum King
 
zootm's Avatar
 
Join Date: Jan 2002
Location: the nether reaches of bonnie scotland
Posts: 13,375
Don't use Bloodshed. It's buggy and rubbish. Visual C++ Express will probably do ya on Windows, just try to avoid ending up learning "Microsoft C++". Failing that the C++ extensions for NetBeans or Eclipse will probably work quite nicely too.

zootm is offline   Reply With Quote
Old 4th September 2007, 13:16   #7
gaekwad2
Foorum King
 
gaekwad2's Avatar
 
Join Date: Jul 2003
Location: bar2000
Posts: 11,424
Quote:
Originally posted by zootm
Don't use Bloodshed. It's buggy and rubbish. Visual C++ Express will probably do ya on Windows
If you manage to get anything done with it.

Oh, and... (somehow the topic seemed familiar)

Last edited by gaekwad2; 4th September 2007 at 13:45.
gaekwad2 is offline   Reply With Quote
Old 4th September 2007, 13:59   #8
zootm
Forum King
 
zootm's Avatar
 
Join Date: Jan 2002
Location: the nether reaches of bonnie scotland
Posts: 13,375
Quote:
Originally posted by gaekwad2
If you manage to get anything done with it.
Sadly this is the peril of starting with any IDE.

zootm is offline   Reply With Quote
Old 4th September 2007, 14:01   #9
. - .... .- -. ....
Backpacking
Moderator
 
. - .... .- -. ....'s Avatar
 
Join Date: Nov 2000
Location: საქართველო (Georgia)
Posts: 10,104
Send a message via ICQ to . - .... .- -. .... Send a message via Yahoo to . - .... .- -. ....
10 Download compiler.
20 Write and debug simple "Hello World" program.
30 Write and debug simple slightly more complex program.
40 Find a programming project that YOU want to do, and code it, learning as you go.
50 GOTO 30

Like my photography? Buy some here....
. - .... .- -. .... is offline   Reply With Quote
Old 4th September 2007, 16:07   #10
xzxzzx
Forum King
 
xzxzzx's Avatar
 
Join Date: Aug 2002
Posts: 7,254
Forget C++. It's a useful language, but unless you're already very familiar with how a PC system works (I'm talking things like memory allocation, what a WORD is, the concept of stack vs. heap, how a string is represented in memory, etc, etc), it's going to be very, very difficult as a first language.

Try Python.

Freedom of speech is the basic freedom of humanity. When you've lost that, you've lost everything.
1\/\/4y 34|<$p4y 1gp4y 33714y, 0d4y 0uy4y? | Roses are #FF0000; Violets are #0000FF; chown -R ${YOU} ~/base
The DMCA. It really is that bad. : Count for your life.
xzxzzx is offline   Reply With Quote
Old 4th September 2007, 16:29   #11
fwgx
Rudolf the Red.
(Forum King)
 
fwgx's Avatar
 
Join Date: Nov 2000
Posts: 9,314
Quote:
Originally posted by xzxzzx
Forget C++. It's a useful language, but unless you're already very familiar with how a PC system works (I'm talking things like memory allocation, what a WORD is, the concept of stack vs. heap, how a string is represented in memory, etc, etc), it's going to be very, very difficult as a first language.

Try Python.
I'd say that makes it ideal as a first language!

.: fwgx.co.uk.:.My art:.

"We think science is interesting and if you disagree, you can fuck off."
fwgx is offline   Reply With Quote
Old 4th September 2007, 18:40   #12
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
Quote:
Originally posted by fwgx
I'd say that makes it ideal as a first language!
Nop..ASM is the ideal..


* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 4th September 2007, 19:17   #13
gaekwad2
Foorum King
 
gaekwad2's Avatar
 
Join Date: Jul 2003
Location: bar2000
Posts: 11,424
ASM is for weak minds who can't remember binary opcodes.
gaekwad2 is offline   Reply With Quote
Old 5th September 2007, 12:46   #14
zootm
Forum King
 
zootm's Avatar
 
Join Date: Jan 2002
Location: the nether reaches of bonnie scotland
Posts: 13,375
Quote:
Originally posted by fwgx
I'd say that makes it ideal as a first language!
I'm not convinced that a language which makes you learn everything up-front can be defended in the face of a gamut of languages which allow you to learn that information when you need it.

zootm is offline   Reply With Quote
Old 5th September 2007, 15:01   #15
xzxzzx
Forum King
 
xzxzzx's Avatar
 
Join Date: Aug 2002
Posts: 7,254
Quote:
Originally posted by fwgx
I'd say that makes it ideal as a first language!
o_O

No, if those were good attributes, you should program in opcodes. Not with an assembler, mind you, but opcodes. Just crack out the ol' Hex Editor, your x86 and PE reference, and get crackin'!

Then you'd really have to learn everything before you could do anything useful.

Well, maybe not. Just look at Steve Gibson. *rimshot*

Freedom of speech is the basic freedom of humanity. When you've lost that, you've lost everything.
1\/\/4y 34|<$p4y 1gp4y 33714y, 0d4y 0uy4y? | Roses are #FF0000; Violets are #0000FF; chown -R ${YOU} ~/base
The DMCA. It really is that bad. : Count for your life.
xzxzzx is offline   Reply With Quote
Old 5th September 2007, 16:31   #16
fwgx
Rudolf the Red.
(Forum King)
 
fwgx's Avatar
 
Join Date: Nov 2000
Posts: 9,314
Being able to understand programming and being able to use a language are slightly different I think.

If you want to learn programming then I think it's best to know what you're programming i.e. the hardware. Once you know that then you can pick up another language a lot easier, the reverse is not true (How many VB6 developers do you think can easily learn C++ or java (yeah a stereotype, sue me)).

Understanding how memory works, what the difference between heap and stack memory is, what a pointer is and how it differs from a variable value, working out the exact size of an object and understanding different data structures and their representation on the hardware I think is pretty fundamental to understanding how to program.

If you just want to get stuff done for a quick app then pick up VB and do it in an afternoon, if you want to become a programmer then learn the fundamentals, and the earlier the better.

Hiding behind a memory safe, soft typed language that hides everything from you doesn't help learning to become a programmer it helps people who can program get things done quicker. If you're not allowed to make mistakes or get access to the underlying hardware then I think you're missing a great deal, especially early on.

They say one of the best things you can write to become a better programmer is a compiler for the language because that forces you to learn a lot about the underlying principles upon which you are programming at a high level.

.: fwgx.co.uk.:.My art:.

"We think science is interesting and if you disagree, you can fuck off."
fwgx is offline   Reply With Quote
Old 5th September 2007, 18:57   #17
k_rock923
\m/
(Forum King)
 
k_rock923's Avatar
 
Join Date: Jul 2003
Location: /bin/bash
Posts: 7,850
Send a message via AIM to k_rock923
Why stop there? Write the linker, too!

Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway.
k_rock923 is offline   Reply With Quote
Old 5th September 2007, 19:56   #18
ScorLibran
Resident Floydian
 
ScorLibran's Avatar
 
Join Date: Aug 2003
Posts: 6,222
Being 16 years old, you've got time. Don't take shortcuts. As some people have advised here, learn the fundamentals early on. Not to say you can't begin learning practical aspects of programming at the same time, just don't let yourself forsake the fundamentals in these early years.

After you have a strong grasp of the concepts and of several simple languages and methodologies with which you can apply them - which should be sometime during your second year of college - then you should find out what languages are hot in the professional world at that time and learn them. (Most CS/CE programs will already include them, but be prepared to use your electives to "fill in the gaps". Sometimes the industry can change pretty fast.)

And don't expect to master anything advanced before embarking on your career. No entry-level applicant I've ever interviewed was a master of anything mainstream (outside their mind ). That's the purpose of the entry-level position. You'll practice what you've learned in school, you'll learn the many aspects of real-world corporate software development, and you'll continue learning all of it throughout your career. And if you stick with it, you'll be recognized many times for the excellence of your work.

I'm a psychosomatic sister running around without a leash.
ScorLibran is offline   Reply With Quote
Old 5th September 2007, 22:05   #19
fwgx
Rudolf the Red.
(Forum King)
 
fwgx's Avatar
 
Join Date: Nov 2000
Posts: 9,314
I agree with ScorLibran. I was pretty good at programming at uni, one of the best in my class. But it wasn't until I left uni that I properly understood some quite fundamental aspects of object orientated code such as polymorphism and the power that that brings and why you shouldn't have classes just filled with getter and setter methods of their private data.

I learned more about C++ in the past 3 years since leaving uni and using it in the real world and reading articles and good blogs on it than I ever did at uni. Whilst you're studying it you get so bogged down in what you're doing that you never get the change to take your head out and look around at the bigger picture which will be the time when concepts twig in your brain. I'm still learning new stuff and probably always will be

One of the biggest complaints I hear branded around is of kids straight out of uni that have only ever used VB, java ruby type languages that have no concept of anything except getting things done quickly. That's fine for what it is, but it doesn't scale or transport anywhere near as well as knowing the reasons behind what you're doing.

.: fwgx.co.uk.:.My art:.

"We think science is interesting and if you disagree, you can fuck off."
fwgx is offline   Reply With Quote
Old 5th September 2007, 23:18   #20
zootm
Forum King
 
zootm's Avatar
 
Join Date: Jan 2002
Location: the nether reaches of bonnie scotland
Posts: 13,375
This is probably going to get vitriolic.

Quote:
Originally posted by fwgx
Being able to understand programming and being able to use a language are slightly different I think.
And as such learning C++ is a perfectly good idea if that's what you want to do. However, if you want to be a good programmer there's better paths to take.

Quote:
Originally posted by fwgx
If you want to learn programming then I think it's best to know what you're programming i.e. the hardware.
This is a lousy attitude. You're almost never programming "the hardware". You are in almost all cases - at best - programming the operating system and its associated libraries.

Quote:
Originally posted by fwgx
Once you know that then you can pick up another language a lot easier, the reverse is not true (How many VB6 developers do you think can easily learn C++ or java (yeah a stereotype, sue me)).
You use a terrible example (the VB6 programmers in question probably would have given up on Java or C++ anyway) and what you're saying simply does not ring true; the important concepts are algorithms and data structures. Most VB6 programs use neither, and most VB6 programmers do not learn by going through this sort of task. This is why they fail.

Quote:
Originally posted by fwgx
Understanding how memory works, what the difference between heap and stack memory is, what a pointer is and how it differs from a variable value, working out the exact size of an object and understanding different data structures and their representation on the hardware I think is pretty fundamental to understanding how to program.
I disagree; only a few of those are useful in anything approaching a general case. The difference between heap and stack is generally important, but in most cases a good understanding of variable scope (which describes 99% of the cases where the distinction is important) is enough. And you'll get that from most languages. Understanding what reference and value types are and how they differ is important; pointers are just a particularly low-level (and, for most purposes, crappy) case of reference types. Data structures are obviously important but most modern languages have excellent facility for teaching these.

"Working out the exact size of an object" is only important when you're doing manual memory management. Working out rough sizes for structures is sometimes useful if you need to cut the memory load of a system, but frequently the problem is algorithmic rather than structural.

Quote:
Originally posted by fwgx
If you just want to get stuff done for a quick app then pick up VB and do it in an afternoon, if you want to become a programmer then learn the fundamentals, and the earlier the better.
I agree with this completely. C++ is not, however, what I'd consider the best language to teach those fundamentals. We do seem to differ a little on what constitutes "fundamental", though.

Quote:
Originally posted by fwgx
Hiding behind a memory safe, soft typed language that hides everything from you doesn't help learning to become a programmer it helps people who can program get things done quicker.
I strongly disagree with the first part of this assertion. Pointers and the other assorted shit you get in C++ do not make you a better programmer, they make you a better C++ programmer.

Type safety as a concept is much more descriptive of the parts of programming that it is important to learn than pointers and that junk. Once you understand call-by-reference as opposed to call-by-value the meaning of pointers is clear; all that's needed is the syntax. Once you understand the object lifecycle you understand how memory allocation works.

Quote:
Originally posted by fwgx
If you're not allowed to make mistakes or get access to the underlying hardware then I think you're missing a great deal, especially early on.
Unless you are planning on going into low-level system programming immediately you are losing precisely nothing here. You don't get a better understanding of the concepts.

Quote:
Originally posted by fwgx
They say one of the best things you can write to become a better programmer is a compiler for the language because that forces you to learn a lot about the underlying principles upon which you are programming at a high level.
I will acknowledge this as a good idea, but it's a much more complex task and hugely out of the scope of someone learning programming. Not to mention the fact that you can write a compiler perfectly well in Java; pointers and so on are still not nearly as important as the abstractions they implement.


Quote:
Originally posted by fwgx
I agree with ScorLibran. I was pretty good at programming at uni, one of the best in my class. But it wasn't until I left uni that I properly understood some quite fundamental aspects of object orientated code such as polymorphism and the power that that brings and why you shouldn't have classes just filled with getter and setter methods of their private data.
Polymorphism is fairly fundamental to object-oriented languages, but not a hell of a lot else. It does work as a nice example of code extension, though. I'm certainly surprised you didn't learn that.

As for the getter- and setter-filled classes, JavaBeans are the recommended way of doing re-usable data structures in Java . It does make sense in that setting, though.

Quote:
Originally posted by fwgx
I learned more about C++ in the past 3 years since leaving uni and using it in the real world and reading articles and good blogs on it than I ever did at uni. Whilst you're studying it you get so bogged down in what you're doing that you never get the change to take your head out and look around at the bigger picture which will be the time when concepts twig in your brain. I'm still learning new stuff and probably always will be
This is true of absolutely any language.

Quote:
Originally posted by fwgx
One of the biggest complaints I hear branded around is of kids straight out of uni that have only ever used VB, java ruby type languages that have no concept of anything except getting things done quickly. That's fine for what it is, but it doesn't scale or transport anywhere near as well as knowing the reasons behind what you're doing.
The language choice is absolutely fuck-all to do with the fact that they did shitty courses.

Java, for example, is a perfectly good choice for a language for a University course. If people need to learn lower-level things later on (such as direct memory management) lower-level languages can be used. Although my own course was Java-based, we used things like C, ML, Prolog, Esterel, and a bunch of other languages as appropriate to learn concepts specific to the areas for which the languages are good. Now I hear that the same course teaches Haskell alongside Java in its first year; despite the fact that it's conceptually "further from the metal", I think it'd make an excellent language for teaching many of the concepts.

zootm is offline   Reply With Quote
Old 6th September 2007, 01:08   #21
fastingaciu
Major Dude
 
fastingaciu's Avatar
 
Join Date: Dec 2005
Location: Canada
Posts: 940
Ok.. well this isn't as easy as I thought it would be. To many people with different opinions. Some of you forgot that I have absolutely no knowledge of any programing. Well other then Turing but with Turing we only had a interface project that included turning LEDs on and stuff like that.

Basically I just want a start point. Even though I'm only 16 I think I'm ready to understand some of the basics programing features. The whole reason why I want this is that I don't want to go to uni and start from scarp. I want to have some knowledge; I just want to make it easier on my self. Also I was always fashioned by the possibility of creating your own programs the way you like it. When I say programs don't think I mean high tech programs because Im not that dumb.

I know that you just don't learn everything over the night. I'm willing to take it step by step and learn slowly.

Those who can do, do; those who can't do, teach.
fastingaciu is offline   Reply With Quote
Old 6th September 2007, 08:10   #22
gaekwad2
Foorum King
 
gaekwad2's Avatar
 
Join Date: Jul 2003
Location: bar2000
Posts: 11,424
Just pick something and go with it.

It's just that if you want to learn by yourself the risk of getting stuck is much lower with an 'easier' language.
gaekwad2 is offline   Reply With Quote
Old 6th September 2007, 15:09   #23
xzxzzx
Forum King
 
xzxzzx's Avatar
 
Join Date: Aug 2002
Posts: 7,254
Ask three good programmers, get four answers. What you should keep in mind is that we're pretty much quibbling on small stuff -- we mostly agree on the major stuff, except for which language to start with, which, of course, is the question you asked.

I think learning C++ (or, say, C) is fantastically helpful to understand what your language of choice in the future will *actually* be doing. And unlike zootm, I think understanding things like pointers and the "bare metal" stuff is a very, very good idea, and will in fact help you program well in a higher-level language, if only from a performance perspective -- even though most performance problems are in fact algorithmic in nature.

On the other hand, I think it's waaay too much to shove into someone's face early-on. It's much better to learn something useful, like Python, than something technical, like C/C++, but I think it's ultimately important to learn both.

In particular, I'd suggest to you to get going in Python for a while, and once you feel fairly comfortable, and have actually made a few interesting programs, take one of your Python programs and rewrite it in C or C++. And then once you've done that, do something low-level -- something like reading in a bitmap file and calculating its average colors, for example.

[edit]Heh. Reading that old thread, I agree with myself, but I no longer have such a low opinion of Java. Damn you, zootm.[/edit]

Freedom of speech is the basic freedom of humanity. When you've lost that, you've lost everything.
1\/\/4y 34|<$p4y 1gp4y 33714y, 0d4y 0uy4y? | Roses are #FF0000; Violets are #0000FF; chown -R ${YOU} ~/base
The DMCA. It really is that bad. : Count for your life.
xzxzzx is offline   Reply With Quote
Old 6th September 2007, 16:02   #24
k_rock923
\m/
(Forum King)
 
k_rock923's Avatar
 
Join Date: Jul 2003
Location: /bin/bash
Posts: 7,850
Send a message via AIM to k_rock923
It makes fuck all for difference what language you learn the basics of programming in. If statements, loops, etc work the same in pretty much whatever you use (unless it's assembly. bad memories of CSCI241).

I think that you might want to then study some algorithms, or at least how algorithms are designed and such as you can't do that many practical things without understanding algorithms.

Pick up a book on data structures as well. I think you need a good understanding of data structures before you start with C/C++.

I'm going to stop because I'm starting to outline a CS course. I'm sure others will point out any flaws in this logic, and I welcome their constructive criticism. I'm really not in the mood for 'you're an idiot, k_rock', though. (long day).

Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway.
k_rock923 is offline   Reply With Quote
Old 6th September 2007, 22:34   #25
zootm
Forum King
 
zootm's Avatar
 
Join Date: Jan 2002
Location: the nether reaches of bonnie scotland
Posts: 13,375
Your outline's actually pretty sensible, k_rock.

zootm is offline   Reply With Quote
Old 12th September 2007, 15:05   #26
xzxzzx
Forum King
 
xzxzzx's Avatar
 
Join Date: Aug 2002
Posts: 7,254
I don't have a particular disagreement. C/Python/Perl/C++/Lua/C#/whatever can be conceptually thought of as the same family of languages -- they're all imperative, code-is-not-data-damn-it languages (although C# 3.0 is breaking that mold a little).

If you get into (for example) Haskell or Lisp, it's pretty different.

I do think that starting with a higher-level language, like Python, Ruby, Lua, etc, is a good idea, because of the initially very steep learning curve of things like C++.

Freedom of speech is the basic freedom of humanity. When you've lost that, you've lost everything.
1\/\/4y 34|<$p4y 1gp4y 33714y, 0d4y 0uy4y? | Roses are #FF0000; Violets are #0000FF; chown -R ${YOU} ~/base
The DMCA. It really is that bad. : Count for your life.
xzxzzx is offline   Reply With Quote
Old 12th September 2007, 15:58   #27
Smeggle
Just Strolling By
(Major Dude)
 
Smeggle's Avatar
 
Join Date: Aug 2002
Location: A Long Winding Road.....
Posts: 3,250
The Invention of C++

Music is Life, Love and Happiness :|: Life is Music. Serren - 1985 - 2005
Religion? Religion is a Blasphemy against humanity - From the film What the Bleep do we know

siggy link So stumbling? whats it all about
Smeggle is offline   Reply With Quote
Old 12th September 2007, 22:44   #28
zootm
Forum King
 
zootm's Avatar
 
Join Date: Jan 2002
Location: the nether reaches of bonnie scotland
Posts: 13,375
Amusing. It's kind of a flame, but it brings up a couple of good points. And a whole bunch of bad ones from someone clearly bitter at "new fangled" programming stuff.

zootm is offline   Reply With Quote
Old 12th September 2007, 23:09   #29
Smeggle
Just Strolling By
(Major Dude)
 
Smeggle's Avatar
 
Join Date: Aug 2002
Location: A Long Winding Road.....
Posts: 3,250
emm wasn't C++ built on C? - do your self a favour learn the nuts and bolts first then learn all the derivatives (That are a total bug full) after..

At least you'll know the basics of how it works - you should be able to then at least try to figure the rest...

Look up the old Sinclair Spectrum/Commordore64|128 - most of that was C basic.. Fun at the time ..

who am I kidding still is

10 PRINT "Hello WORLD I CAN PROGRAM"
20 GOTO 10
30 RUN
ENTER

Yay simplest loop in C

jayz I used to love annoying Currys and Dixons on a Saturday

whats scary is I can fucking remember that

Music is Life, Love and Happiness :|: Life is Music. Serren - 1985 - 2005
Religion? Religion is a Blasphemy against humanity - From the film What the Bleep do we know

siggy link So stumbling? whats it all about
Smeggle is offline   Reply With Quote
Old 12th September 2007, 23:20   #30
gaekwad2
Foorum King
 
gaekwad2's Avatar
 
Join Date: Jul 2003
Location: bar2000
Posts: 11,424
Er, that was BASIC, not C.

(Also RUN in a program doesn't make sense (though I bet some dialect had a perverse use for it), even less so after an infinite loop.)

And Commodore Basic was horrible, all those PEEKs and POKEs to get anything done, GOSUBs instead of functions (and of course no local variables (also iirc variable names were limited to two characters)), no loops except FOR...NEXT, no code blocks (had to use GOTO if you wanted to do more things after an IF statement than could be fit in a (80 character) line),...

Last edited by gaekwad2; 12th September 2007 at 23:37.
gaekwad2 is offline   Reply With Quote
Old 12th September 2007, 23:51   #31
Smeggle
Just Strolling By
(Major Dude)
 
Smeggle's Avatar
 
Join Date: Aug 2002
Location: A Long Winding Road.....
Posts: 3,250
Quote:
Originally posted by gaekwad2
Er, that was BASIC, not C.

(Also RUN in a program doesn't make sense (though I bet some dialect had a perverse use for it), even less so after an infinite loop.)

And Commodore Basic was horrible, all those PEEKs and POKEs to get anything done, GOSUBs instead of functions (and of course no local variables (also iirc variable names were limited to two characters)), no loops except FOR...NEXT, no code blocks (had to use GOTO if you wanted to do more things after an IF statement than could be fit in a (80 character) line),...
but it was fun - especially when you got a typo in $sprite at line 1468 (Why was it always 1468 ) and then spent the next three days rewriting the fecking thing...

But GOTO was brilliant - least I thought so...

Music is Life, Love and Happiness :|: Life is Music. Serren - 1985 - 2005
Religion? Religion is a Blasphemy against humanity - From the film What the Bleep do we know

siggy link So stumbling? whats it all about
Smeggle is offline   Reply With Quote
Old 13th September 2007, 01:12   #32
k_rock923
\m/
(Forum King)
 
k_rock923's Avatar
 
Join Date: Jul 2003
Location: /bin/bash
Posts: 7,850
Send a message via AIM to k_rock923
Although it's very rarely the correct thing to do, when it is appropriate to use goto, it really comes in handy.

Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway.
k_rock923 is offline   Reply With Quote
Old 18th September 2007, 18:28   #33
xzxzzx
Forum King
 
xzxzzx's Avatar
 
Join Date: Aug 2002
Posts: 7,254
There's absolutely nothing wrong with goto, but like most programming constructs, it can be wildly abused.

Freedom of speech is the basic freedom of humanity. When you've lost that, you've lost everything.
1\/\/4y 34|<$p4y 1gp4y 33714y, 0d4y 0uy4y? | Roses are #FF0000; Violets are #0000FF; chown -R ${YOU} ~/base
The DMCA. It really is that bad. : Count for your life.
xzxzzx is offline   Reply With Quote
Old 18th September 2007, 21:17   #34
zootm
Forum King
 
zootm's Avatar
 
Join Date: Jan 2002
Location: the nether reaches of bonnie scotland
Posts: 13,375
Goto can be made into a useful programming construct, but at its original core it is a rotten idea.

zootm is offline   Reply With Quote
Old 20th September 2007, 05:47   #35
ulillillia
Senior Member
 
ulillillia's Avatar
 
Join Date: Feb 2002
Location: Minot, ND, USA
Posts: 381
I first started with Gamestudio which has a programming language very similar to C, except highly simplified. It took me a few months to get going on it and I later went with C programming to expand on my potential with game programming since Gamestudio was too limiting due to the single variable type. Nowadays, I can program almost any 2D game though I still have a few things I need to learn: dynammically changing the size of an array, running in fullscreen rather than windowed mode, and using hardware acceleration for dynamically-created on-the-fly special effects. I've already made and released one of my C programs, The Interactive Animation (licensed as freeware), but it's not a game or anything.

For starters, learn the fundamentals:

1. The formatting and syntax - semicolons at the end of statements, commenting, defining and creating functions and variables, preprocessor directives like #define, and other essentials.
2. Using and calling functions, especially "int main()".
3. Variable manipulation - controlling variables, whether through complex formulas or the choosing of options with if statements
4. Understand and use common C instructions like printf, strcpy, and while().

These are just some examples. The cprogramming.com website is particularly useful. I'd rather start with C first then migrate to C++ since the two are very similar with only a few minor differences. Visual C++ 2005 Express, which is what I use, is particularly effective and its free! The mega downside, however, is its huge download. If you've got a dial-up connection, expect to spend almost 12 hours downloading at 5 Kilobytes per second. Even on my 4 Mbps connection, it still took a monster 20 minutes to download it (it's 200 MB - huge, and that doesn't include a further 250 MB for the Windows SDK if you do get that). Fortunately, you actually download a download manager first and this will help a lot for those with dial-up.

Learn the basics first, then try to make something simple. Just a year ago, I couldn't write a program to simply add 2+3 and display the output. Now I've got an interactive program a few others to automate tasks I do a lot of. I'm now working on my first game I made, but rewriting it in C to take advantage of what C offers that Gamestudio doesn't (or didn't at the time). I don't recall my signature here, but if I recall right, it's basically a fun-type C program with correct formatting though without the proper spacing and indenting.

void BlueWater() {water.color=blue; while(GameRunning) {if (fox.pos == InBlueWater) {fox.air--; FoxDrown(fox.air);} else {fox.air=1800; fox.flags = WantsToGetWet; } WaitFrames(1); }} // My top favorite thing in 2D Sonic (as C)
ulillillia is offline   Reply With Quote
Old 20th September 2007, 07:10   #36
mikm
Major Dude
 
mikm's Avatar
 
Join Date: May 2001
Location: somewhere else
Posts: 1,255
The addition of object-orientation is more than just "a minor difference".

powered by C₂H₅OH
mikm is offline   Reply With Quote
Old 20th September 2007, 08:19   #37
ulillillia
Senior Member
 
ulillillia's Avatar
 
Join Date: Feb 2002
Location: Minot, ND, USA
Posts: 381
Quote:
Originally posted by mikm
The addition of object-orientation is more than just "a minor difference".
I mostly referred to the style of the syntax. Sorry if I wasn't clear on that.

Edit: Copying my signature, here's a brief explanation on C anyway:

code:

void BlueWater()
{
water.color=blue;

while(GameRunning)
{
if (fox.pos == InBlueWater)
{
fox.air--;
FoxDrown(fox.air);
}

else
{
fox.air=1800;
fox.flags = WantsToGetWet;
}

WaitFrames(1);
}
}



void BlueWater() - a function declared that doesn't return anything nor have any parameters.

water.color = blue; - sets the color aspect of water to blue. The "blue" would have to be defined in a #define for it to work, usually 0x00FF0000 (or 0xFF000000, not sure which)

while (GameRunning) - a loop that continues as long as the "GameRunning" variable is equal to 1.

if (fox.pos == InBlueWater) - a condition where the "pos" variable of the fox structure exactly equals whatever value "InBlueWater" is, likely another #define (used as a flag).

fox.air--; - the "air" variable in the fox structure decreases by 1.

FoxDrown(fox.air); - calling the "FoxDrown" function with the "air" variable of the fox structure as the parameter.

else - used when an "if" condition is present and applies to all other conditions involving the variables as specified in the "if" statement. In this case, it'll execute only when "fox.pos" is not the same as "InBlueWater".

fox.air - sets the "air" variable of the fox structure to 1800.

fox.flags = WantsToGetWet; - Setting the flags variable of the fox structure to "WantsToGetWet", again, another define or variable. This, for flags, will only make this one active.

WaitFrames(1); - Another function call with the number 1 as the parameter.

This, of course, wouldn't run because you'll need the other essentials as well. I'm just only explaining a few things. If you've played the classic Sonic games with Sonic and Tails together, you'll be familiar as to what this is. If not, I tend to like drowning Tails in the water in the games and this quite well mimics what I enjoy doing.

void BlueWater() {water.color=blue; while(GameRunning) {if (fox.pos == InBlueWater) {fox.air--; FoxDrown(fox.air);} else {fox.air=1800; fox.flags = WantsToGetWet; } WaitFrames(1); }} // My top favorite thing in 2D Sonic (as C)

Last edited by ulillillia; 20th September 2007 at 08:34.
ulillillia is offline   Reply With Quote
Old 20th September 2007, 15:59   #38
xzxzzx
Forum King
 
xzxzzx's Avatar
 
Join Date: Aug 2002
Posts: 7,254
Quote:
Originally posted by zootm
Goto can be made into a useful programming construct, but at its original core it is a rotten idea.
I don't think so. It's more of a very low-level idea, not a bad one.

Incidentally, you might enjoy this:
http://pplab.snu.ac.kr/courses/adv_p...p261-knuth.pdf
Edit: In fact, there is some particularly prophetic stuff in there that would be interesting even if "goto" stuff wasn't covered.

Freedom of speech is the basic freedom of humanity. When you've lost that, you've lost everything.
1\/\/4y 34|<$p4y 1gp4y 33714y, 0d4y 0uy4y? | Roses are #FF0000; Violets are #0000FF; chown -R ${YOU} ~/base
The DMCA. It really is that bad. : Count for your life.
xzxzzx is offline   Reply With Quote
Old 20th September 2007, 16:06   #39
k_rock923
\m/
(Forum King)
 
k_rock923's Avatar
 
Join Date: Jul 2003
Location: /bin/bash
Posts: 7,850
Send a message via AIM to k_rock923
Try doing much of anything in assembly without goto/jumps. . .

Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway.
k_rock923 is offline   Reply With Quote
Old 20th September 2007, 19:56   #40
zootm
Forum King
 
zootm's Avatar
 
Join Date: Jan 2002
Location: the nether reaches of bonnie scotland
Posts: 13,375
Quote:
Originally posted by xzxzzx
I don't think so. It's more of a very low-level idea, not a bad one.

Incidentally, you might enjoy this:
http://pplab.snu.ac.kr/courses/adv_p...p261-knuth.pdf
Edit: In fact, there is some particularly prophetic stuff in there that would be interesting even if "goto" stuff wasn't covered.
That's what I mean though. Most of the examples in that paper (and I've just skimmed it, but still) can be achieved by a "safe" implementation of goto which assures sensible running order. C# has this, for example, and sparing use there can be handy.

Quote:
Originally posted by k_rock923
Try doing much of anything in assembly without goto/jumps. . .
I don't think regarding assembly as a "programming language" on this sort of level is useful!

zootm is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Community Center > General Discussions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump