• 0

C++ Compiler of choice


Question

Hey all, lately I've been wanting to learn a programming language and decided I'd like to learn C++, I've had suggestions about using Dev-C++ but I've also heard some pretty dodgy reviews due to it not being updated since 2005 and doesn't compile exes properly in some cases. I have Visual C++ 6 already installed and was wondering if this would be a better option. Also please state any better choices and why you think they're better; any tips to get started would also be apprectiated.

Thank you

-Alex

Link to comment
Share on other sites

Recommended Posts

  • 0

You need:

- an editor, to write the code. A good editor highlights the language syntax, provides suggestions as you type, shows you your errors in real-time, allows to easily navigate, provides auto-formatting, etc.

- a compiler, to convert the code into an executable

- a debugger, to analyse what your program is doing as it executes

- some method to manage all the different files of your projects and how they are built

The GCC and Autotools provide a compiler. debugger, and a build system. A simple text editor like GNU Nano, Vim, Emacs, or Gedit are enough for writing the actual code text.

I'm a big believer in understanding the tools I'm using; So with that in mind, I suggest first learning to write a simple program in a basic editor, and using the compiler (GCC) directly to build it and learn the various parameter it takes. After mastering that, and once you start working on bigger, more complex programs, the Autools should then be mastered. That's how I would approach it.

A good IDE (integrated development environment) provides all of that seamlessly. Visual Studio and Eclipse CDT are examples of C++ IDEs. MSVC and GCC are examples of compilers (they are used by the respective aforementioned IDEs).

Visual Studio doesn't and can't use the GCC or the Autotools. It's proprietary, closed source, and locked down, standards incompliant (isn't everything that Microsoft does non-standard?), and finally, is locked down to Windows.

An IDE isn't really necessary. An editor with syntax highlighting and good standards compliant documentation is sufficient really.

Link to comment
Share on other sites

  • 0

If you're just working with Windows, Visual Studio hands down. Everything included, easy to use, tons of quality help. Easy transition if you go pro or higher for some of the excellent third party tools available (CodeRush/Refactor Pro is awesome), plus integration of all the various languages/platforms in one versus a bunch of different Express installs.

Avoid C++ Builder like the plague.

Cross platform, GCC is an obvious choice for the compiler, personally a fan of Code::Blocks for the IDE, although Eclipse, Anjunta and KDevelop aren't too shabby either.. kind of a "try it out and see for yourself" sort of thing.

The only problem with that is currently I have no idea what I'd be looking for :p but all the same thanks for the heads up, currently I'm experimenting with Eclipse and V studio 2010, so far loving the layout of Eclipse, although from previous experience of V studio it was a lot simpler.

Link to comment
Share on other sites

  • 0

I'm gunna say so far the best thing I've found for a beginner would most likely be visual studio mainly because of the interactive vusal side of things, and you can individually edit the code for the individual functions, I don't know what other IDEs comparison to this function but that is very interesting (and before anyone points it out yes I did realise 'visual' probably has something to do with it :p)

p.s. Sorry I don't know the forums rules on double-posting

Link to comment
Share on other sites

  • 0

Visual Studio doesn't and can't use the GCC or the Autotools. It's proprietary, closed source, and locked down, standards incompliant (isn't everything that Microsoft does non-standard?), and finally, is locked down to Windows.

Why should they use GCC? They have their own - better? - compiler! Btw. the Visual C++-Compiler is pretty compliant with the standard (including C++0x) and GCC isn't what I would call standards compliant perse?

  • Like 2
Link to comment
Share on other sites

  • 0
Visual Studio doesn't and can't use the GCC or the Autotools. It's proprietary, closed source, and locked down, standards incompliant (isn't everything that Microsoft does non-standard?), and finally, is locked down to Windows.

Actually it can use GCC (granted it's far from optimal, see one post up), although on the Windows platform I can't think of a good reason why I would.

Link to comment
Share on other sites

  • 0

Thank you again, atm I'm looking for a good place to start though :p don't know what to do as the very basics, what I should learn etc.

Basically I need to find out how to start, if anyone has any advice from when they started thank you.

Well, I can give you an idea of how I would start off on Ubuntu. You might need to adapt this to whatever platform you are using:

1. Open up a terminal (applications->accessories->terminal).

2. Paste: sudo apt-get install build-essential (assuming it's not already installed). This will install GCC etc.

3. In the same terminal window, type nano main.cpp (C++) or nano main.c (Plain C) (replace with 'gedit' if you prefer a gui , although for a basic hello world, they are pretty much the same.

4. Write a test entry point function (this is the function that the OS will first call in your program). For example:

/* main.c In C */
#include <stdio.h> /* this imports the printf function and other input/output routines from the standard library */

/* this is how a standard entry point function looks. */
int 
main (int argc, char **argv) {
/* send the text 'Hello World' to the terminal. you can also use puts() */
printf("Hello World! This is a C program :D\n"); 
return EXIT_SUCCESS;
}

And to compile it, save the text in the editor, and type on the terminal: gcc -o hello_world main.c

To run it, type: ./hello_world

/* main.cpp In C++ */
#include <iostream> /* this imports the cout function and other input/output routines from the standard library */

/* this is how a standard entry point function looks. */
int 
main (int argc, char **argv) {
/* send the text 'Hello World' to the terminal (C++ way uses something called streams) */
std::cout << "Hello, world! This is a C++ program\n";
return EXIT_SUCCESS;
}

And to compile it, save the text in the editor, and type on the terminal: g++ -o hello_world main.cpp

To run it, type: ./hello_world

Here is the online documentation for GCC: http://gcc.gnu.org/onlinedocs/gcc/ Or for a pdf version: http://gcc.gnu.org/onlinedocs/gcc-4.6.0/gcc.pdf

Simple, eh? No need for IDE's really. It's best to learn how to use a compiler first in my opinion. If you want to know about a function, you can also use: man 3 printf - for example to look up the documentation on the terminal.

Link to comment
Share on other sites

  • 0

It's best to learn how to use a compiler first in my opinion.

I strongly disagree - especially in a language like C++ where there is no standard compiler and all available compilers differ greatly in terms of commandline switches! Personally I think that learning the language itself should be the first step! Second: learning the library.

  • Like 2
Link to comment
Share on other sites

  • 0

Currently I'm just running a desktop edition of Ubuntu, but soon enough getting Arch which I've heard some good reviews about :)

Don't know if anyone here has experience with that and would advise for or against using it.

Link to comment
Share on other sites

  • 0

I strongly disagree - especially in a language like C++ where there is no standard compiler and all available compilers differ greatly in terms of commandline switches! Personally I think that learning the language itself should be the first step! Second: learning the library.

GCC works on all platforms. I'd say that's pretty standard. It also follows the posix unix style of parameters like most other FOSS and cross platform programs.

Currently I'm just running a desktop edition of Ubuntu, but soon enough getting Arch which I've heard some good reviews about :)

Don't know if anyone here has experience with that and would advise for or against using it.

I've heard a lot of good things about arch, although personally, I've never used it. I tend to use Ubuntu and Gentoo mainly.

Link to comment
Share on other sites

  • 0

Yeah, ubuntu has been working nicely for me, just fancied trying something different. Althought lately it isn't showing up at bootup, I used a program called 'Wubi' to dual-boot it, and at startup I'd get the choice of which OS to load, Win 7 or ubuntu, although today it hasn't been, will have to look into that later. May have a look at some other distros before getting Arch though.

Link to comment
Share on other sites

  • 0

GCC works on all platforms. I'd say that's pretty standard. It also follows the posix unix style of parameters like most other FOSS and cross platform programs.

The compiler being available on all plattforms is COMPLETLY unimportant if you want to learn a language!

Pretty standard != standard compliant?

Parameters? Totally irrelevant if you want to start learning programming!

Link to comment
Share on other sites

  • 0

Yeah, ubuntu has been working nicely for me, just fancied trying something different. Althought lately it isn't showing up at bootup, I used a program called 'Wubi' to dual-boot it, and at startup I'd get the choice of which OS to load, Win 7 or ubuntu, although today it hasn't been, will have to look into that later. May have a look at some other distros before getting Arch though.

It might work better if you install Ubuntu in a dual boot configuration, that is, if you burn the ubuntu iso to disk or usb pen drive, then reboot into. The installer will give you an option to run it side by side with WIndows 7. Wubi can be quite buggy with Windows 7 at times.

Link to comment
Share on other sites

  • 0

I was being serious though. If you spend most time in windows and aren't in a hurry to figure out the wubi issue, just install Cygwin and pickup the current gcc for it. That and notepad are enough to get you going through any cpp tut around for now. You can worry about the best STL, optimizations, frameworks, and platforms once you start writing and compiling code.

Okay one more thing LOL - notepad++ or editplus - just do it :)

Link to comment
Share on other sites

  • 0
Currently I'm just running a desktop edition of Ubuntu, but soon enough getting Arch which I've heard some good reviews about :)

Don't know if anyone here has experience with that and would advise for or against using it.

Well shoot thought you were talking specifically Windows since you mentioned VC6 in the first post lol.. if Windows only, definitely the MS flavor as it'll be much more optimized for the platform, best tool for the job and all that, but since you're dealing cross platform, that's a whole different ballgame. As for the distros, both are good, access to all the same software and tools.. personally I preferred Arch just because it's more BSD like and I like how they deal with source in the repositories better along with the Ports-like system, but that's just personal preference. Both are top notch for Linux, just keep in mind Arch's install is a fair bit trickier as Ubuntu's installation is very out-of-the-box oriented, versus Arch's building up from a console prompt. (Not hard, just different.. have the Arch Wiki handy for the first time.) End result user-experience is going to be very similar depending on the DE and IDE you pick, if any.

Link to comment
Share on other sites

  • 0

Yeah, I'm still looking for basic tutorials, I'm going to start looking for a few ebooks pretty soon. This is the main problem with trying to learn a programming language I hope, getting started.

And I've sorted the Wubi issue :) no worries.

Link to comment
Share on other sites

  • 0

The compiler being available on all plattforms is COMPLETLY unimportant if you want to learn a language!

Pretty standard != standard compliant?

Parameters? Totally irrelevant if you want to start learning programming!

The GCC compiler follows the c/c++ standards, both c89, c99, and others. Because it's available across platforms means it's readily accessible no matter which OS you use. A good place to start when beginning programming in my opinion.

Link to comment
Share on other sites

  • 0

Well shoot thought you were talking specifically Windows since you mentioned VC6 in the first post lol.. if Windows only, definitely the MS flavor as it'll be much more optimized for the platform, best tool for the job and all that, but since you're dealing cross platform, that's a whole different ballgame. As for the distros, both are good, access to all the same software and tools.. personally I preferred Arch just because it's more BSD like and I like how they deal with source in the repositories better along with the Ports-like system, but that's just personal preference. Both are top notch for Linux, just keep in mind Arch's install is a fair bit trickier as Ubuntu's installation is very out-of-the-box oriented, versus Arch's building up from a console prompt. (Not hard, just different.. have the Arch Wiki handy for the first time.) End result user-experience is going to be very similar depending on the DE and IDE you pick, if any.

Yeah, I noticed about the Arch install, I was watching a review about it on Youtube and the guy was reviewing it while installing it, a lot more complex than ubuntu lol. But still would figure it out ;).. Or not obviously there's always a chance I'd fail miserably :p

The GCC compiler follows the c/c++ standards, both c89, c99, and others. Because it's available across platforms means it's readily accessible no matter which OS you use. A good place to start when beginning programming in my opinion.

I'm probably going to just use visual studio on my desktop, and have GCC on my laptop which is using win 7 and ubuntu :) will give me the best of both in that case hopefully ;)

Link to comment
Share on other sites

  • 0

Yeah, I'm still looking for basic tutorials, I'm going to start looking for a few ebooks pretty soon. This is the main problem with trying to learn a programming language I hope, getting started.

And I've sorted the Wubi issue :) no worries.

If you are in interested in C, K&R is the absolute definitive. for C++, again, I don't think you can go wrong with a book written by the creator of the language. In this case, Bjarne Stroustrup's The C++ Programming Language (Third Edition).

Link to comment
Share on other sites

  • 0
Yeah, I noticed about the Arch install, I was watching a review about it on Youtube and the guy was reviewing it while installing it, a lot more complex than ubuntu lol. But still would figure it out ;).. Or not obviously there's always a chance I'd fail miserably :p

If in doubt, mess with it in a virtual machine till you get the hang of it, or just decide to go elsewhere. Arch along with AwesomeWM, VIM and the like is a fun setup. Breaking your Windows install because you messed up the GRUB bootloader or accidentally repartitioning your Windows partition as EXT4, not so much.

Link to comment
Share on other sites

  • 0

If in doubt, mess with it in a virtual machine till you get the hang of it, or just decide to go elsewhere. Arch along with AwesomeWM, VIM and the like is a fun setup. Breaking your Windows install because you messed up the GRUB bootloader or accidentally repartitioning your Windows partition as EXT4, not so much.

That's a good point, I never really thought of the consequences :p I'll have a look for a vm then, I already have VM workstation on both my systems so thanks for the advice :D

If you are in interested in C, K&R is the absolute definitive. for C++, again, I don't think you can go wrong with a book written by the creator of the language. In this case, Bjarne Stroustrup's The C++ Programming Language (Third Edition).

Ah, I saw something about that book earlier on, thank you will have a look see if I can find it. You have any idea if it'd cost or be free by any chance? :p

anyways, I'm going to sleep all, thanks for the help. See you in the morning :)

Link to comment
Share on other sites

  • 0

if Windows only, definitely the MS flavor as it'll be much more optimized for the platform, best tool for the job and all that

I'm sorry, but I have to call BS on that statement. Microsoft compilers are no more optimised than any others that run on Windows. The difference compared to GCC is that GCC is standards compliant and MSVC is not, just the same way as IE is less standards compliant then other web browsers. MSVC is also proprietary, closed source, and locked down to Windows only.

Ah, I saw something about that book earlier on, thank you will have a look see if I can find it. You have any idea if it'd cost or be free by any chance? :p

If you want K&R, PM me.

Link to comment
Share on other sites

  • 0

If you are in interested in C, K&R is the absolute definitive. for C++, again, I don't think you can go wrong with a book written by the creator of the language. In this case, Bjarne Stroustrup's The C++ Programming Language (Third Edition).

K&R is not even standard C!!!!!

And if you start learning C++, don't even consider to read Stroustrup! His book on the C++ standard - matter of fact no book about the standard - is any good to learn the language! Anyone who is recommending this book to beginners has no idea!

I'm sorry, but I have to call BS on that statement. Microsoft compilers are no more optimised than any others that run on Windows. The difference compared to GCC is that GCC is standards compliant and MSVC is not

That's just utter rubish! MSVC is really good in terms of standard compliance. And again GCC does NOT represent the C++ standard!! Concerning the optimized thing: How is one going to generate libs and dlls with GCC?!

  • Like 3
Link to comment
Share on other sites

  • 0
Visual Studio doesn't and can't use the GCC or the Autotools. It's proprietary, closed source, and locked down, standards incompliant (isn't everything that Microsoft does non-standard?), and finally, is locked down to Windows.
We're not trying to push any licensing ideology here, just helping someone learn and experiment with the C++ language. Since he's using Windows, what will do the best job is Visual Studio.

Furthermore you seem to have no idea what you're talking about. You call MSVC not standard-compliant but go on to recommend K&R C as the "absolute definitive" reference, when it was superceded about 20 years ago... And GCC isn't any better than MSVC. It's slow, it doesn't optimize for ****, it chokes on templates, and I've yet to work at a company that uses it instead of MSVC where MSVC is available.

  • Like 3
Link to comment
Share on other sites

  • 0

K&R is not even standard C!!!!!

K&R (Second Edition) is ANSI C (c89). If you don't know that, then there is no hope for you. Do do know that K&R created the C language right?

And if you start learning C++, don't even consider to read Stroustrup! His book on the C++ standard - matter of fact no book about the standard - is any good to learn the language! Anyone who is recommending this book to beginners has no idea!

If you want a definitive language reference, then Stroustrup, the creator of the C++ language, is most likely the best source. If you have a real criticism of my book suggestion, then i'd like to hear it.

That's just utter rubish! MSVC is really good in terms of standard compliance. And again GCC does NOT represent the C++ standard!! Concerning the optimized thing: How is one going to generate libs and dlls with GCC?!

MSVC is renowned for it's poor standards compliance:

http://stackoverflow.com/questions/1599960/visual-c-standards-compliance

GCC implements the C++ standard, just like every other compiler. However, there are degrees of compliance, and MSVC has a horrible history. Do you really want to write code in MSVC that compiles yet behaves differently or fails to compile with other compilers? Risky business writing code in MSVC if you want any kind of portability and deterministic behaviour.

As far as optimisation, GCC creates platform specific dynamically linked and static libraries the same way as MSVC. I compiles them into PE/DLL compliant layouts on Windows, and ELF/SO on GNU/Linux. Any clearer?

Link to comment
Share on other sites

  • 0

Furthermore you seem to have no idea what you're talking about. You call MSVC not standard-compliant but go on to recommend K&R C as the "absolute definitive" reference, when it was superceded about 20 years ago...

Superceded? Have you heard of ANSI C, aka C89, or standard C! Most C code is written in C89, not C99, and K&R Second Edition, is based on ANSI C. Have you ever even written any C code? If you had, you would have known this.

And GCC isn't any better than MSVC. It's slow, it doesn't optimize for ****, it chokes on templates, and I've yet to work at a company that uses it instead of MSVC where MSVC is available.

Evidence? Thought not. Spurious claims once again. But I digress, we're getting off topic and clogging this thread up.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.