tags:

views:

215

answers:

6

I recently started C++. I am using PHP right now and decided to take a look at C++. Web programming had me working with a couple of languages, with a couple of people. I wanted to do programming where I only had to bother with one language and create small utility apps (mostly not web-based). I wanted a compiled, strongly-type language without memorizing a tome of classes. Basically I wanted to learn C++ for the following:

  1. mobile programming (I don't ever want to go touching Java, and I don't have a Mac for Objective C or IPhone SDK)
  2. small desktop apps like DTRs, POSs
  3. creating small desktop-based games
  4. creating small Air-like applications that can access the web for additional content

I heard that C++ is not beginner-friendly and is mostly used for huge projects with lots of calculations and fine details (like 3D games). Is it practical or even possible for me to use C++ for the above cases? (Sorry, I haven't delved on C++ that much yet, so aside from "huge, monolithic project", I don't know any other uses for it)

A: 

For 2, 3 and 4, I recommend C# over C++, for the reasons I wrote here.

About 1, you can do iPhone development with .NET but I've never tried it and I don't know how viable it is.

Edit
To answer your actual question: yes, it's totally practical to write small and large desktop apps in C++. Especially if you use quality tools like Visual Studio and Qt. It's just that I think it'd waste a lot of your time for no reason, unless you intend to go into professional game development eventually.

Stefan Monov
iPhone development with .NET is probably banned now.
eman
I'm pretty sure it is as it requires an additional runtime environment (MonoTouch).
Timo Geusch
I thought you were restricted to using Java on the iPhone per Ming the Merciless
Khorkrak
@Khrokrak: only C/C++/Obj-C on the iPhone.
Nick Bedford
+2  A: 

You can certainly use C++ in all the areas you mention, though whether it is best of breed for any of them is open to debate. C++ is very large and complex language, and requires a fair bit of effort to get up to speed on. If I were you, I would pick one of the areas you mention that you are most interested in, and then find out which language(s) are best suited for that area and learn that.

If you are set on learning C++ you will need to read at least one book on it - you cannot learn it from internet resources alone. See this question http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list for a book list.

anon
+1  A: 

The only one of your four use cases that poses a real problem is mobile. You'd have to find a mobile platform that allows use of C++. The last such platform I used was the original Palm OS. I suppose WinCE is another, but I heard that with Phone 7 they're moving to Silverlight for "native" apps. You're obviously already aware that the requirement to use C++ also rules out Android and iPhone. This trend toward managed languages on mobile platforms seems hard to stop.

As for "not beginner friendly", that may be true in a comparative sense, but since you're already a programmer, you're not a beginner any more. :) C++ isn't the best choice for "first programming language" but it's fine for second or third.

Warren Young
Symbian OS (probably most mature smartphone os with biggest marketshare worldwide) is written in c++ so that covers that point. Perhaps more useful thoigh would be to look at Qt which is basically c++ with a few additions and can do all you ask for and supports symbian, maemo, meego, linux, windows etc. It also has a very impressive new scripting language called Qt quick which is worth a look.
Dynite
can I go straight to learning Qt or must I learn C++ before I delve into it?
Ygam
A: 

On the droid you can use other languages aside from Java - check out their ASE (Active Scripting Environment). C++ / C should really only be used when you have no other choice - i.e. speed critical code, operating systems etc. It's very easy to make a mistake that's difficult to diagnose and there are lots of task where it'll take way longer than it should to write and odds are others have already done so and done it way better - reinventing the wheel is bad. If it interests you though by all means learn and eventually you may master it. It's an excellent skill to have.

It's also not a completely object oriented language however, it's a hybrid one that supports most object oriented features, but some such as inheritance and polymorphism are a bit awkward to deal with in C++ - for example you have to define methods as virtual in base classes in order to be allowed to redefine them in subclasses - sort of like predicting the future - will this method every be desired to be redefined by an inheritor? Really what happens in that case is you make the base class method virtual later on to enable it to be redefinable - that is if you happen to have access to the source code to do just that - if not then oh well. For an example of this confusing stuff in C++ and other gotchas: Pitfalls

Look at other languages such as Ruby or Python - in particular Stackless Python where a combination of it and C++ (used where necessary) was used to create EVE Online as well as the functional languages such Erlang and Haskell.

Khorkrak
A: 

I went to C++ from PHP like you, but I was more interested in 3D games and such. Now I have moved on to C# and find it much more enjoyable than C++.

As for your specific areas of interest however, C++ is certainly an option but C# may be better.

Mobile programming with C++ is probably not a good idea. I know it's possible with NDKs and such but for a beginner it's probably not so good. For iPhone development, other than the official SDK, the next best option is the (commercial) MonoTouch framework from Novell. However, you may still need a mac to deploy (I don't know). In terms of Android, if you don't want to touch Java (don't blame you) I believe a C# framework (similar to MonoTouch) is in development and other languages may be available. Other platforms? No idea.

Small desktop apps is also very possible with C++. Assuming you're running Windows, you can use the Win32 API (pain) or the C++/CLI API (better). You could also use a different GUI framework like Qt, wxWidgets or GTK+ which are all also supported on other platforms. Again coming back to C#, GUI development using GTK# in MonoDevelop is so much fun. Having used WinForms in Visual C# Express back in my Windows days, I can say that I now enjoy the process whereas I didn't before.

Games are my main area of interest and the reason I originally picked up C++. Seeing as you've said small and desktop-based, using C++ for performance reasons is way overkill IMO. You could make a decent, fun, playable game in Python using pygame without the pain of using a language like C++. In C# (yes, I'm trying to sell it to you) you could create awesome games using the XNA framework from Microsoft or other frameworks like (my personal favorite) OpenTK.

Rich internet applications. C++ is probably not the right tool to use here. It's certainly possible but seeing as C++ has no standard networking library, you would have to figure some of this stuff out yourself. C# may not be the right tool either but it makes it a little easier. There are other options as well (like Python) but it's not something I know much about.

Despite what I've said about it, I still think C++ is a good language to learn. It teaches you about lower-level things you never think about in PHP land. If you want to learn it, the book that really helped me was "C++: A beginners guide" by Herbert Schildt and also "Programming" by Bjarne Stroustrup.

Tom Savage
Not Schildt, please. Commonly thought to be the worse book on C++ ever.
anon
I never heard any complaints about it or have any myself. For someone coming from PHP, I thought it was great. What is it about that book that makes it so bad?
Tom Savage
I have been notably unhappy with python-based desktop apps, they always seem slow to me.
Paul Nathan
A: 

Yes, your use cases can all be done with C++, more or less (YMMV on mobile devices).

To some degree or another, a language like C# will be more rapid to develop in, however.

In my opinion, once you get away from the straight-up form design features and hack for a while in a language & application, language feature comparisons begin to diminish in meaningfulness.

I recommend C++ as a first "heavyweight" language; see here for my most recent discussion on it.

Paul Nathan