Re:Amplifying C (2010)
by atilaneves on Sunday February 07, 2016 @03:15PM
(#11054595)
"compiles super fast": compared to C++, sure. But not really, no.
[ Parent
| on HN ]
Re:Amplifying C (2010)
by iainmerrick on Sunday February 07, 2016 @03:58PM
(#11054801)
Compiling stb_image, an incredibly useful image loader:
$ wc -l stb_image.h
6433 stb_image.h
$ more stb_image.c
#define STBI_ONLY_JPEG
#define STBI_ONLY_PNG
#define STBI_FAILURE_USERMSG
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
$ time clang -c stb_image.c -o stb_image.o
real 0m0.091s
user 0m0.075s
sys 0m0.014s
Seems pretty fast to me!
Re:Amplifying C (2010)
by atilaneves on Monday February 08, 2016 @03:42AM
(#11057017)
Have you ever written Pascal, Go, or D? That's what fast compilation looks like. The D standard library compiles in 3.5s from scratch.
Re:Amplifying C (2010)
by iainmerrick on Monday February 08, 2016 @05:16AM
(#11057303)
Yes, I've used Go. The compiler is fast and that's really nice; fast compilation was one of their explicit goals.
Pascal and C are fast because they're old and relatively simple, and their implementations are mature.
C++ becomes super slow when you start doing anything interesting, when I tried Rust it seemed very slow, even Java is slow although it seems like it shouldn't have to be. Those languages are all more widely used than D, I think.
[edit: typo]
C compilation is generally faster than C++ compilation for obvious reasons. However the true speed depends on the level of optimization you want and the number of header files you're including. Non-Optimized C code can be generated very quickly, and if you manage your header files conservatively you can have very fast compilation speeds.