Live data from Hacker News

How to convince any C developer to dump gcc and use clang

fseek.me

41–50 of 97 posts

Re: How to convince any C developer to dump gcc and use clang

#41

As a dynamic language guy, I can't help but look at the static analysis here and feel a twinge of jealousy. There really isn't anything like this in the Ruby world. Some stuff is starting to emerge, but we're still largely dependent on tests to catch stupid mistakes. When I'm chasing down a bug, it would be nice to have a variety of tools to throw at the problem.

I spend most of my time writing C code, but like to work with Python when I get the chance. There isn't anything like pylint for Ruby? A dynamic runtime doesn't necessarily mean you have to give up static analysis.

Re: How to convince any C developer to dump gcc and use clang

#42
post #37

Earlier quoted context omitted.

You shouldn't need to port your code; C is C, right? Or do you use a lot of gcc extensions?

Clang is compatible with the most used GCC extensions. See this: http://clang.llvm.org/features.html#gcccompat

Even better!

Re: How to convince any C developer to dump gcc and use clang

#43
post #10

you're saying I should port all my code just because the ui is more user-friendly? what about performance, options, special warnings, builtins, and everything else? I've been using gcc for a while now, and every time I use it I found a new feature. It's rock solid and had never let me down.

just because the ui is more user-friendly?

Those better warnings aren't just due to a simple UI patch ... clang is doing better and deeper static analysis than gcc in order to even be able to produce those more intelligent warnings.

Re: How to convince any C developer to dump gcc and use clang

#44
post #25

I am currently switching between gcc and clang for my codebase. The performance is mixed. For some programs (2-level hashtable, for example), the clang version got about 50% speed up against gcc and icc. But other programs (sobel filter for example), clang version slows down about 25% (against gcc 4.4). The result certainly machine specific, but I think clang can do better in a long run.

Although cryptic, I'd say that gcc's error messages are manageable. I'd hold other factors, such as performance of compiled code - across platforms - to be more important. Alternatively, they could improve on the C++ template error reporting (when they get around to taking C++ support beyond alpha) and that may be enough to sell me.

a quick search yields http://clang.llvm.org/performance.html (favourable, but somewhat skewed results). http://forums.cocoaforge.com/viewtopic.php?f=10&t=21016 indicates improved compile times, but it's purely anecdotal.

That said, does anyone else have any experience moving a performance-centric or cross platform project to clang?

Re: How to convince any C developer to dump gcc and use clang

#46

Earlier quoted context omitted.

It's quite common and accepted for compilers to make assumptions about the rest of the code, and for those to be wrong if your code is broken. For example, the C# compiler has a large number of passes, and it will do no more passes after seeing an a previous pass. Thus, you might knock a file down to one error, fix that error, and then find that you have a couple dozen more errors.

> It's quite common and accepted for compilers to make assumptions about the rest of the code, and for those to be wrong if your code is broken. Indeed. Most annoyingly, many "modern" C compilers still attempt to muddle onward by replacing unknown types with "int".

I think the standard requires that.

Re: How to convince any C developer to dump gcc and use clang

#47

As a dynamic language guy, I can't help but look at the static analysis here and feel a twinge of jealousy. There really isn't anything like this in the Ruby world. Some stuff is starting to emerge, but we're still largely dependent on tests to catch stupid mistakes. When I'm chasing down a bug, it would be nice to have a variety of tools to throw at the problem.

I spend most of my time writing C code, but like to work with Python when I get the chance. There isn't anything like pylint for Ruby? A dynamic runtime doesn't necessarily mean you have to give up static analysis.

roody, rufus, reek, flay, flog, probably more. Sadly, in the current state of the ruby community it's even hard to find a library that will run with ruby's own warnings enabled.

Re: How to convince any C developer to dump gcc and use clang

#48
post #10

you're saying I should port all my code just because the ui is more user-friendly? what about performance, options, special warnings, builtins, and everything else? I've been using gcc for a while now, and every time I use it I found a new feature. It's rock solid and had never let me down.

just because the ui is more user-friendly? Those better warnings aren't just due to a simple UI patch ... clang is doing better and deeper static analysis than gcc in order to even be able to produce those more intelligent warnings.

gcc with the dehydra plugin is doing better and deeper static analysis than clang.

Re: How to convince any C developer to dump gcc and use clang

#49

Earlier quoted context omitted.

"What would happen if the programmer got a list of error and started fixing from the end?" I always fix the first 1 or 2 reported errors and try to recompile. I assume everyone did. A traditional "report on errors which are actually there each time they happen" compiler will give you tons of completely spurious errors which happily disappear once you fix the first few. In the instance you point out, it could just use…

One point was mentioned - recompiling time may be huge. On the other hand - if the recompile time is tiny, I don't bother with any specific order, I just fix what I see as trivial first. But when you see the clang's very verbose errors - how many can you fit on the screen? 10? 15? To make sure none of the last ones depend on some code guessing, you'd have to scroll to the top every time, instead of just fixing what y…

How long is recompiling really going to be if it's one file, though? I'm not talking about C++, which clang isn't quite fluent in yet, but one file of pure C shouldn't take long to compile. Or have I not been compiling the right C files?

Re: How to convince any C developer to dump gcc and use clang

#50
post #44
post #25

I am currently switching between gcc and clang for my codebase. The performance is mixed. For some programs (2-level hashtable, for example), the clang version got about 50% speed up against gcc and icc. But other programs (sobel filter for example), clang version slows down about 25% (against gcc 4.4). The result certainly machine specific, but I think clang can do better in a long run.

Although cryptic, I'd say that gcc's error messages are manageable. I'd hold other factors, such as performance of compiled code - across platforms - to be more important. Alternatively, they could improve on the C++ template error reporting (when they get around to taking C++ support beyond alpha) and that may be enough to sell me. a quick search yields http://clang.llvm.org/performance.html (favourable, but somewha…

If clang could come up with better C++ template error messages that would be really sweet. STL related error messages in g++ (and MSVC) are really hard to figure out, especially when C++ is not your main language; so you're not exposed to those problems on a daily basis.
Post reply on HN