tags:

views:

178

answers:

2

I used code:blocks as the C++ IDE on Windows. I switched to netbeans 6.8 (with C/C++ plugin, MinGW, MSYS) recently, because netbeas have the nice feature of "checking syntax errors when typing" (same as working on Java or PHP projects).

But the painful thing is that, it takes 2 seconds to compile a simple hello world project in netbeans. Any trick to make it as fast as code:blocks, or at least make the compiling time no more than 0.5 second?

EDIT:
I did not care about this 2 seconds difference until I worked on Google codejam questions yesterday.

A: 

MinGW uses G++ 3.x, which is very very old. It's a limitation of the compiler itself -- old versions of G++ are simply slow. There are some "unofficial" G++ ports to windows that borrow from the MinGW project that use more recent (4.x) versions of G++, and it's possible your Code::Blocks IDE was using one of those.

I seriously doubt that the second and a half is significant in 99.9% of usages of most compilers anyway. Even if it is overhead imposed by the IDE itself, we're talking about what is essentially a one time cost -- it shouldn't blow up to insane compile times when you compile larger programs.


In response to FredOverflow's comment: From the MinGW installer (mingw.ini):

[mingw]
Build=12
URL=http://prdownloads.sourceforge.net/mingw
Filename=MinGW-5.1.6.exe
packages=previous|current|candidate

[current]
runtime=mingwrt-3.17-mingw32-dev.tar.gz|7300
runtimeDLL=mingwrt-3.17-mingw32-dll.tar.gz|30
w32api=w32api-3.14-mingw32-dev.tar.gz|14460
binutils=binutils-2.20-1-mingw32-bin.tar.gz|26979
core=gcc-core-3.4.5-20060117-3.tar.gz|7712
gpp=gcc-g++-3.4.5-20060117-3.tar.gz|15480
g77=gcc-g77-3.4.5-20060117-3.tar.gz|5272
ada=gcc-ada-3.4.5-20060117-3.tar.gz|33860
java=gcc-java-3.4.5-20060117-3.tar.gz|43160
objc=gcc-objc-3.4.5-20060117-3.tar.gz|3720
make=make-3.81-20090914-mingw32-bin.tar.gz|723

[previous]
runtime=mingwrt-3.15.2-mingw32-dev.tar.gz|7616
runtimeDLL=mingwrt-3.15.2-mingw32-dll.tar.gz|40
w32api=w32api-3.13-mingw32-dev.tar.gz|14420
binutils=binutils-2.19.1-mingw32-bin.tar.gz|21093
core=gcc-core-3.4.2-20040916-1.tar.gz|8627
gpp=gcc-g++-3.4.2-20040916-1.tar.gz|16542
g77=gcc-g77-3.4.2-20040916-1.tar.gz|5158
ada=gcc-ada-3.4.2-20040916-1.tar.gz|33333
java=gcc-java-3.4.2-20040916-1.tar.gz|45547
objc=gcc-objc-3.4.2-20040916-1.tar.gz|4555
make=mingw32-make-3.81-20080326-2.tar.gz|727

[candidate]
binutils=binutils-2.18.50-20080109-2.tar.gz|20505
core=gcc-core-3.4.5-20060117-3.tar.gz|7712
gpp=gcc-g++-3.4.5-20060117-3.tar.gz|15480
g77=gcc-g77-3.4.5-20060117-3.tar.gz|5272
ada=gcc-ada-3.4.5-20060117-3.tar.gz|33860
java=gcc-java-3.4.5-20060117-3.tar.gz|43160
objc=gcc-objc-3.4.5-20060117-3.tar.gz|3720
make=mingw32-make-3.81-2.tar.gz|720
Billy ONeal
No, I use the same version MinGW for netbeans and Code:Blocks. Actually I set the path of compliers in netbeans pointing to those use with MinGW. I know it is probably a one-time cost, but it is still uncomfortable when I need to repetitively compile small projects many many times to check if they work correctly. I am working on Google codejam questions.
Ethan
What do you mean, "unofficial"? You can get the latest g++ 4.5.0 as part of the official [MinGW package](http://sourceforge.net/projects/mingw/files/).
FredOverflow
@FredOverflow: The item you linked to contains G++ 3.4.4
Billy ONeal
@Billy THe GCC 4.5 compiler is actually on the MinGW SourceForge site, but that site is so abysmally unusable I can't blame anyone for not finding it. I cannot see why ANYONE continues to use SourceForge, but MinGW have added their own levels of impenetrability to it.
anon
@Billy That's the installer - there isn't one for 4.5, or any recent versions, but that doesn't mean those versions don't exist. That's why everyone uses the "unoficial" releases by people like Twilight Dragon and nuwen.
anon
@Billy I downloaded 4.5 just fine from that site under "GCC version 4". `g++ --version` confirms that this is really 4.5.0. You simply have to download and extract the files listed unter "runtime requirements" in [the readme](http://sunet.dl.sourceforge.net/project/mingw/GCC%20Version%204/gcc-4.5.0-1/gcc-4.5.0-1-mingw32.RELEASE_NOTES.txt).
FredOverflow
@Neil Butterworth: That is correct and is why I said "unofficial" above. @FredOverflow: I was not aware of that. However the fact that no installer exists for 4.5 is still a major problem. No IDE bundles the 4.5 version because the latest installer has only the 3.4.4 version. When the installer is fixed I might start recommending GCC again for Windows, but until then I cannot. (It's an *EXCELLENT* compiler on *nix platforms though)
Billy ONeal
@Billy The TD release is at 4.4.1, comes as an installer, and works perfectly.
anon
Just upgrade MinGW to TDM's GCC/MinGW32 Builds (http://sourceforge.net/projects/tdm-gcc/). Compiling time reduces to 1 second.
Ethan
A: 

Two seconds to load a compiler, compile a source file, assemble it, and link it is actually pretty fast. The speed difference may be due to the very large memory footprint of Netbeans compared with the quite small one for Code:;Blocks. Netbeans is more or less unusable on my ancient laptop, whereas Code::Blocks works just fine.

anon
Two seconds is pretty fast? Turbo Pascal could do this instantly 25 years ago, and its only advantage was having the compiler already in memory.
Gabe
for a hello world app, 2 seconds is a long time. For larger projects, of course, 2 seconds is nothing.
jalf
@Gabe: The C++ standard library didn't exist 25 years ago, so how do you know? (Compilation of HelloWorld with "cstdio" should be instantaneous, whereas "iostream" is a beast only surpassed by some boost libraries :) )
UncleBens
@Gabe: Pascal != C++. They have completely different linking models. Comparing one to the other is inherently not a meaningful comparison.
Billy ONeal
Computers are 1000 times faster and have 1000 times the memory of computers from 25 years ago that could compile and link a program in 20ms. I know C++ is more complicated than Pascal, but not 100,000 times more complicated!
Gabe
@Gabe: Hard disks are not 1000 times faster, and when compiling a hello world program the disk is going to be the bottleneck, not anything like CPU or RAM. Your assertion that a 1000 times faster CPU with 1000 times the memory is 100,000 times as fast is false. Finally, when compiling that hello world program, the compiler could be processing several MB of source code as a result of `#include` ing various standard library headers.
Billy ONeal
One might hope that somewhere withing those thousands of megabytes of memory, there might be room to cache things like the compiler, linker, object files, and so on. That way the first compiler would be slow because everything has to be loaded from disk, but successive ones would be much faster.
Gabe