Messing with c++

I’ve been coding with Java for about year and I would like to learn also c++. I have installed Dev-c++ and I can do “hello world” and some other small programs.

Right now I am just wondering that is there some kind of similar api for c++ like we have this to java --> http://java.sun.com/javase/6/docs/api/

“Java” is a language, an API, and a virtual machine. C++ is just a language, and it does not have anything equivalent to the Java API. There are many libraries available for C++ that do the same things as the Java API, both proprietary and free. This is why so many developers use tools like Microsoft Visual C++, which includes both the C++ compiler and a huge set of libraries such as .NET.

Not quite. For any C language to call itself C, has to provide a set of ANSI standard libraries. However, that does not provide a windowing environment. You might find it easy to SDL with Dev-C++ if you are just going to be doing games.

If you want some good API for c++ go for the QT framwork, which is similar in scope and sometimes philosophy to the java SE API.

Thanks to everyone for your answers, I’m getting wiser all the time.

I should have qualified that I was speaking in little white lies. The ANSI libraries are not really comparable in scope to the Java APIs, in my opinion. That comment will get me flamed by system programmers…

By the way, if you want to write effective C++, I recommend “Effective C++” by Scott Meyers.

  1. Dev-Cpp is ancient and IIRC no longer supported. Go get yourself a decent compiler and IDE. Visual Studio Express is free to download ( http://www.microsoft.com/express/ ). Alternatively try Code Blocks or Eclipse CDT.

  2. CppReference ( http://www.cppreference.com/ ) covers the C++ standard library. As can see it’s tiny compared to the Java SDK. You might also want Boost ( http://www.boost.org/ ) which provides a lot of stuff which really should be in a standard library.

  3. For a windowing API you’ll have to go with yet another library. Qt is popular and IIRC cross platform. Or you can write platform specific Win32 / X / Mac code. Or if you just want something simple (ie a window to draw on) then you can try SDL.

  4. The standard C++ bible for beginners is The C++ Programming Language ( http://www.amazon.com/C%2B%2B-Programming-Language-Special-3rd/dp/0201700735/ref=pd_bbs_sr_2?ie=UTF8&s=books&qid=1199216934&sr=1-2 ).

Yeeesshh,

I’ll have to check which of these books can I find from my home towns library. Atleast “C++ Programming Language” by Stroustrup is available there, both in english and finnish so I guess I’ll borrow (loan?) that finnish version, even though some times translators make some bad mistakes translating programming books (honestly, why they have to translate names of variables in code examples? The worst thing is that some variables are not all translated and the example program doesn’t work!).

I have already bought "C programming language"by Kernighan & Richie (from flea market, cost 1€).

Does some kind of Java bible exist? Is it “Java Programming Language” by Arnold, Gosling and Holmes?

Even John Romero recommends that Visual c++, so it looks like the best option for a beginner like me.

Be careful going the Visual C++ route. Microsoft is great at bastardizing C++. Managed C++ (and whatever they are calling it now) is not standard C++ at all. If you go the MS route and start to look for C++ help, you’ll be floating in a sea of Managed C++, ATL, MFC, etc etc. It really gets polluted.

IMO you’re better off going with something like g++ and a good text editor, or investigating how well eclipse supports C++ these days.

And also be careful, C and C++ are not the same thing. C++ is a superset of C, but the two languages should be approached very differently.

Okay…

One thing that I would like to have is IDE and comiler in same thing. I never get anything to work when I try to add compiler to ide. For example trying to add cygwin to netbeans.

Dos eclipse have some kind of compiler in it?

The documentation is a little awkward if you’re not expecting it, but VS still supports regular C++ as long as you choose the right project type. And ATL and MFC are still regular C++, not managed.

[quote]And also be careful, C and C++ are not the same thing. C++ is a superset of C, but the two languages should be approached very differently.
[/quote]
Technically C++ is not a superset of C any more. It’s possible to write valid C code which isn’t valid C++ code.

What is the “right” project type then?

In VS2003 all the managed C++ projects are grouped under a “.NET” folder and labled as using managed C++. The layout may have changed in 2005 or 2008 though - just avoid ones which mention managed code or .NET and you should be fine. “Win32 Console Project” or “Makefile project” is probably what you want if you’re after something bare bones.

Well, yeah. But .NET would potentially confuse someone new to C++, especially if he started googling around and/or asking on the MSDN forums.

Yeah. But I wouldn’t wish ATL or MFC on a veteran C++ developer, let alone a newbie :slight_smile:

My point is MS pushed and bent C++ so much to try and reach their goals it almost doesn’t feel like the same language anymore. Pure ISO C++ with some simple libraries to help any platform specific issues is a much nicer experience. C++ is a really nice language in its own right, and it’s refreshing and nice to be able to harness some of the power if offers. But IMO, that only really applies if you can experience C++ in the way it was intended, and I strongly argue MS ruins that quite a bit.

If you are running Windows then Visual Studio is the only IDE to bother with for C/C++.

It was brain-dead idiotic for the Netbeans team to require cygwin/gcc/MingGW on Windows because it is absolute crap on the Windows platform and no professional developer would consider it for a second. On Windows everyone uses Visual Studio and the Microsoft complier, or if they really need that extra bit of performance, they use the Intel compiler for their release builds (still with Visual Studio).

On other platforms you have more options, but on Windows, Visual Studio is the only reasonable option.

I’ve been using Netbeans for C developement for about a month now and I’m perfectly happy with it. Haven’t noticed any problems with cygwin.

I think they (netbeans devs) were trying to support a ‘standard’ c/c++ development model (makefile centered) which I appreciate since I’m not writing windows specific code. I think this is the case for most anyone who would use something like Netbeans or Eclipse for c/c++ development in place of vis studio; I want my code to compile on linux/mac/windows with minimum hassle.

Well, I also have Ubuntu so what kind of good IDEs and compilers do we have for linux?

Code::Blocks gets recommended a lot, but I havn’t tried it myself.

I can’t think of anything more uninteresting than C++. The problem is that it follows the same paradigm as Java, it adds nothing, just some low-level crap. It is not an improvement, it is just manual labor, like a civil construction worker carrying bags of cement on his back.

Do yourself a favor and learn something that might change the way you think about software. Learn Lisp. I guarantee that you will look towards your Java programs or even C++ programs a lot differently and will understand what some people see of so interesting in it.

You are not EA, so don’t think like EA. If somehting works for big studios not necessarily it will work for small ones.

I’m employed as a game developer and i’m coding in c++. I hate it - god awful language. It’s such a fucking mess. And I come from a background of programming C for just under two decades and C++ for at least a decade.

C++ is okay only if you write ALL the code you use by yourself or work with a team who agree to strictly use a subset of the language… Working with other C++ coders and APIs, you end up with impedance mismatch between code styles - some people write templated shite, some people do OO, some people write C++ as if it’s C. All these different styles don’t mesh well and you end up fighting the language just to do really simple stuff.

I personally think that C++ is a mess. They should scrap it and start again. The D programming language is a reasonable example of what C++ ought to have been.