Hey. I have a quick question. [Will it be extremely hard to learn C++ on my own]

Discussion in 'Indie Basics' started by Mashew, May 16, 2007.

  1. Mashew

    Mashew New Member

    Joined:
    May 14, 2007
    Messages:
    53
    Likes Received:
    0
    Hi, first off. I am new to the forum! Hi everyone, been great to read your posts.

    Ok, now for my question. Will it be extremely hard to learn C++ on my own with books and online sources? Will it take a very long time? How did you learn C++/C?

    EDIT: I do know basic C++ and basics of other languages. So, I do some programming, I just want to make sure I ain't getting into to something that is extremely hard to do alone.
     
  2. Jesse Aldridge

    Original Member

    Joined:
    Apr 19, 2005
    Messages:
    222
    Likes Received:
    0
    1.) I took a Computer Science course in high school and learned everything else on my own. I didn't find it very hard to learn. I think you can definitely learn a programming language online.
    Although... I've known people who could never learn to program anything if they had all the time in the world... so... good luck!

    2.) Learning the language is the easy part. Learning how to turn ideas into reality is the hard part.

    3.) C++ is a thing of the past. Start with Java or Python or Ruby or Flash. Unless you're looking for a job in the mainstream industry -- it's still mostly C++ (I think).
     
  3. Mashew

    Mashew New Member

    Joined:
    May 14, 2007
    Messages:
    53
    Likes Received:
    0
    Next year I am taking a C++ course in school, I was just wanting to learn it during the summer or at least some so, I can just for the most part slack off. So far, C++ seems quite straight forward until you try to compile your script. -_-

    Also, the only reason that I am learning C++ is that my dad is/was a programmer and used C++ and told me that I should learn and I am just basically doing what he thinks is good.

    So, would learning C++ be a step in the right direction or the wrong direction?
     
  4. Backov

    Original Member

    Joined:
    Oct 23, 2005
    Messages:
    812
    Likes Received:
    0
    I wouldn't start with C++ tbh. Most people just use a small subset of it anyways.

    Start with a real OO language without the legacy crap - I suggest either Java or C#. (They're so close they might as well be the same language).

    Once you're comfortable with those, and the concepts of OO programming and programming in general, you can try C++. You'll go ewww, but you'll understand it and be able to learn it, and more importantly, not create hideous, incredibly hard to debug code with it.
     
  5. Game Producer

    Moderator Original Member

    Joined:
    Jan 13, 2006
    Messages:
    1,418
    Likes Received:
    1
    Then... regarding C++ learning times: it depends. If you are already familiar with some other programming languages, then you might be able to learn it pretty fast (at least enough to get things going). On the other hand, if you've never programmer before then it will take ages to learn it (well, not ages... but don't expect to master it in week.). I suppose it may take some months depending how much you need to learn, and how experienced programmer you are.

    I'd recommend taking some ready made engine to learn basics of any programming language... anything that helps you make something fast like my mini-game in 21 hours :)
     
  6. ZeHa

    Original Member

    Joined:
    Nov 19, 2006
    Messages:
    426
    Likes Received:
    0
    You could also try D (http://digitalmars.com/d/index.html), that's a language that tries to be as good as C++ in performance, but combining it with all the nice stuff from Java and C# (and of course C++) while leaving out the not-so-nice stuff of them ;)

    One advantage is that basically every C/C++ lib can be used, though it must be wrapped first. But for some very important libs this has already been done (SDL and such).

    A disadvantage is of course that it's still rather unknown, since 1.0 got final this January. But hopefully it will rise and grow, because it seems to be pretty neat.

    Well, I think if you just want to learn programming, you should start with some simple language like Python, so that you get into it, and you can learn some other languages like Java, C# and D afterwards. But if you're interested in learning C++ then it might be not a bad idea to start directly with C++ and learn at least the basics, and then perhaps move on to Java, C# or D as well. It's never wrong to have some C++ knowledge, even if you mainly use some other language.
     
    #6 ZeHa, May 16, 2007
    Last edited: May 16, 2007
  7. tolworthy

    tolworthy New Member

    Joined:
    Oct 4, 2006
    Messages:
    261
    Likes Received:
    0
    At last! A programming question where I can act like an expert!

    Answers:
    No,
    6 months (you could do it in less),
    with a distance learning course. I never visited the college.

    It sounds like you know more than I did. I started off not being able to program at all. I visited the local job centre about subsidized courses (I was unemployed at the time) and signed up for 2 home study courses. First I took Pascal for beginners (so I could learn the basic concepts, you can probably skip this part if you've programmed already), then a course in C++

    I can't claim to be an expert, that would take YEARS. But with a copy of Borland C++ builder (highly recommended) I never had an idea that I couldn't implement.

    Having said all that, I realized that the game engine I was inventing would take me about fifty years (it was VERY ambitious), so after 3 years I opted to go for a ready made game engine instead. Haven't really programmed anything advanced since then, but it was good experience.
     
    #7 tolworthy, May 16, 2007
    Last edited: May 16, 2007
  8. Andy

    Original Member

    Joined:
    Jul 29, 2004
    Messages:
    1,258
    Likes Received:
    0
    As dad of three kids myself I say you "Do what your dad recommends" :)

    Nah! Really. Do you think your dad could wish anything bad to you? You ask the recommendation here in forums from peoples who (let's say this) don't care about you at all.

    Everyone above has recommended correct things. You ask how it could be so? It's pretty easy - different peoples prefer different things. And that's why there is no any 100% solid answer for your general question.

    Pardon me for being annoying with this. ;)
     
  9. jimflip

    Original Member

    Joined:
    Aug 5, 2005
    Messages:
    75
    Likes Received:
    0
    If you can do c++ then c#, java etc are easy...doesn't work the other way round.

    D sounds interesting but you won't get a job with it.

    The way I learnt was C then C++, but I also had to walk 3 miles to school without shoes and had to write in dirt with sticks ;)

    C# is a reasonable idea, as it's very handy but you might get lost/confused in lots of microsoft gibberish. C++ is far more portable, but pointers seems to be the thing that breaks learners, if you can get your head around pointers then a lower level language like c/c++ might be for you.
     
  10. Mashew

    Mashew New Member

    Joined:
    May 14, 2007
    Messages:
    53
    Likes Received:
    0
    What would be "higher" level language?

    Also, I have been looking through sample code of C# and Java but, C++ just seems much easier in declaring things.

    Like...

    PHP:
    using System.Windows.Forms;

    using System.Drawing;

     

    class 
    MyForm:Form{

       public static 
    void Main(){

          
    Application.Run(new MyForm());

       }

      

       protected 
    override void OnPaint(PaintEventArgs e){

          
    e.Graphics.DrawString("Hello World!", new Font("Arial"35),

             
    Brushes.Blue10100);

       }

    }
    vs.

    PHP:
    #include <iostream>

    using namespace std;

    int main()
    {
      
    cout<<"HEY, you, I'm alive! Oh, and Hello World!\n";
      
    cin.get();
    }
    C++'s code is way simpler and a lot more understandable.

    What is the MAIN difference between Java/C# and C++. I just heard that C++ is somewhat more powerful but, much harder to "control". What is C#/Java's strong point(s)?
     
  11. mot

    mot
    Indie Author

    Joined:
    Oct 21, 2004
    Messages:
    439
    Likes Received:
    0
    The main difference is memory management. Java and C# manage memory
    for you - you don't have to delete unused objects. This speeds up development.

    Another difference is that C++ is usually compiled into native code, whereas
    both C# and Java are compiled into bytecode that runs on a virtual machine.
    That makes them a little slower and makes deployment a bit more complicated.

    C++ is more "powerful" - you can get more raw performance if you write
    everything the right way but it also means that it's harder for an IDE to give
    you useful hints about the code - sometimes it just gets too complex.
    C# and Java are simpler languages designed from scratch and their IDEs
    (Visual Studio and Eclipse) give you more refactoring options, more hints and
    code inspection tools.

    I recommend Java :)

    Tom
     
  12. Mashew

    Mashew New Member

    Joined:
    May 14, 2007
    Messages:
    53
    Likes Received:
    0
    Hm. I am trying a little C right now. Aren't C and Java nearly inter changable?
     
  13. HairyTroll

    Original Member

    Joined:
    Jul 29, 2004
    Messages:
    583
    Likes Received:
    0
    They are about as interchangable as a minivan and a turkey dinner.
     
  14. Mashew

    Mashew New Member

    Joined:
    May 14, 2007
    Messages:
    53
    Likes Received:
    0
    Hm. I see no difference. Lol.
     
  15. PrefixEx

    Original Member

    Joined:
    Nov 25, 2005
    Messages:
    51
    Likes Received:
    0
    Wow, I guess plain old C would be really a thing of the past :).

    Guess, I'll go back to my C code.
     
  16. oNyx

    Original Member

    Joined:
    Jul 26, 2004
    Messages:
    1,212
    Likes Received:
    0
    Sure it is... because you're comparing a command line app with a graphical one.

    Hello world in Java:
    Code:
    public class HelloWorld{
    	public static void main(String[]args){
    		System.out.println("hello world");
    	}
    }
    More like your second example:
    Code:
    import javax.swing.*;
    import java.awt.*;
    public class HelloWorld2 extends JFrame{
    	public static void main(String[]args){
    		new HelloWorld2();
    	}
    	public HelloWorld2(){
    		super("Hello World");
    		setSize(400,100);
    		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		setVisible(true);
    	}
    	public void paint(Graphics g){
    		super.paint(g);
    		g.setColor(new Color(0x0000ff));
    		g.setFont(new Font("Arial",Font.PLAIN,30));
    		g.drawString("Hello World",50,75);
    	}
    }
    @topic

    It doesn't really matter with which language you start. You will most likely switch to something else later on. Courses are nice if you haven't programmed at all yet. Other than that you're more effective with books and online resources.

    Either way... it will take some time. Be prepared for that.

    >Aren't C and Java nearly inter changable?

    Controlling the (low level) flow is pretty much the same in C, C++, Java, JS etc and the basic syntax is also similar. However, thats the really easy stuff anyways. Each language has it's own set of features, quirks and standard libraries. And that's where you'll spend your learning time.
     
  17. Mashew

    Mashew New Member

    Joined:
    May 14, 2007
    Messages:
    53
    Likes Received:
    0
    Hopefully, my last question. -_-'

    Of those who learned from an online source (Specifically Java.), Where did you learn it?

    (I have a book on Java but, I don't feel like reading 600+ pages of stuff >__<)
     
    #17 Mashew, May 17, 2007
    Last edited: May 17, 2007
  18. electronicStar

    Original Member

    Joined:
    Feb 28, 2005
    Messages:
    2,069
    Likes Received:
    0
  19. oNyx

    Original Member

    Joined:
    Jul 26, 2004
    Messages:
    1,212
    Likes Received:
    0
    600 pages? Most likely only 1/4th of that will be relevant to you and half of it won't be that interesting or necessary at first.

    Like say... Java Swing (it's a massive widget toolkit)... I got some 1300 pages book only about that. For your average tool or level editor you only need a tiny fraction of all that stuff.

    Well, the book is a good starting point. Work through the first few chapters, which cover the basics of the language and then you're free to acquire the necessary knowledge for the task at hand in whichever way you like. The book has some index for example and there is google, several online books, dedicated forums, irc channels and so on.

    Speaking of forums... for language specific questions a specialized forum is clearly the better choice. Eg game programming + Java = JGO. And there are also general game development communities, which focus more on the programming side such as gamedev.net.
     
  20. KatieL

    Original Member

    Joined:
    Nov 2, 2005
    Messages:
    44
    Likes Received:
    0
    Go and buy

    "Accelerated C++: Practical Programming by Example" by Andrew Koenig

    It's part of a series which goes into lots of detail about C++; this is the "introduction" volume. It doesn't teach you C first because C++ is not longer "C with some classes", but it does explain how to use the STL (C++'s standard class library) and other features which turn C++ from a fiddly language into a really powerful one without you having to learn all the bits of C which... you then ignore anyway because C++ programs don't do those things.

    The poster who said that "C++ -> C#/Java" being easier than the other move is right, but so are the comments about pointers. If you cannot understand pointers you're never going to get C++ stuff to work. Quite a lot of people can't seem to; personally I think this is a brain structure thing -- some people aren't born to cope with things like that in the same way that some people are born without the potential to ever do higher level maths.

    As for the timescale; You could have c++ code running in a couple of days, but it will take several months before all the keywords and structures make sense. Full-on hard-core C++ will take a LONG time to get the hang of; probably several years. A lot of people think after a couple of years, their C++ learning is done, but C++ goes a lot further than most people think it does.

    C++ is the more complicated of the languages simply because it's more expressive. You can do more in the same amount of code, but at the cost of having more "parts" to the language - templates, for instance, are not just an over complicated way of having generics. C# and Java both started out dismissing C++'s template language as overcomplicated and deciding they weren't having one. Later on, they found out that generics are actually important, so they've added them back, but proudly claim that they're "not over-complicated like C++ templates". However this ignores that C++ templates are not just a generics system -- it's actually an entire metalanguage, capable of giving C++ things like domain languages and closures and a lot of the higher level functions of languages like LISP, but without the runtime overheads.

    If you plan on being productive, don't mess about with esoteric things.

    There are lots of commercial games written in C++, Java, C# and scripting languages like python. They get chose for a good reason; they're practical for the purpose. It may be worth paying attention to that shared wisdom...

    If you have a particular framework or tool in mind, pick a language that it supports well. Don't go trying to be adventurous on your first experiments; it's hard enough using (for instance) OpenGL for the first time without also being effectively a beta-tester for the version 0.9 "Nearly complete!!" Prolog bindings for it...

    Don't dismiss python/pygame. I know it doesn't feel like "proper" programming, but you can very quickly get stuff up and running (far faster than in C++), and the potential is there to re-write speed-critical portions in C++ later.


    But in fact, really the tricky skill in all these languages is in doing OO design -- unless you can get the hang of doing OO design, the code is going to be a pain to handle in any of them. So while you're at the bookshop, pick up at least a couple of books on OOA/OOD. I can't think of any to recommend offhand. TBH, the really good OO people I've met have all learned it by a sort of osmosis and not really from textbooks. They were around while good OO was happening and they got the hang of it. I, again, suspect this is a brain structure thing and that some people are just naturally good at it but it seems to be a rather hard skill to describe on paper. That's why it's probably worth reading several viewpoints on it.
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer