Developing In C/C++? Why You Should Consider Clang Over GCC (dice.com) 255
Nerval's Lobster writes: The idea with Clang, a compiler front-end for C, C++, Objective-C++, and Objective-C, and LLVM (a compiler infrastructure) is that you can mix the compiler front-end with a targeted back-end and end up with highly portable and efficient compiler. Clang can perform static analysis of your code, and lets you write tools that give you information about a program. Although many developers prefer developing in C/C++ using GCC, developer David Bolton (in a new Dice article) makes an argument for why you should switch to Clang. While GCC is probably still best when it comes to speed, he argues, Clang is improving release by release, and features tools that developers could find useful.
Translation (Score:3, Insightful)
While GCC is probably still best when it comes to speed, he argues, Clang is improving release by release, and features tools that developers could find useful
Translation: "network tran--I mean speed is a feature that most of our users don't need, so it's not in our development plan"
Re:Translation (Score:5, Informative)
Translation: "network tran--I mean speed is a feature that most of our users don't need, so it's not in our development plan"
No. Clang produces faster code [phoronix.com]. What TFA means is that GCC compiles faster. But if slightly faster compiles are that important, just turn off the optimizer, or buy a faster computer. How much time does a modern developer spend waiting for the compiler to finish? For me, it is less than 1%. Far more important is the better error messages, warnings, and static analysis from Clang. Those save me way more time than the speed of the compiler.
Re: (Score:2)
How much time does a modern developer spend waiting for the compiler to finish
In C/C++? All the freagin time. Large applications can take -forever- to compile, even if its not a clean compile.
Re:Translation (Score:5, Informative)
Large applications can take -forever- to compile, even if its not a clean compile.
Many complaints about slow compiles are due to dysfunctional workflow. You should be using precompiled headers, and set up your makefiles for multiple cores. But most importantly, you should be using TDD to develop and debug code outside of the application. So instead of compiling and linking the entire application repeatedly as you track down a bug, you only integrate after all your unit tests are written and passed in isolation.
But, anyway, it isn't clear that Gcc actually compiles faster than Clang. Here are some benchmarks [phoronix.com], and the results are mixed. Sometimes Clang is faster, sometimes Gcc is faster. For a large app, they would likely be about even in compile time. But Clang would likely generate better code, and almost certainly generate more helpful errors/warnings/analysis.
I can't see any rational reason to prefer Gcc.
Re: (Score:3)
Number 1 is important. The primary reason Apple is supporting Clang is that they got a snit over the new GPL license.
Now Clang/LLVM do work on more than just PC architectures, but there aren't as many developers and users for them compared to GCC users. So the more users you have the more feedback, the more feedback the better the end product. Especially with something like ARM with lots of processor and instruction set variants you really want to make sure you're not inadvertently the beta tester for th
Re:Translation (Score:5, Insightful)
Apple, whose most profitable product lines all include ARM chips, has a large compiler team working on Clang and LLVM. Google, which doesn't ship any ARM products, but does have a huge investment in the ARM ecosystem, also employs a lot of people contributing to LLVM. They contributed most of the ARMv8 back end. ARM also has several large teams working on LLVM (I think that they've largely consolidated them now - they used to have separate C, OpenCL-ARM, and OpenCL-Mali teams all working largely independently on LLVM) and is now (as the other poster says) using LLVM for their proprietary toolchain (which is mostly expensive because of the debugging / tracing tools), so they're contributing a lot. There are a lot more ARM developers working on LLVM than clang. IBM has people working on PowerPC support, Imagination Tech on MIPS support. SPARC is largely volunteers these days, but Oracle seems to be killing SPARC as a thing anyone else might care about.
Re: (Score:2)
which doesn't ship any ARM products
Other than the Nexus product line.
Re: (Score:2)
Does Apple care about ARM chips other than what's in their phones? Probably not. But still, Clang/LLVM is too new, if you want stability right now you stick to GCC instead of jumping ship because some PC users are in love with something else.
In the embedded world it's a massive hassle to upgrade compilers even to a new version, you need buy off from everyone on the team, you still need to keep the old ones around to support older releases, you have to put the new tools on every dev and build machine, and
Re: (Score:2, Insightful)
1) Long term Freedom. The importance of which can not and should not be understated.
Except gcc doesn't give you that. The FSF keeps changing the goalposts on what constitutes "free" software (see GPLv2 vs GPLv3, for instance), and every time they do it, they lose developers who can no longer adapt to their ideology. Clang is FREE. Sure, someone might fork it, someone might embrace&extend it, this does not mean I will in the future be unable to use the Clang code I have on my hard-drive right now. An
Re: (Score:2)
Given that's a massive proportion of all the markets I ever wish to program for, I will accept this terrible stricture and forge on in terrible silence.
Re: (Score:2)
I wouldn't go anywhere near this pattern for self contained code.
Re: (Score:3)
"Clang is also portable code, which gcc absolutely is not." ... Er, gcc has been portable to cpu architectures and os platforms you probably haven't even heard of, in decades you perhaps weren't even born yet. It's probably one of the most portable pieces of software. (It pays for that in many ways.)
Re: (Score:2)
Optimization is almost certainly going to be better inside a translation unit than between two translation units. That could be important under certain circumstances. This is one of those cases where there may not be a good answer, but at least memory is cheap.
Re: (Score:3)
I've seen cross-compile builds of large code bases of 2 million+ lines take 10 minutes. Change one header file of a low-level module, and the whole stack has to be rebuilt. Just because BaseClassA has had a new boolean flag added, DerivedClassB to DerivedClassJ have to be recompiled along with container classes, interface classes, then the GUI layer with custom widgets, the plugins for third-party editors, the dynamic linked libraries, and finally the application itself.
Re:Translation (Score:4)
If you are running into that issue often, consider the Pimpl-pattern.
As always, C++ doesn't take the decision away from you. If you cannot live with the overhead in runtime from one pointer indirection, you have to live with the other downside.
From my standpoint and experience, most compile time issues were due to people putting things into the headers out of convenience.
In order to save some forward declarations or pimpl implementations, things were put into the header, which caused constant recompiles,and long compile times.
Re: (Score:3)
C++ (in GCC at least) is vastly slower than C, for the same input source. That's without doing the complicated stuff. You can speed a lot of with parallel builds, but a lot of people don't set up their build systems to make that easy (just passing -j to a recursive make can break).
A decade ago I had an 18 hour build. So bad that people would start shouting if someone tweaked a major header file. Much of the slowdown was from the commercial compiler, and part of the slowdown was by using Visual Studio as
Re: Translation (Score:5, Funny)
And what kind of garbage programmers are you that need to compile the same code multiple times? Write the code correctly the first time and only compile once.
Re: Translation (Score:4, Funny)
I keep telling the users that, run the program correctly the first time and you shouldn't have to run it a second time!
Re: (Score:3)
Re: (Score:3)
No. Sometimes Clang produces faster code. Read the rest of that review.
G++ versus Clang++ (Score:5, Informative)
>better error messages, warnings, and static analysis from Clang. Those save me way more time than the speed of the compiler.
This is the truth. Ain't nobody got time to read through a hundred lines of error messages to track down a single bug.
As a simple test, I wrote the following code which has a simple mistake (using an integer instead of an int array in a range-based for loop):
test.cc:
#include
int main() {
int x = 0;
for (int i: x) std::cout constexpr const _Tp* std::end(std::initializer_list)
end(initializer_list __ils) noexcept"
2 lines for a single straightforward error in clang++ 3.7 (with colors even!):
"test2.cc:5:12: error: invalid range expression of type 'int'; no viable 'begin' function available
for (int i: x) std::cout i;"
I currently use g++ with new programmers, and will be switching soon to clang++.
Plus Clang does cool things like interoperate with things like YouCompleteMe to do real time compiling and error message generation for syntax completion in VIM.
Re: (Score:3)
(Sigh, Slashdot. Stop eating code snippets in Plain Old Text mode. This is a place for geeks.)
Here's the code that generated the bug, without Slashcode mangling it:
int x;
for (int i: x) std::cout i;
109 lines of error messages in g++, 2 lines in clang++
Re: (Score:2)
I'd be willing to bet that there's supposed to be less-than or greater-than symbols in there. Slashcode helpfully treats them as some sort of html tag, and ignores what it doesn't recognize.
Re: (Score:2)
My previous job we used C++ with template heavy usage and I ended up being the unofficial translator of G++ error messages. This is really the only part of GCC I dislike (and it's only on the C++ side which I'm not using now).
Re: (Score:3)
If you're marvelling over clang producing coloured error messages, then you're using an old version of gcc. Try switching to something in the new gcc-5 series. Contrary to popular belief, it's quite slow, but not hard to compile. Also, many distros have gcc-5 packages available.
PS, both versions of your code got mangled, so I can't see what you're referring to precisely.
Re: (Score:2)
Re: (Score:2)
... sources ... on a RAM disk.
Whenever anybody loses a fair chunk of a day's work due to a crash / power failure / other dumbass mistake, I always advise them "it's easier the second time around."
Nobody ever appreciates the advice.
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Been there, done that (because of a sysamdin who thought that doing diagrams with pretty pictures was MUCH more important than doing backups for any of my team for many weeks, on one occasion) and you know what?
You're right!
Rgds
Damon
PS. Not that I advocate it as normal workflow for the sake of everyone's blood pressure for a start!
Re: (Score:2)
Have you benchmarked it recently? I tried this on our build machines (32 cores, 256GB of RAM, 512GB SSD split mostly as L2ARC with a small amount as log device, 3TB spinning rust in a ZFS mirror) a while ago. The amount of I/O that actually goes to the spinning rust is tiny (object files are written out, but never read back), pretty much all I/O comes from the buffer cache. Putting it on a RAM drive reduced the writes, but there's no synchronisation required for them so they never became a bottleneck. I
Re: (Score:3)
If you're dubious about "special compilation", then use GCC to compile clang. (It's not sufficient, but using a different compiler to do the compilation of the compiler is a necessary step.)
Graph (Score:2)
So you could write a tool against LLVM that looks to see which templates are causing problems, maybe output the usage graph to graphviz to help refactor your code...
Re: (Score:2)
It's a Dice article. It's therefore intentionally click bait.
Re:Translation (Score:5, Insightful)
Apple migrated over to Clang, but they left a bastardized GCC in it's place as a "transition". The preprocessor swears up and down that it's GCC but if you use inline assembler it barfs. So it's basically lying. It's a GCC front end and LLVM back-end, and the solution is to manually install a real GCC in its place (easier than porting the code, easier than ifdef OSX vs Linux, etc). And it's a major pain in the ass for new developers to set up a development environment, and inevitably someone eventually screws up their PATH to pick up the broken compiler...
Anyway screw it. Clang may be ok, but there's production code that assumes GCC, it's cross-platform code so having stability on x86 doesn't necessarily mean anything about all those other CPUs that GCC supports well. Ie, GCC supports ARM, and ARM supports GCC, so if I go to the team and say "hey guys, I'm going to mix things up for a few months and try out a different compiler, things might break unexpectedly but in the long run you might like it, what do you think?" then I won't get positive feedback.
Until there are drawbacks to GCC there's no much reason to change.
Re: (Score:2)
GCC supports ARM, and ARM supports GCC
ARM has a lot more people working on LLVM than they do on GCC and they're slowly transitioning everything across. Their customers fell into two categories: ones that don't care about the license and ones that won't touch GPLv3. If you want a compiler with long-term support for ARM, then GCC probably isn't your best bet.
Re: Translation (Score:3)
Re: (Score:3)
Clang for Windows is taking an approach which is somewhat bizarre but could potent
Re: (Score:2)
i'd be interested to know how fast Clang compiles Petzond [charlespetzold.com] compared to msvc. including re-compiling with simple change with/without PCH & incremental linking enabled.
Re: (Score:2)
Hmm, what? GCC can be built natively on windows thus it is a native app, it can be built without cygwin libraries.
Or compile on everything (Score:3, Insightful)
Compile in both. And visual studio too if possible. Enable all warnings. They are all good at identifying different categories of problems and code that compiles cleanly under multiple compilers will prove easier to maintain.
Strongly recommend Clang (Score:3, Informative)
I strongly recommend Clang. It's speed is about on par with GCC, but the output and syntax checking is so much better. I tried it a bit a few years back and I have been hooked on Clang since. Using GCC feels like a big step backward now because it's so fussy and its warnings are so cryptic in comparison.
Re: (Score:2)
I strongly recommend Clang. It's speed is about on par with GCC, but the output and syntax checking is so much better. I tried it a bit a few years back and I have been hooked on Clang since. Using GCC feels like a big step backward now because it's so fussy and its warnings are so cryptic in comparison.
Last time I looked, Clang didn't recognize idiomatic "rotate", e.g.:
(x << 3) | (x >> 29)
That should compile to a single opcode, dammit. Anyone know if that problem is still there.
Re: (Score:2)
On what processor would that be a single opcode? I'm curious.
Re: (Score:3)
Re: (Score:2)
But you fail to give an example ;D
Which opcode, on an x86 e.g. can rotate left and right simultaniously and OR the two results together: simultaniously? Feel free to pick a different architecture. Not even on an ARM you can do that in one opcode.
Re: (Score:2)
Re: (Score:2)
Ah, I'm coming closer to it. But I have not grasped it yet.
I shift left 3 times and or the result with the same register shifted right 29 times, both together is a rotate? Never thought about that. I have to test that on paper, does not really look plausible on the first attempt.
Re: (Score:2)
Sounds like you've got the gist of it. C only has a bitwise shift (where the end that the shift would "empty" is filled with zeroes for unsigned integers), not a bitwise rotate (ex. 00001011 rotated right by 2 becomes 11000010), so the closest thing to saying "bitwise rotate this" is using a set of expressions that would have the same behavior. Since a bitwise rotate is the same as splitting the binary number into two parts (of sizes determined by the desired rotation amount) you just have to create the two
Re: (Score:2)
SHL and SHR...been a long time since I used them, but pretty sure they will still be around.
Re: (Score:2)
You missed the parent:
He claimed that instant of
LDC R1 #value1
LDC R2 #value2
SHR R1,something
SHL R2,something
OR R3,R1,R2
You can do the above in a single opcode ... it is beyond me how he would do that or if that is possible because the constants in his example are "special".
Assuming the registers R1 and R2 already hold the values in question: you need minimum 3 opcodes or a special architecture like ARM, but on an ARM I believe you minimum would need 2 opcodes.
Re: (Score:3)
Re: (Score:2, Informative)
$ cat rol3.c
$ gcc -c rol3.c
$ objdump -d rol3.o
$ gcc -O1 -c rol3.c
$ objdump -d rol3.o
Re: (Score:2)
You can put function calls inside a switch statement but outside the case statements in gcc. Does that happen in Clang? Even old Borland C++ compilers from 1990's would catch that one.
Re: (Score:2)
fussy? What do you mean? They both pretty much support the entire standard very well. If gcc is failing to accept code, you're probably doing something non standard tha clang has as an extension.
What do they mean by speed? (Score:2)
Re:What do they mean by speed? (Score:4, Funny)
Nope, those still get you modded down. To be modded up, you'll need to be an elf or a hobbit...
Re: (Score:2)
Nope, those still get you modded down. To be modded up, you'll need to be an elf or a hobbit...
I hear you can also get modded up for being an ent, but it can take years.
Neat thing (Score:2)
One neat thing about LLVM/clang is that theoretically you could provide your application as IR files, which can be flattened to machine-specfic code on the fly by a platform-specific backend.
I think at some point it was fast enough to generate that code on the fly. I vaguely remember Apple doing that with its OpenGL stuff.
Re: (Score:2)
I vaguely remember Apple doing that with its OpenGL stuff.
CoreImage transforms.
Re: (Score:2)
I think at some point it was fast enough to generate that code on the fly.
Many interpreters are embedding LLVM for JIT these days.
Re: (Score:2)
One neat thing about LLVM/clang is that theoretically you could provide your application as IR files, which can be flattened to machine-specfic code on the fly by a platform-specific backend.
Is this a relatively new feature? The last time I looked at LLVM IR for this purpose, there was no general "pointer-sized" data type that could accomplish this. It would be really cool if this were no longer the case.
Re: (Score:2)
Re: (Score:2)
Use both (Score:2, Interesting)
To make sure my code is not using any compiler features I compile my code on both.
Intermediate formats (Score:2)
Does Clang compile to intermediate formats, such as Bytecode or any other formats? On the GCC side, I believe that the FSF (read RMS) is opposed to it
Re: (Score:2)
You mean, like GIMPLE?
Re: (Score:3)
Clang can compile to the LLVM "IR" format, which is a mostly machine-independent Intermediate Representation. Kind of like bytecode.
The IR file format has two variations: a human readable text format, and a more compact binary format.
Given an IR file, you can optimize it, which produces another IR file, or you can compile it into an object file.
Re: (Score:2)
LLVM "IR" format, which is a mostly machine-independent Intermediate Representation
LLVM IR is target agnostic, not target independent. The format itself is the same across all targets, but various things (e.g. calling conventions - how you split structs between registers and the stack) will be different for different targets.
License (Score:3)
Isn't LLVM/clang all about the license (non-GPL)? Otherwise if clang is good, then we should fork it and make a GPL version of it.
Re:License (Score:5, Informative)
No, LLVM/clang is all about having a superior architecture to GCC, so that a lot of new applications become possible. One of the key ideas is that the optimizer and code generator are libraries with a C++ API. One cool application of this is that you can use the LLVM library to implement a JIT compiler for your interpreted language: you generate the machine code directly into memory (instead of to a file), then execute it.
LLVM has many more developers than GCC, and is evolving and improving more quickly than GCC can. This is because of the licence: it turns out that corporations like Apple are more willing to provide developer resources for this open source project if the licence isn't copyleft. For this particular project, this means that the BSD license is more successful than the GPL. Of course, there are other projects for which the GPL produces better results in the real world.
If you want to make a GPL fork of LLVM just for the pure pleasure of fucking over the original project due their heresy in choosing a license you don't approve of, well, good luck with that.
Re:License (Score:5, Interesting)
This is because of the licence: it turns out that corporations like Apple are more willing to provide developer resources for this open source project if the licence isn't copyleft.
That's not really true, Apple contributed to GCC for years before LLVM. The problem was that Apple wanted features, and GCC wouldn't allow those features to be built. So finally Apple just gave up and built their own.
This is the rule of running an open source project (and Linus does a really good job of it): give users what they want, or the users will leave.
Re:License (Score:4, Informative)
True, but Apple could also see the writing on the wall with the GPLv3 and what that could mean to their use of the compiler. Which is also why they poured a lot of effort into LLVM and wrote clang. This effort dated way back too - the earliest versions of OS X that started coming out with LLVM as an option was around the 10.4 era.
A lot of companies saw what the GPLv3 was bringing to the table, and they didn't like it, so they moved on. Some, like Apple, realized they could stick around and fight with GCC and GPLv3, or work on an alternative.
GCC is deliberately obtuse as well - Apple wanted a nice front end to help parse and recompile code in real time, and GCC is intentionally twisty to prevent that (and if you want to write a parser for code, why not reuse what the compiler actually uses?). LLVM is more modular and makes it easier to integrate with an IDE
And in the end, I think having the diversity we do in compilers is refreshing - even if you hate LLVM with a passion, at least it's also brought forth development on GCC, which seems to have a history of stalling in development before someone else decides to fork it, revamp things, and have the fork become the official GCC.
FYI - the very last checkin to GCC by Apple was related to Grand Central Dispatch to the Obj-C compiler - basically about blocks.
Re: (Score:2)
Re: (Score:2)
You have cherry picked one comment from Richard Stallman, which was just his personal ideology. David Edelsohn replied this:
https://gcc.gnu.org/ml/gcc/201... [gnu.org]
GCC is working toward re-factoring its code base toward a more
compositional approach for "toolification". One can look at
presentations from the recent GNU Cauldron 2013 for discussion of the
topic. David Malcolm also has created patches for the GCC backend to be used as a JIT.
The assertions that FSF policy prevents technical development and
innovation simply is not true.
Maybe GCC was "deliberately obtuse", but as I see it, steps are taken to change that and enhance GCC for tool chains and to be used a library just as LVMM is.
Re: (Score:2)
The problem was that Apple wanted features, and GCC wouldn't allow those features to be built. So finally Apple just gave up and built their own.
This was not the issue. Apple maintained their own branch of GCC in the FSF's svn repository for a long time. Lots of features (e.g. blocks support, some Objective-C features) never made it back into the FSF's branch, but this was not a problem for Apple. The problem was that GCC could not be used, for both technical and legal reasons, in some of the places where Apple wanted to use it. Syntax highlighting was one simple example. GCC does constant folding in the front end, so by the time that you have
Re: (Score:2)
Apple started LLVM due to GPL v3. If you know anything about why they switched, that much is obvious ... being that they flat out said thats why they were switching among other things.
Re: (Score:2)
No, he didn't.
He tried to claim that NeXT's own code in the Objective-C front end was proprietary. He was more than happy to distribute the rest of GCC freely, but wanted to keep Objective-C closed. He failed.
Which is exactly the same thing as the OP said, once one uses precise language: the GPL's requirements also apply to the Objective C frontend precisely because the compiler as a whole is a single program (program = "copyrightable work licenced under this license").
Mixed backend languages is recipe for subtle bugs (Score:3)
From up-close-and-personal experience with Objective C and C++ (also Smalltalk), these languages have substantially different semantics regarding class identity (primarily: what version of overridden member functions you get) during construction and destruction. I wouldn't be surprised if Objectivce-C++ had yet another semantics, pulling "features" from both, and I have no clue about LVMM.)
Building a frontend to compile to them, interchangeably, is a recipe for subtle bugs, if the frontend doesn't deal with these issues. Efficiency may go out the window if the frontend tries to impose one language's construction/destruction semantics on another. Doing so also brings up the issue of which semantics the compiler exposes to the programmer - each has its good and bad points, and each enables different - and incompatible - useful programming features.
I'd be interested in what (if anything) Clang has done about this issue. (Unfortunately, I'm busy on other stuff, so I'll have to depend on others to elucidate this.)
Evidence? (Score:4, Interesting)
I would think that if these subtle bugs exist they'd be caught by the test suites. Do you have any actual evidence of these subtle bugs?
Re: (Score:2)
No, the trouble is that you just cannot implement an efficient garbage collector in C/++. So Java and .Net do their own compiling. C is only efficient if you think "C".
Re: (Score:3)
From up-close-and-personal experience with Objective C and C++ (also Smalltalk), these languages have substantially different semantics regarding class identity (primarily: what version of overridden member functions you get) during construction and destruction. I wouldn't be surprised if Objectivce-C++ had yet another semantics, pulling "features" from both, and I have no clue about LVMM.)
Objective-C++ mixes the syntax of the two languages, and allows you to use either a C++ object or an Objective-C object at will, however it does not make C++ objects into Objective-C objects or vice versa. Any semantics relating to C++ objects still applies to C++ objects, and no additional semantics are implied.
In short: things work as you'd expect, and there are no hidden gotchas.
The only real complexities are what happens when you embed a C++ object as a member inside an Objective-C object (this doesn't
Auto-vectorization (Score:2)
Once I checked, clang was not good at generating vector instructions from simple loops. Unless it has improved lately, that would be a show stopper for a class of code.
Re: (Score:2)
Both GCC and Clang (Score:2)
Re: (Score:2)
Damn, picked wrong formatting.
gcc *.c -o xxx -O -Wall -Wextra -Wmissing-prototypes \ -Wmissing-declarations -Wshadow -Wpointer-arith -Wcast-align \ -Wredundant-decls -Wnested-externs -Winline \ -Wno-long-long -Wconversion -Wstrict-prototypes -ansi -pedantic
clang *.c -o xxx -Wall -Wextra
What planet are you on? (Score:2)
I care how fast my compiler compiles (as long as it's not insane) about as much as I care how fast my system boots (as long as it's not insane).
Seriously. Whatever planet you weird devs came from, can you return to it? (And take Lennart with you?)... Spend your free time re-optimizing your cut-and-paste chef recipes or something, and leave the engineering to the rest of us?
Re: (Score:2)
Where is the time spent?
You should probably get someone to fork out for a 64 core build machine for you for nice, fast parallel builds.
Re: (Score:2)
I'm the architect, so most of my changes require a full recompile.
No. You aren't. An architect isn't writing code. And you'd be a shitty one if you were, since its a pretty shitty time spent if you're waiting for the entire system to compile for changes instead of having a CI system, unit tests and integration tests running on an automated system for you.
Don't try to brag like you're awesome, you're post shows you aren't.
just a warning (Score:3)
while clang is probably fine for most projects, if your project needs -std=c++14 then you should be warned that sometimes Clang can't properly deduce (even when you are explicit) variadic template parameters.
for example, this code will not compile on Clang no matter what but works fine with G++.
template<typename... ArgTypes> using deeper = void(*)(ArgTypes...);
template<typename... ArgTypes> void shallow(deeper<ArgTypes...> arg) { }
int main(int argc, char* argv[])
{
deeper<int> arg;
shallow<int>(arg);
return 0;
}
Clang was written by author of Swift (Score:2)
the guy who developed clang - Chris Lattner - also wrote swift.
he first modernized the architecture of the compiler, and then wrote a better language on top of it that is capaable of doing system level things like C++ with a cleaner semantic style.
++
Re: (Score:2)
Second of all, if you are developing in either C or C++, you should develop in a different language.
Depends on what you're doing. There are purposes for which C is the optimal language. I suspect that there are also purposes for which C++ is the optimal language. (In neither case can the purpose include handling unicode strings.)
Re: (Score:2)
C++ typically provides fast code with excellent abstraction capabilities. It's also much safer than C, since modern C++ eliminates a lot of C memory bugs (when used according to reasonable standards, anyway).
Re: (Score:2)
Oh. What language is that? javascript?
Re: (Score:2)
Second of all, if you are developing in either C or C++, you should develop in a different language.
OK, I'll bite. C and C++ are commonly used for real-time embedded applications, primarily because of speed. Do you have a better language for that? Remember, it has to compile on the processor you're actually using. My current project uses a Blackfin DSP processor by Analog Devices. The toolset that Analog provides supports only C, C++, and assembly. I don't expect them to provide Java, .Net, PHP, Haskell, Python or [your favorite language here] anytime soon.
Re: (Score:3)
My current project uses a Blackfin DSP processor by Analog Devices. The toolset that Analog provides supports only C, C++, and assembly. I don't expect them to provide Java, .Net, PHP, Haskell, Python or [your favorite language here] anytime soon.
You can run Linux on a blackfin. I'd strongly expect you could easily run Python or PHP on it. Not sure why you'd want to.
Re: (Score:2)
Exactly this. We do the very same.
However, Clang is significantly faster for our application. I would do some timings for you right now... but it takes too damn long to compile the entire stack with GCC ;-) Last time I checked it was on the order of 25% faster. Over a whole day of compiling that can make a big difference.
Re: (Score:2)
Re: Except RHEL doesn't have clang (Score:2)
Re: (Score:2)
... you mean code written specifically for GCC doesn't work as well in every case under a different compiler without the same shitty GCC quirks?!
WHAT IS THIS YOU SPAKE?