Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: C++ programing  (Read 3704 times)

0 Members and 1 Guest are viewing this topic.

tommy

  • Guest
  • Trade Count: (0)
C++ programing
« on: December 24, 2006, 12:04:57 am »
Anyone into this sort of thing?

I was looking to learn about making plugins for hl2 and wondered if anyone had any good tutorials as where to get started.

Is it possible to just "get started" with really no knowledge of what I'm doing?

ChadTower

  • Chief Kicker - Nobody's perfect, including me. Fantastic body.
  • Trade Count: (+12)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 38212
  • Last login:June 22, 2025, 04:57:38 pm
Re: C++ programing
« Reply #1 on: December 24, 2006, 10:22:37 am »

There are hundreds of good C++ books out there.  All the way from "I'm an expert and just need the advanced C++ preprocessor commands again" to "my mouse tastes bad - help me".

C++ isn't the easiest road to take into programming but I'd say it's a good one.

Grasshopper

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2380
  • Last login:March 04, 2025, 07:13:36 pm
  • life, don't talk to me about life
Re: C++ programing
« Reply #2 on: December 24, 2006, 12:57:44 pm »
I'd say that C++ is one of the hardest, if not the hardest of the commonly used languages to learn. However, it's also one of the most useful.

If you are going to take the plunge then I'd suggest you learn C first as a stepping stone. The best book on C is still the original one by Kernigan and Ritchie.

When picking books on programming, a good rule of thumb is to avoid the ones that are either very thick, or have an overformatted look.
"Patriotism is the last refuge of the scoundrel." - Samuel Johnson

AtomSmasher

  • I'm happy to fly below Saint's radar
  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3884
  • Last login:September 02, 2022, 03:50:10 am
  • I'd rather be rich than stupid.
    • Atomic-Train
Re: C++ programing
« Reply #3 on: December 24, 2006, 12:59:56 pm »

There are hundreds of good C++ books out there.  All the way from "I'm an expert and just need the advanced C++ preprocessor commands again" to "my mouse tastes bad - help me".

C++ isn't the easiest road to take into programming but I'd say it's a good one.
Agreed.  Your best bet might be to try and find HL2 specific tutorials since thats what your going to be working with.  Most game engines use a scripting language similar to C++, but isn't actually C++ so you may want to double check what you need to learn.

sphetr2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 316
  • Last login:February 08, 2009, 06:35:00 pm
  • black and white album
Re: C++ programing
« Reply #4 on: December 24, 2006, 04:14:22 pm »

If you are going to take the plunge then I'd suggest you learn C first as a stepping stone. The best book on C is still the original one by Kernigan and Ritchie.

Meh, are you sure about that? I've had no trouble learning C++ and have never learned a programming language before.

I agree with AtomSmasher completely, too.

SithMaster

  • Lets see how happy you are when you need to use a lawn mower and it keeps turning off when you want to cut up zombies.
  • Trade Count: (+4)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1781
  • Last login:January 12, 2014, 03:52:59 pm
  • The brightest light casts the darkest shadow.
Re: C++ programing
« Reply #5 on: December 24, 2006, 04:48:58 pm »
try this link i havent been here in a while but last time i looked it showed some useful info.

learning a langauge depends entirely on the way you learn it.  im trying to learn C and when i looked around at the books at borders they were all not good enough.  Stay away from the dummies books.  also dont try and find a book specifically for game deving but first start with something broader (like the basics).  I had to special order my C book since my library that had it doesnt anymore (maybe a year between the last time i took it out) and they claim it doesnt exist.

try checking you local library for some books on C++.

sphetr2 did you learn C++ in school or on your own time?
Back in MY day we lived on the moon and we had to build a rocket ship from scratch to get to the Earth before we suffocated.

hypernova

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2753
  • Last login:November 25, 2016, 12:52:48 pm
Re: C++ programing
« Reply #6 on: December 24, 2006, 11:34:32 pm »
Whatever you do, don't try to talk to Macintosh about that.  I don't think he cares. :)
I'll exercise patience when you stop exercising stupidity.
My zazzle page.  I've created T-shirts!

AtomSmasher

  • I'm happy to fly below Saint's radar
  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3884
  • Last login:September 02, 2022, 03:50:10 am
  • I'd rather be rich than stupid.
    • Atomic-Train
Re: C++ programing
« Reply #7 on: December 25, 2006, 12:47:46 am »
try this link i havent been here in a while but last time i looked it showed some useful info.

learning a langauge depends entirely on the way you learn it.  im trying to learn C and when i looked around at the books at borders they were all not good enough.  Stay away from the dummies books.  also dont try and find a book specifically for game deving but first start with something broader (like the basics).  I had to special order my C book since my library that had it doesnt anymore (maybe a year between the last time i took it out) and they claim it doesnt exist.

try checking you local library for some books on C++.

sphetr2 did you learn C++ in school or on your own time?
This web page has a bunch of free programming books, most of which are older books, but they still contain a lot of useful info.  http://freecomputerbooks.com/

Also, reading the reviews of the books on Amazon often gives a good impression of how good a book is.  There are definately a lot more bad programming books then there are good ones.

Although the question wasn't directed at me, I learned C++ in school, but they taught us Java first.  Actually my progression of languages went Basic on my own, Turbo Pascal in highschool, Java, C++, Perl, and half dozen other languages in college. 

IMO, although object oriented languages can be difficult for beginners to grasp, C++ is often not used in a non OO manner in beginner books.  Since he will be working with HL2, and that no doubt heavily relies on multiple objects, learning C++ from the beginning would probably be best, assuming of course that he decides not to use HL2 specific tutorials.
« Last Edit: December 25, 2006, 12:52:06 am by AtomSmasher »

sphetr2

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 316
  • Last login:February 08, 2009, 06:35:00 pm
  • black and white album
Re: C++ programing
« Reply #8 on: December 26, 2006, 01:14:29 pm »
sphetr2 did you learn C++ in school or on your own time?

I'm taking (actually, took, the semester is over) a course in school on C++. Next semester we do java.

I did learn BASIC on my own, like AtomSmasher.  ;D

tommy

  • Guest
  • Trade Count: (0)
Re: C++ programing
« Reply #9 on: December 26, 2006, 07:31:30 pm »
Thanks for all the links and feedback guys, i think i'll give it a shot.

MYX

  • Wiki Master
  • Trade Count: (0)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 1527
  • Last login:September 18, 2020, 05:00:22 pm
  • Even Jesus loves Donkey Kong!
    • MYX Digital Blog
Re: C++ programing
« Reply #10 on: December 27, 2006, 12:33:10 pm »
Check THIS out. It is C++ Express. It is intended to get you going on the learning side and then you can step up the the grown up version. I am working on VB Express.
They also have training videos you can watch.

I think it is a good place to get your feet wet rather than paying a brazillion dollars for software you might decide later you don't want. 
M    Y    X

BLACKOUT  - Finally rewritten - http://blog.myxdigital.com/
Original BLACKOUT thread - http://forum.arcadecontrols.com/index.php?topic=48239.0

ChadTower

  • Chief Kicker - Nobody's perfect, including me. Fantastic body.
  • Trade Count: (+12)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 38212
  • Last login:June 22, 2025, 04:57:38 pm
Re: C++ programing
« Reply #11 on: December 27, 2006, 12:51:37 pm »

What brazillion dollar software?  There are so many strong and free C++ compilers out there he could drown in them.

barnes

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 51
  • Last login:January 10, 2008, 10:15:29 pm
Re: C++ programing
« Reply #12 on: December 27, 2006, 03:38:15 pm »
If you want to make HL2 mods and plugins, check out http://www.kaosnyrb.co.uk/index.html that will get you started programming for HL2. Theres also a list of good C++ lessons online. I learned using Sams Teach Yourself C++ in 21 Days, which is a good book if you wanted a book.

shardian

  • Saint is the evil mastermind
  • Trade Count: (+23)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 9218
  • Last login:August 21, 2015, 03:11:31 pm
  • Friends don't let friends build frankenpanels...
Re: C++ programing
« Reply #13 on: December 27, 2006, 04:08:30 pm »
I used the bloodshed c++ package when I took c++ in college.

http://www.bloodshed.net/devcpp.html

Once you have an idea of what you are doing, c++ can be pretty neat.

PS - its all free.
« Last Edit: December 27, 2006, 08:38:36 pm by shardian »

tommy

  • Guest
  • Trade Count: (0)
Re: C++ programing
« Reply #14 on: December 27, 2006, 10:52:21 pm »
If you want to make HL2 mods and plugins, check out http://www.kaosnyrb.co.uk/index.html that will get you started programming for HL2. Theres also a list of good C++ lessons online. I learned using Sams Teach Yourself C++ in 21 Days, which is a good book if you wanted a book.

Thanks for that link, that link got me going in a good direction.  :cheers:

jbox

  • BYOAC Poet Laureate
  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1032
  • Last login:November 30, 2007, 08:00:54 am
Re: C++ programing
« Reply #15 on: December 28, 2006, 01:50:30 am »
And, to save you a few grey hairs one day, sooner or later you'll have a method which returns an array that looks like this:

int[] wrong() {
  int[20] bob;
  ...
  return bob;
}

and it wont work. In my experience this is probably one of the most annoying errors in C/C++ for beginners because it looks sensible, it often appears to work fine for people over several runs, and then when they finally realise something is wrong they usually look in the wrong place. And the tricky part is trying to explain *why* it's wrong to people who don't know what a "stack" or a "heap" has to do with getting their code to do what it looks like it should do. For the record the correct code should be:

int *right() {
  int *bob;
  bob = new int[20];
  ...
  return bob;
}

Almost all of the other things you will screw up are usually obvious *where* you screwed up even if you don't know why, while this one is just one of those lovely little "gotchas" waiting to catch the unwary...
Done. SLATFATF.

Grasshopper

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2380
  • Last login:March 04, 2025, 07:13:36 pm
  • life, don't talk to me about life
Re: C++ programing
« Reply #16 on: December 28, 2006, 06:59:19 am »
Jbox's example illustrates one of the problems I have with C++ as a language - its mix of high level and low level concepts.

C was originally intended to be a sort of portable assembler for Linux. It's an excellent language (possibly the best) but to use it effectively you have to have some idea of what's going on behind the scenes.

C++ is essentially C with OOP extensions added on. There are a few minor differences but 95% of C code seems to run on a C++ compiler without modification.

The problem is that Object Orientated Programming is a high level concept that doesn't really fit in with C's get-under-the-hood philosophy. Because of this design mismatch C++ ended up being a messy over-large language with a lot of murky areas.

Thanks to poor design C++ is, in my opinion, an unnecessarily hard language to learn. If Stroustrup (sp?) had designed an OOP language from scratch instead of basing it on C he would have ended up with a smaller, cleaner, and more tightly defined language.

It was also a missed opportunity for C enthusiasts. There was definitely room for an improved C but C++ wasn't it.

Having said that, C++ is still the best OOP language to learn simply because it's so widely used. It's also very powerful once you get past the steep learning curve.
"Patriotism is the last refuge of the scoundrel." - Samuel Johnson

Chris

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4574
  • Last login:September 21, 2019, 04:59:49 pm
    • Chris's MAME Cabinet
Re: C++ programing
« Reply #17 on: December 28, 2006, 08:27:32 am »
The problem with learning C first is that you do things in C and C++ in such dramatically different ways that you need to "un-learn" some stuff to go to C++.

--Chris
DOSCab/WinCab Jukebox: http://www.dwjukebox.com

CCM

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1274
  • Last login:August 08, 2020, 10:08:27 am
Re: C++ programing
« Reply #18 on: December 28, 2006, 10:32:42 am »

C was originally intended to be a sort of portable assembler for Linux. It's an excellent language (possibly the best) but to use it effectively you have to have some idea of what's going on behind the scenes.



C has been around much longer than Linux.  It was developed for Unix back in the early 70's.

ChadTower

  • Chief Kicker - Nobody's perfect, including me. Fantastic body.
  • Trade Count: (+12)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 38212
  • Last login:June 22, 2025, 04:57:38 pm
Re: C++ programing
« Reply #19 on: December 28, 2006, 10:46:04 am »

C was also designed for writing system software, i.e. the operating system and hardware level binaries.  It was not written to be "user friendly".

I dramatically disagree that you have to "unlearn" anything to move from one language to another.  Ever.  All concepts do not apply or work optimally in all languages but in 15 years of coding I have never intentionally unlearned anything I have used.

C is procedural (often specifically structural like Pascal or Ada).  C++ is procedural or object oriented (in a generic manner, again like Ada).  The point behind the way C++ works is to provide abstraction from the mechanics of the compiler and preprocessor while still providing most of the system level functionality of C (that a more fully abstracted language like Java doesn't provide).  The abstraction is what makes it difficult for a beginner to write advanced C++ since it's not providing the stack/pointer and memory management for you yet you don't always have to do those things yourself like in C.  When/where you need to do those things, and when/where you do not, can be confusing and ambiguous for quite some time to a beginner (jbox's example is a perfect one for this).

Chris

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4574
  • Last login:September 21, 2019, 04:59:49 pm
    • Chris's MAME Cabinet
Re: C++ programing
« Reply #20 on: December 28, 2006, 10:58:50 am »
I dramatically disagree that you have to "unlearn" anything to move from one language to another.  Ever.  All concepts do not apply or work optimally in all languages but in 15 years of coding I have never intentionally unlearned anything I have used.

C is procedural (often specifically structural like Pascal or Ada).  C++ is procedural or object oriented (in a generic manner, again like Ada). 
Well, perhaps I should qualify that to say that I've found it difficult for me, to the point where I'm still writing in C even though I know my main project (the jukebox) would probably be better served by C++.  But I have 25 years of procedural programming inertia to overcome. I really should convert the jukebox to C++ just to force myself to use it and get out of my comfort zone.

--Chris
--Chris
DOSCab/WinCab Jukebox: http://www.dwjukebox.com

ChadTower

  • Chief Kicker - Nobody's perfect, including me. Fantastic body.
  • Trade Count: (+12)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 38212
  • Last login:June 22, 2025, 04:57:38 pm
Re: C++ programing
« Reply #21 on: December 28, 2006, 11:19:07 am »

Fair enough.  I have always had to bounce between all types of languages from day to day so there isn't any inertia for me.  On any given day I'll be knee deep in PERL, C++, Java, or any number of other languages depending on what I'm doing that day.  It's a pain in the ass sometimes but it forced me to develop a full understanding of the concepts rather than the applications of each language.

Grasshopper

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2380
  • Last login:March 04, 2025, 07:13:36 pm
  • life, don't talk to me about life
Re: C++ programing
« Reply #22 on: December 28, 2006, 12:15:34 pm »
C has been around much longer than Linux.  It was developed for Unix back in the early 70's.

Oops, my bad.

I've got into the bad habit of using the terms Linux and Unix interchangeably.
"Patriotism is the last refuge of the scoundrel." - Samuel Johnson

Grasshopper

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2380
  • Last login:March 04, 2025, 07:13:36 pm
  • life, don't talk to me about life
Re: C++ programing
« Reply #23 on: December 28, 2006, 12:39:34 pm »
The problem with learning C first is that you do things in C and C++ in such dramatically different ways that you need to "un-learn" some stuff to go to C++.



The problem is that even if you've chosen to use C++ as an OOP, you're still going to come across a lot of code written by people who are using C++ as basically C with a few bolt on extras. So you still have to know about the C way of doing things.
"Patriotism is the last refuge of the scoundrel." - Samuel Johnson

ChadTower

  • Chief Kicker - Nobody's perfect, including me. Fantastic body.
  • Trade Count: (+12)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 38212
  • Last login:June 22, 2025, 04:57:38 pm
Re: C++ programing
« Reply #24 on: December 28, 2006, 12:42:31 pm »

You have to understand both procedural and object oriented programming to be an effective professional anyway.

Kaytrim

  • I'm too nice a guy
  • Trade Count: (+4)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2095
  • Last login:September 22, 2015, 04:11:30 pm
Re: C++ programing
« Reply #25 on: December 28, 2006, 01:00:10 pm »

What brazillion dollar software?  There are so many strong and free C++ compilers out there he could drown in them.

M$ Visual Express editions are free to use.  A compiler is a compiler no matter who makes it they still convert your English like code to machine language.  An Integrated Development Environment (IDE) makes writing code easier and some are better than others.  Personally I like Microsoft's IDE but to each his own.

ChadTower

  • Chief Kicker - Nobody's perfect, including me. Fantastic body.
  • Trade Count: (+12)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 38212
  • Last login:June 22, 2025, 04:57:38 pm
Re: C++ programing
« Reply #26 on: December 28, 2006, 01:15:18 pm »

Actually, all compilers are not the same nor are they all created equal.  Two different compilers could create binaries that act differently at the machine level.  One could actually do something slightly mechanically different than another, or one could be better at optimizing certain types of algorithms than another.  A compiler could have more or less preprocessing functionality.  Some are more forgiving of certain "violations" than others are and they vary pretty widely on debugging facilities.

Generally, any officially released compiler will do for an average user, but some are just better than others like anything else.

You're right, though, that most of the time the real bang for the buck differences are in the IDEs.  I'm usually more of a raw text editor guy because so few IDEs handle a wide enough range of languages to be useful to me.

Chris

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4574
  • Last login:September 21, 2019, 04:59:49 pm
    • Chris's MAME Cabinet
Re: C++ programing
« Reply #27 on: December 28, 2006, 02:04:35 pm »
The problem is that even if you've chosen to use C++ as an OOP, you're still going to come across a lot of code written by people who are using C++ as basically C with a few bolt on extras. So you still have to know about the C way of doing things.
Excellent point.
--Chris
DOSCab/WinCab Jukebox: http://www.dwjukebox.com

jbox

  • BYOAC Poet Laureate
  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1032
  • Last login:November 30, 2007, 08:00:54 am
Re: C++ programing
« Reply #28 on: December 28, 2006, 06:25:08 pm »
The problem is that even if you've chosen to use C++ as an OOP, you're still going to come across a lot of code written by people who are using C++ as basically C with a few bolt on extras. So you still have to know about the C way of doing things.
The corollary states that you can write FORTRAN in any language remember?  ;D

Now, if you want to program in a language that's really hard to write badly, that's why the DoD invented Ada. Unfortunately it was so good at tryng to force you do the right thing that nobody wanted to use it.  :hissy:
Done. SLATFATF.

Buddabing

  • Wiki Master
  • Trade Count: (0)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 1845
  • Last login:February 12, 2015, 02:51:45 pm
  • I'm a llama!
Re: C++ programing
« Reply #29 on: December 28, 2006, 07:39:16 pm »
IMO plain C and C++ are good for different types of applications. Plain C, on the one hand, is good when you have mostly static allocation of memory and very little gets dynamically created or destroyed. This applies to most command line tools, emulators, Chris' jukebox, and so on. IMO it was a mistake writing Daphne in C++.

On the other hand, C++ fits well with an application in which objects are constantly being created and destroyed, and where the object-oriented philosophy fits well. Take a computer game like Diablo II, for example. You have auras, weapon effects, monsters spawning, treasure dropping, and similar events going on all the time. It's nice to have a object::~object() function instead of a zillion calls to free(). You might miss one and get a memory leak.

I have changed my nickname to "Cakemeister". Please do not PM the Buddabing account because I do not check it anymore.

Please read the wiki!

jbox

  • BYOAC Poet Laureate
  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1032
  • Last login:November 30, 2007, 08:00:54 am
Re: C++ programing
« Reply #30 on: December 28, 2006, 08:00:54 pm »
Disclaimer: all my heavy lifting is done in Java because I tend to build massive graphs and then toss them away at a moments notice.

I thought you could get automagic garbage collection for C++ if you wanted it? The main problem with GC in the original C was people storing pointer data in non-pointer data types, so no analyser would ever know for sure what was going on. Presumably for most non-OS applications, you shouldn't be doing that kind of black magic in C++, and hence it would be easy to add a GC to the runtime if you needed it? Some of the modern GC techniques are pretty damn spiffy too if you have the standard "older objects" retention pattern that most programs do.
Done. SLATFATF.