A Conversation for The H2G2 Programmers' Corner
can someone help an absolute beginner in c++?
Researcher207975 Started conversation Apr 18, 2003
...and I do mean absolute beginner. I can't even get my first obligatory 'hello' program to run!
I've posted a message up in the How Do I...? area of h2g2 before finding this mecca of programming.
Basically, I'm using the terminal on my mac (essentially unix) and I have written and (I believe) compiled my first c++ program... but I don't seem to be able to get it to run.
As I'm not sure how to put in a link to my previously posted question, I'll repeat the details here (hope you don't mind).
To compile I did this:
c++ hello.cpp -o hello
This created a file called hello
Then I thought all I had to do was type in hello, but to my dismay, it just said it couldn't find the command.
Please help me find my training wheels...
can someone help an absolute beginner in c++?
Ion the Naysayer Posted Apr 18, 2003
"hello" may not be set to execute permissions. Try "chmod 755 hello" in the same directory and try again.
can someone help an absolute beginner in c++?
Ion the Naysayer Posted Apr 18, 2003
Another thought... If it still doesn't work, try "./hello" instead of just "hello". Depending on your configuration you may have to specify that the program is in the current directory.
can someone help an absolute beginner in c++?
26199 Posted Apr 18, 2003
Ion's second answer sounds right to me... as far as I'm aware it's a security precaution, stops you accidentally running a program that's not in one of the standard locations...
So -- if I might ask -- why programming, and why c++?
I wish you all the best with it, of course, programming is a lot of fun ... I'm just incurably curious
can someone help an absolute beginner in c++?
Researcher207975 Posted Apr 18, 2003
Thanks very much Ion & 26199! ./hello did the trick... I can now move on from Chapter 2 of the Idiot's Guide
As for why programming and why c++? Well, I got a taste of programming in uni (did java), sadly, I enjoyed it... Unfortunately, I'm one of those ppl who constantly struggles with themselves trying to discover their perfect career & as a result change my mind a lot...
I found a course in games programming that I'd like to do and I thought I'd dip my toe in the c++ pool before taking the plunge and forking out large sums of money for a course that uses visual c++.
Thanks again!
can someone help an absolute beginner in c++?
DoctorMO (Keeper of the Computer, Guru, Community Artist) Posted Apr 19, 2003
Yep great work guys, same anwsers I would have given, so why c++, why not ansii c? all those type def's and castings, lots of display niggles and string manipulation problems, although visual c++ I didn't find as nice to work with as just gcc and kate.
I'm going to move onto Java at some point, now that I got that SmartBeans Thingy, looks quite nice.
-- DoctorMO --
can someone help an absolute beginner in c++?
26199 Posted Apr 19, 2003
Ah... I've been using Java at uni for ... well, a little over a year now ... good fun!...
I've never actually used C++ as such, only C... but as far as I'm aware it's effectively Java but not as restricted, and with a few extra bits (and a few things not done as well), and of course different libraries. You can screw things up much more thoroughly ... but it is indeed the industry standard for games programming.
Either way, have fun ... the programmer's corner is a good place to ask questions
can someone help an absolute beginner in c++?
MaW Posted Apr 19, 2003
C++ is a bit more than a less restrictive Java... I always find it feels like a top-of-the-range sports car next to a family saloon.
can someone help an absolute beginner in c++?
Peet (the Pedantic Punctuation Policeman, Muse of Lateral Programming Ideas, Eggcups-Spurtle-and-Spoonswinner, BBC Cheese Namer & Zaphodista) Posted Apr 19, 2003
can someone help an absolute beginner in c++?
26199 Posted Apr 19, 2003
Ah, those were the good old days...
Ever play anything by Epic MegaGames?... Epic Pinball, One Must Fall... those, apparently, were coded in pure Assembler.
Respect
can someone help an absolute beginner in c++?
Peet (the Pedantic Punctuation Policeman, Muse of Lateral Programming Ideas, Eggcups-Spurtle-and-Spoonswinner, BBC Cheese Namer & Zaphodista) Posted Apr 19, 2003
I recently aquired a book by the authors of "Quake", giving the secrets of their rendering engine. Everything that actually manipulated pixels was written in pure assembler; higher-level languages like C++ were only used to write the "user shell" that tied it all together.
Their polygonal texture-mapping routines were optimised to eight machine cycles per pixel!
can someone help an absolute beginner in c++?
26199 Posted Apr 19, 2003
Interesting...
Was that for the software rendering, though?...
I can't see hardware-based rendering being all that optimisable...
Besides, Quake was a top-of-the-range game... hardly standard...
What's the book? Any good?
can someone help an absolute beginner in c++?
MaW Posted Apr 19, 2003
John Carmack didn't work alone on Quake, but nobody ever seems to remember who the other people were.
C++ is used increasingly for more and more of games because computers are getting faster and this allows, rather than for them to be able to waste CPU cycles (which they can't), but rather to be able to use better and better compilers, because the compilers can do far more optimisation than before while still maintaining acceptable compile times.
I would imagine hand-tuning in assembler still happens of course, but not to the extent that it used to, especially when you're using hardware graphics rendering (written in OpenGL or Direct3D most likely).
can someone help an absolute beginner in c++?
Peet (the Pedantic Punctuation Policeman, Muse of Lateral Programming Ideas, Eggcups-Spurtle-and-Spoonswinner, BBC Cheese Namer & Zaphodista) Posted Apr 19, 2003
It was the "Graphics Programming Black Book" by Michael Abrash, with foreward and some sections by John Carmack. And yes, the 8 instruction cycles per pixel was for software texture mapping, on a VGA-compliant device, using a "classic" (non-MMX) Pentium CPU model!
The book was published in 2000, and recently given away free in PDF format to Byte.com subscribers.
can someone help an absolute beginner in c++?
Peet (the Pedantic Punctuation Policeman, Muse of Lateral Programming Ideas, Eggcups-Spurtle-and-Spoonswinner, BBC Cheese Namer & Zaphodista) Posted Apr 19, 2003
can someone help an absolute beginner in c++?
DoctorMO (Keeper of the Computer, Guru, Community Artist) Posted Apr 19, 2003
Oh how none Assembler programers sqweel when it is mentioned, that asembler is fast, you may argue all you want, C or C++ isn't never going to be as fast. no mater how good your opermisations, anyway it probly gets worse with C#.
I belive all programers should learn some basic asm, even just x86 basics, it teaches you about some fundermental principals, like COMMENTING CODE!
Game Programing gets all the attenion these days. but it get's high up after a while, too many libaries and sub classes.
-- DoctorMO --
can someone help an absolute beginner in c++?
Ion the Naysayer Posted Apr 20, 2003
Considering with C# there's a layer between the executable and the hardware, it most likely will be slower than an equivalent program written in C/C++. Same deal with Java.
Of course if you're writing "Hello World" the effect is much worse. If you're writing a huge program the requires reimplementing most of the library functionality of C# or Java, they will probably both run at the same speed.
The difference, however, is usually negligable for real life applications. Most processors spend the vast majority of their time on the NOP instruction anyway. (NOP being the assembly langage instruction for No OPeration)
The tradeoff is usually speed of development. It's a lot faster to write a program when you can include a library instead of having to program the functionality yourself.
can someone help an absolute beginner in c++?
MaW Posted Apr 20, 2003
Of course, asm can always be faster than even the best-compiled C or C++ (which will always beat C# or Java or anything else that's run as bytecode, like Perl 6 will be), but there's a point where you just cannot write everything in hand-optimised assembler anymore. Modern software is so insanely big and takes so long to write anyway, can you imagine hand-optimising something like Unreal Tournament 2003 written entirely in assembler? Sure, it's possible, but it'd reduce development time to the point where you'd probably never see any profit from the game, which would be silly.
So we accept a slight reduction in speed as a trade-off for having faster development time, more profits and programmers who still have some of their hair.
Gaming's one of the few areas where speed is absolutely critical anyway - other than real-time and embedded use, where resources are often rather limited. For your average piece of desktop software, say a web browser, sure you want it to be responsive and fast, but you don't need to drop into assembly to do that, because most desktop systems are massively overblown in terms of power anyway.
The only reason my system's really as fast as it is is because I play games on it - yes it's nice that doing image processing is pretty nippy, but for web browsing and so forth I could get away with something half as fast (or slower). So languages like C#, Java, Perl and so on become far more feasible - but they're not really games programming languages. They're desktop languages.
Perl 6, by the way, runs on a bytecode interpreter called Parrot that's seriously, seriously fast - it'll never beat native C or C++, but it should blow Java right out the water. Muahahahaha
Key: Complain about this post
can someone help an absolute beginner in c++?
- 1: Researcher207975 (Apr 18, 2003)
- 2: Ion the Naysayer (Apr 18, 2003)
- 3: Ion the Naysayer (Apr 18, 2003)
- 4: 26199 (Apr 18, 2003)
- 5: Researcher207975 (Apr 18, 2003)
- 6: DoctorMO (Keeper of the Computer, Guru, Community Artist) (Apr 19, 2003)
- 7: 26199 (Apr 19, 2003)
- 8: MaW (Apr 19, 2003)
- 9: 26199 (Apr 19, 2003)
- 10: Peet (the Pedantic Punctuation Policeman, Muse of Lateral Programming Ideas, Eggcups-Spurtle-and-Spoonswinner, BBC Cheese Namer & Zaphodista) (Apr 19, 2003)
- 11: 26199 (Apr 19, 2003)
- 12: Peet (the Pedantic Punctuation Policeman, Muse of Lateral Programming Ideas, Eggcups-Spurtle-and-Spoonswinner, BBC Cheese Namer & Zaphodista) (Apr 19, 2003)
- 13: 26199 (Apr 19, 2003)
- 14: Ion the Naysayer (Apr 19, 2003)
- 15: MaW (Apr 19, 2003)
- 16: Peet (the Pedantic Punctuation Policeman, Muse of Lateral Programming Ideas, Eggcups-Spurtle-and-Spoonswinner, BBC Cheese Namer & Zaphodista) (Apr 19, 2003)
- 17: Peet (the Pedantic Punctuation Policeman, Muse of Lateral Programming Ideas, Eggcups-Spurtle-and-Spoonswinner, BBC Cheese Namer & Zaphodista) (Apr 19, 2003)
- 18: DoctorMO (Keeper of the Computer, Guru, Community Artist) (Apr 19, 2003)
- 19: Ion the Naysayer (Apr 20, 2003)
- 20: MaW (Apr 20, 2003)
More Conversations for The H2G2 Programmers' Corner
Write an Entry
"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."